1 unstable release
0.1.0 | Mar 12, 2023 |
---|
#874 in Authentication
330KB
1K
SLoC
Fire-and-Forget Bot
A Matrix bot aimed at one-shot usage from the command line.
Features/usage
The command itself is most helpful:
Usage: fafbot [OPTIONS] <COMMAND>
Commands:
login Login to server with user and password
login-sso Login to server through SSO
login-restore-session Login to server by reusing an existing token
join Join room
leave Leave room
list-joined List joined rooms
list-invited List rooms invited to
send Send message
help Print this message or the help of the given subcommand(s)
Options:
--debug Enable debug logging
--dry-run Do everything but send the message and join/leave channels (still log in, etc)
-d, --db-dir <db-dir> Directory where the bot state is stored [env: FAFBOT_DB_DIR] [default: /home/user/.local/state/fafbot]
-h, --help Print help
In essence:
- You need to login to the server by running one of the three first subcommands.
- For the next invocation, you should join a room using the
join
subcommand. If you want to join a private room, make sure to be invited first. Thelist-invited
subcommand is available for your convenience. - Do whatever; join/leave rooms, send messages. I'm not your mother.
If you are not familiar with Matrix, please note that a user may have one or more devices. Matrix' E2E encryption works by sending encryption keys to each user's device which means that it's customary to keep your device count down as a user. This is why login is separated from join/leave/send, and why there is a state directory: Each sign-in will create a session, i.e. a device.
Known issues 1
Sometimes when running, fafbot may stumble upon issues in decryption. This seems to be an issue with the Matrix SDK, and looks to be benign:
Failed to decrypt a non-pre-key message with all available sessions sender=@user:example.org sender_key=f0O69NqwrEVNjdnqlwhQPdn4xVqF05YGr8wR1Jhi+mTNr0UFAaOiQtu1Q
An Olm message got replayed, decryption failed sender="@user:example.org" sender_key=vf0O69NqwrEVNjdnqlwhQPdn4xVqF05YGr8wR1Jhi+mTNr0UFAaOiQtu1Q
And:
Failed to deserialize a global account data event error=Error("unknown variant `org.matrix.msc3931.room_version_supports`, expected one of `event_match`, `contains_display_name`, `room_member_count`, `sender_notification_permission`", line: 1, column: 1018)
Failed to deserialize a global account data event error=Error("unknown variant `org.matrix.msc3931.room_version_supports`, expected one of `event_match`, `contains_display_name`, `room_member_count`, `sender_notification_permission`", line: 1, column: 1018)
Known issues 2
If using the login-restore-session
subcommand, there must be no keys
registered for the device. If there are, you will see errors like this and will
need to set up a new session:
Error when sending out an outgoing E2EE request error=Http(Api(Server(Known(ClientApi(Error { kind: Unknown, message: "One time key signed_curve25519:AAAAAAAAAA0 already exists. Old key: {\"key\":\"mme2Wf6Bj4wfx50ZHIr6LbR7eVGByKQFwHtmgOYjpoOqAQa1gM1SLKD2hg\",\"signatures\":{\"@user:example.org\":{\"ed25519:\":\"a072/U1At3i1JXi7XzOaCsRTR8hhjcgLwMS4Q5pOFCkRBA9KX2J8RWcX+/m5adqcybUzHrgtQ3TCaz9N1rmAEP2eNfsVA1Ug/IcImub7MT1xQ4kzr2Y\"}}}; new key: {'key': 'd44FTHHoKWazpSZhHKUpPFoakL0p3RhUrxoyFmEphmoBxfO+cA2KOkh4AQ', 'signatures': {'@user:example.org': {'ed25519:BIEPEEXIEN': '9cynKfWRywWX3y1+dp3XzrS7HMa2v9DKButSZYv/F4gLCI3pnSLH+NRuMpEMiIsMcrW6xsg6cImK9nbZ/f/lYlbWfTUUIMRsx5inyTWl9qvnpepegNM'}}}", status_code: 400 })))))
Dependencies
~28–43MB
~721K SLoC