Documentation ¶
Index ¶
- Variables
- type BotClient
- func (botClient *BotClient) DecryptMegolmEvent(evt *mevt.Event) (*mevt.Event, error)
- func (botClient *BotClient) ForwardRoomKeyToDevice(userID id.UserID, deviceID id.DeviceID, roomID id.RoomID, ...) error
- func (botClient *BotClient) InitOlmMachine(client *mautrix.Client, nebStore *matrix.NEBStore) (err error)
- func (botClient *BotClient) InvalidateRoomSession(roomID id.RoomID) (id.SessionID, error)
- func (botClient *BotClient) OnCancel(cancelledByUs bool, reason string, reasonCode mevt.VerificationCancelCode)
- func (botClient *BotClient) OnSuccess()
- func (botClient *BotClient) Register(syncer mautrix.ExtensibleSyncer)
- func (botClient *BotClient) SendMessageEvent(roomID id.RoomID, evtType mevt.Type, content interface{}, ...) (*mautrix.RespSendEvent, error)
- func (botClient *BotClient) SendRoomKeyRequest(userID id.UserID, deviceID id.DeviceID, roomID id.RoomID, ...) (chan bool, error)
- func (botClient *BotClient) StartSASVerification(userID id.UserID, deviceID id.DeviceID) (string, error)
- func (botClient *BotClient) SubmitDecimalSAS(otherUser id.UserID, otherDevice id.DeviceID, sas crypto.DecimalSASData)
- func (botClient *BotClient) Sync()
- func (botClient *BotClient) VerificationMethods() []crypto.VerificationMethod
- func (botClient *BotClient) VerifySASMatch(otherDevice *crypto.DeviceIdentity, sas crypto.SASData) bool
- type Clients
- type CryptoMachineLogger
- type NebStateStore
- func (ss *NebStateStore) FindSharedRooms(userID id.UserID) []id.RoomID
- func (ss *NebStateStore) GetEncryptionEvent(roomID id.RoomID) *event.EncryptionEventContent
- func (ss *NebStateStore) GetJoinedMembers(roomID id.RoomID) ([]id.UserID, error)
- func (ss *NebStateStore) IsEncrypted(roomID id.RoomID) bool
- func (ss *NebStateStore) UpdateStateStore(resp *mautrix.RespSync)
Constants ¶
This section is empty.
Variables ¶
var StateBotOptionsEvent = mevt.Type{Type: "m.room.bot.options", Class: mevt.StateEventType}
Functions ¶
This section is empty.
Types ¶
type BotClient ¶
BotClient represents one of the bot's sessions, with a specific User and Device ID. It can be used for sending messages and retrieving information about the rooms that the client has joined.
func (*BotClient) DecryptMegolmEvent ¶
DecryptMegolmEvent attempts to decrypt an incoming m.room.encrypted message using the session information already present in the OlmMachine. The corresponding decrypted event is then returned. If it fails, usually because the session is not known, an error is returned.
func (*BotClient) ForwardRoomKeyToDevice ¶
func (botClient *BotClient) ForwardRoomKeyToDevice(userID id.UserID, deviceID id.DeviceID, roomID id.RoomID, senderKey id.SenderKey, sessionID id.SessionID) error
ForwardRoomKeyToDevice sends a room key to another device.
func (*BotClient) InitOlmMachine ¶
func (botClient *BotClient) InitOlmMachine(client *mautrix.Client, nebStore *matrix.NEBStore) (err error)
InitOlmMachine initializes a BotClient's internal OlmMachine given a client object and a Neb store, which will be used to store room information.
func (*BotClient) InvalidateRoomSession ¶
InvalidateRoomSession invalidates the outbound group session for the given room.
func (*BotClient) OnCancel ¶
func (botClient *BotClient) OnCancel(cancelledByUs bool, reason string, reasonCode mevt.VerificationCancelCode)
OnCancel is called when a SAS verification is canceled.
func (*BotClient) OnSuccess ¶
func (botClient *BotClient) OnSuccess()
OnSuccess is called when a SAS verification is successful.
func (*BotClient) Register ¶
func (botClient *BotClient) Register(syncer mautrix.ExtensibleSyncer)
Register registers a BotClient's Sync and StateMember event callbacks to update its internal state when new events arrive.
func (*BotClient) SendMessageEvent ¶
func (botClient *BotClient) SendMessageEvent(roomID id.RoomID, evtType mevt.Type, content interface{}, extra ...mautrix.ReqSendEvent) (*mautrix.RespSendEvent, error)
SendMessageEvent sends the given content to the given room ID using this BotClient as a message event. If the target room has enabled encryption, a megolm session is created if one doesn't already exist and the message is sent after being encrypted.
func (*BotClient) SendRoomKeyRequest ¶
func (botClient *BotClient) SendRoomKeyRequest(userID id.UserID, deviceID id.DeviceID, roomID id.RoomID, senderKey id.SenderKey, sessionID id.SessionID, timeout time.Duration) (chan bool, error)
SendRoomKeyRequest sends a room key request to another device.
func (*BotClient) StartSASVerification ¶
func (botClient *BotClient) StartSASVerification(userID id.UserID, deviceID id.DeviceID) (string, error)
StartSASVerification starts a new SAS verification with the given user and device ID and returns the transaction ID if successful.
func (*BotClient) SubmitDecimalSAS ¶
func (botClient *BotClient) SubmitDecimalSAS(otherUser id.UserID, otherDevice id.DeviceID, sas crypto.DecimalSASData)
SubmitDecimalSAS stores the received decimal SAS from another device to compare to the local one. It stores the SAS in the bot client's SAS sync map to be retrieved from the `VerifySASMatch` function.
func (*BotClient) Sync ¶
func (botClient *BotClient) Sync()
Sync loops to keep syncing the client with the homeserver by calling the /sync endpoint.
func (*BotClient) VerificationMethods ¶
func (botClient *BotClient) VerificationMethods() []crypto.VerificationMethod
VerificationMethods returns the supported SAS verification methods. As a bot we only support decimal as it's easier to understand.
func (*BotClient) VerifySASMatch ¶
func (botClient *BotClient) VerifySASMatch(otherDevice *crypto.DeviceIdentity, sas crypto.SASData) bool
VerifySASMatch returns whether the received SAS matches the SAS that the bot generated. It retrieves the SAS of the other device from the bot client's SAS sync map, where it was stored by the `SubmitDecimalSAS` function.
type Clients ¶
type Clients struct {
// contains filtered or unexported fields
}
A Clients is a collection of clients used for bot services.
func (*Clients) Update ¶
func (c *Clients) Update(config api.ClientConfig) (api.ClientConfig, error)
Update updates the config for a matrix client
type CryptoMachineLogger ¶
type CryptoMachineLogger struct{}
CryptoMachineLogger wraps around the usual logger, implementing the Logger interface needed by OlmMachine.
func (CryptoMachineLogger) Debug ¶
func (CryptoMachineLogger) Debug(message string, args ...interface{})
Debug formats and logs a debug message.
func (CryptoMachineLogger) Error ¶
func (CryptoMachineLogger) Error(message string, args ...interface{})
Error formats and logs an error message.
func (CryptoMachineLogger) Trace ¶
func (CryptoMachineLogger) Trace(message string, args ...interface{})
Trace formats and logs a trace message.
func (CryptoMachineLogger) Warn ¶
func (CryptoMachineLogger) Warn(message string, args ...interface{})
Warn formats and logs a warning message.
type NebStateStore ¶
type NebStateStore struct {
Storer *mautrix.InMemoryStore
}
NebStateStore implements the StateStore interface for OlmMachine. It is used to determine which rooms are encrypted and which rooms are shared with a user. The state is updated by /sync responses.
func (*NebStateStore) FindSharedRooms ¶
func (ss *NebStateStore) FindSharedRooms(userID id.UserID) []id.RoomID
FindSharedRooms returns a list of room IDs that the given user ID is also a member of.
func (*NebStateStore) GetEncryptionEvent ¶
func (ss *NebStateStore) GetEncryptionEvent(roomID id.RoomID) *event.EncryptionEventContent
GetEncryptionEvent returns the encryption event for a room.
func (*NebStateStore) GetJoinedMembers ¶
GetJoinedMembers returns a list of members that are currently in a room.
func (*NebStateStore) IsEncrypted ¶
func (ss *NebStateStore) IsEncrypted(roomID id.RoomID) bool
IsEncrypted returns whether a room has been encrypted.
func (*NebStateStore) UpdateStateStore ¶
func (ss *NebStateStore) UpdateStateStore(resp *mautrix.RespSync)
UpdateStateStore updates the internal state of NebStateStore from a /sync response.