Documentation ¶
Overview ¶
Package mautrix implements the Matrix Client-Server API.
Specification can be found at http://matrix.org/docs/spec/client_server/r0.4.0.html
Index ¶
- Constants
- Variables
- type AccountDataStore
- type AuthType
- type BaseAuthData
- type Client
- func (cli *Client) AddTag(roomID id.RoomID, tag string, order float64) (err error)
- func (cli *Client) BanUser(roomID id.RoomID, req *ReqBanUser) (resp *RespBanUser, err error)
- func (cli *Client) BuildBaseURL(urlPath ...interface{}) string
- func (cli *Client) BuildURL(urlPath ...interface{}) string
- func (cli *Client) BuildURLWithQuery(urlPath URLPath, urlQuery map[string]string) string
- func (cli *Client) ClaimKeys(req *ReqClaimKeys) (resp *RespClaimKeys, err error)
- func (cli *Client) ClearCredentials()
- func (cli *Client) CreateAlias(alias id.RoomAlias, roomID id.RoomID) (resp *RespAliasCreate, err error)
- func (cli *Client) CreateFilter(filter *Filter) (resp *RespCreateFilter, err error)
- func (cli *Client) CreateRoom(req *ReqCreateRoom) (resp *RespCreateRoom, err error)
- func (cli *Client) DeleteAlias(alias id.RoomAlias) (resp *RespAliasDelete, err error)
- func (cli *Client) DeleteDevice(deviceID id.DeviceID, req *ReqDeleteDevice) error
- func (cli *Client) DeleteDevices(req *ReqDeleteDevices) error
- func (cli *Client) DeletePushRule(scope string, kind pushrules.PushRuleType, ruleID string) error
- func (cli *Client) Download(mxcURL id.ContentURI) (io.ReadCloser, error)
- func (cli *Client) DownloadBytes(mxcURL id.ContentURI) ([]byte, error)
- func (cli *Client) ForgetRoom(roomID id.RoomID) (resp *RespForgetRoom, err error)
- func (cli *Client) GetAccountData(name string, output interface{}) (err error)
- func (cli *Client) GetAvatarURL(mxid id.UserID) (url id.ContentURI, err error)
- func (cli *Client) GetDeviceInfo(deviceID id.DeviceID) (resp *RespDeviceInfo, err error)
- func (cli *Client) GetDevicesInfo() (resp *RespDevicesInfo, err error)
- func (cli *Client) GetDisplayName(mxid id.UserID) (resp *RespUserDisplayName, err error)
- func (cli *Client) GetDownloadURL(mxcURL id.ContentURI) string
- func (cli *Client) GetEvent(roomID id.RoomID, eventID id.EventID) (resp *event.Event, err error)
- func (cli *Client) GetKeyChanges(from, to string) (resp *RespKeyChanges, err error)
- func (cli *Client) GetLoginFlows() (resp *RespLoginFlows, err error)
- func (cli *Client) GetOwnAvatarURL() (url id.ContentURI, err error)
- func (cli *Client) GetOwnDisplayName() (resp *RespUserDisplayName, err error)
- func (cli *Client) GetPushRule(scope string, kind pushrules.PushRuleType, ruleID string) (resp *pushrules.PushRule, err error)
- func (cli *Client) GetPushRules() (*pushrules.PushRuleset, error)
- func (cli *Client) GetScopedPushRules(scope string) (resp *pushrules.PushRuleset, err error)
- func (cli *Client) InviteUser(roomID id.RoomID, req *ReqInviteUser) (resp *RespInviteUser, err error)
- func (cli *Client) InviteUserByThirdParty(roomID id.RoomID, req *ReqInvite3PID) (resp *RespInviteUser, err error)
- func (cli *Client) JoinRoom(roomIDorAlias, serverName string, content interface{}) (resp *RespJoinRoom, err error)
- func (cli *Client) JoinRoomByID(roomID id.RoomID) (resp *RespJoinRoom, err error)
- func (cli *Client) JoinedMembers(roomID id.RoomID) (resp *RespJoinedMembers, err error)
- func (cli *Client) JoinedRooms() (resp *RespJoinedRooms, err error)
- func (cli *Client) KickUser(roomID id.RoomID, req *ReqKickUser) (resp *RespKickUser, err error)
- func (cli *Client) LeaveRoom(roomID id.RoomID) (resp *RespLeaveRoom, err error)
- func (cli *Client) LogRequest(req *http.Request, body string)
- func (cli *Client) Login(req *ReqLogin) (resp *RespLogin, err error)
- func (cli *Client) Logout() (resp *RespLogout, err error)
- func (cli *Client) MakeFullRequest(method string, httpURL string, headers http.Header, reqBody interface{}, ...) ([]byte, error)
- func (cli *Client) MakeRequest(method string, httpURL string, reqBody interface{}, resBody interface{}) ([]byte, error)
- func (cli *Client) MarkRead(roomID id.RoomID, eventID id.EventID) (err error)
- func (cli *Client) Members(roomID id.RoomID, req ...ReqMembers) (resp *RespMembers, err error)
- func (cli *Client) Messages(roomID id.RoomID, from, to string, dir rune, limit int) (resp *RespMessages, err error)
- func (cli *Client) PutPushRule(scope string, kind pushrules.PushRuleType, ruleID string, req *ReqPutPushRule) error
- func (cli *Client) QueryKeys(req *ReqQueryKeys) (resp *RespQueryKeys, err error)
- func (cli *Client) RedactEvent(roomID id.RoomID, eventID id.EventID, extra ...ReqRedact) (resp *RespSendEvent, err error)
- func (cli *Client) Register(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
- func (cli *Client) RegisterDummy(req *ReqRegister) (*RespRegister, error)
- func (cli *Client) RegisterGuest(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
- func (cli *Client) RemoveTag(roomID id.RoomID, tag string) (err error)
- func (cli *Client) ResolveAlias(alias id.RoomAlias) (resp *RespAliasResolve, err error)
- func (cli *Client) SendImage(roomID id.RoomID, body string, url id.ContentURI) (*RespSendEvent, error)
- func (cli *Client) SendMassagedStateEvent(roomID id.RoomID, eventType event.Type, stateKey string, ...) (resp *RespSendEvent, err error)
- func (cli *Client) SendMessageEvent(roomID id.RoomID, eventType event.Type, contentJSON interface{}, ...) (resp *RespSendEvent, err error)
- func (cli *Client) SendNotice(roomID id.RoomID, text string) (*RespSendEvent, error)
- func (cli *Client) SendReaction(roomID id.RoomID, eventID id.EventID, reaction string) (*RespSendEvent, error)
- func (cli *Client) SendStateEvent(roomID id.RoomID, eventType event.Type, stateKey string, ...) (resp *RespSendEvent, err error)
- func (cli *Client) SendText(roomID id.RoomID, text string) (*RespSendEvent, error)
- func (cli *Client) SendToDevice(eventType event.Type, req *ReqSendToDevice) (resp *RespSendToDevice, err error)
- func (cli *Client) SendVideo(roomID id.RoomID, body string, url id.ContentURI) (*RespSendEvent, error)
- func (cli *Client) SetAccountData(name string, data interface{}) (err error)
- func (cli *Client) SetAvatarURL(url id.ContentURI) (err error)
- func (cli *Client) SetCredentials(userID id.UserID, accessToken string)deprecated
- func (cli *Client) SetDeviceInfo(deviceID id.DeviceID, req *ReqDeviceInfo) error
- func (cli *Client) SetDisplayName(displayName string) (err error)
- func (cli *Client) SetPresence(status event.Presence) (err error)
- func (cli *Client) SetTags(roomID id.RoomID, tags event.Tags) (err error)
- func (cli *Client) StateEvent(roomID id.RoomID, eventType event.Type, stateKey string, ...) (err error)
- func (cli *Client) StopSync()
- func (cli *Client) Sync() error
- func (cli *Client) SyncRequest(timeout int, since, filterID string, fullState bool, ...) (resp *RespSync, err error)
- func (cli *Client) TurnServer() (resp *RespTurnServer, err error)
- func (cli *Client) TxnID() string
- func (cli *Client) UnbanUser(roomID id.RoomID, req *ReqUnbanUser) (resp *RespUnbanUser, err error)
- func (cli *Client) Upload(content io.Reader, contentType string, contentLength int64) (*RespMediaUpload, error)deprecated
- func (cli *Client) UploadBytes(data []byte, contentType string) (*RespMediaUpload, error)
- func (cli *Client) UploadBytesWithName(data []byte, contentType, fileName string) (*RespMediaUpload, error)
- func (cli *Client) UploadCrossSigningKeys(keys *UploadCrossSigningKeysReq, uiaCallback UIACallback) error
- func (cli *Client) UploadKeys(req *ReqUploadKeys) (resp *RespUploadKeys, err error)
- func (cli *Client) UploadLink(link string) (*RespMediaUpload, error)
- func (cli *Client) UploadMedia(data ReqUploadMedia) (*RespMediaUpload, error)
- func (cli *Client) UploadSignatures(req *ReqUploadSignatures) (resp *RespUploadSignatures, err error)
- func (cli *Client) UserTyping(roomID id.RoomID, typing bool, timeout int64) (resp *RespTyping, err error)
- func (cli *Client) Versions() (resp *RespVersions, err error)
- func (cli *Client) Whoami() (resp *RespWhoami, err error)
- type ClientWellKnown
- type CrossSigningKeys
- type DefaultSyncer
- func (s *DefaultSyncer) GetFilterJSON(userID id.UserID) *Filter
- func (s *DefaultSyncer) OnEvent(callback EventHandler)
- func (s *DefaultSyncer) OnEventType(eventType event.Type, callback EventHandler)
- func (s *DefaultSyncer) OnFailedSync(res *RespSync, err error) (time.Duration, error)
- func (s *DefaultSyncer) OnSync(callback SyncHandler)
- func (s *DefaultSyncer) ProcessResponse(res *RespSync, since string) (err error)
- type DeviceIDList
- type DeviceKeys
- type DeviceKeysRequest
- type EventFormat
- type EventHandler
- type EventSource
- type ExtensibleSyncer
- type Filter
- type FilterPart
- type HTTPError
- type HomeserverInfo
- type IdentifierType
- type IdentityServerInfo
- type InMemoryStore
- func (s *InMemoryStore) LoadFilterID(userID id.UserID) string
- func (s *InMemoryStore) LoadNextBatch(userID id.UserID) string
- func (s *InMemoryStore) LoadRoom(roomID id.RoomID) *Room
- func (s *InMemoryStore) SaveFilterID(userID id.UserID, filterID string)
- func (s *InMemoryStore) SaveNextBatch(userID id.UserID, nextBatchToken string)
- func (s *InMemoryStore) SaveRoom(room *Room)
- func (s *InMemoryStore) UpdateState(_ EventSource, evt *event.Event)
- type KeyMap
- type LazyLoadSummary
- type Logger
- type OldEventIgnorer
- type OneTimeKey
- type OneTimeKeysCount
- type OneTimeKeysRequest
- type ReqAliasCreate
- type ReqBanUser
- type ReqClaimKeys
- type ReqCreateRoom
- type ReqDeleteDevice
- type ReqDeleteDevices
- type ReqDeviceInfo
- type ReqInvite3PID
- type ReqInviteUser
- type ReqKeysSignatures
- type ReqKickUser
- type ReqLogin
- type ReqMembers
- type ReqPresence
- type ReqPutPushRule
- type ReqQueryKeys
- type ReqRedact
- type ReqRegister
- type ReqSendEvent
- type ReqSendToDevice
- type ReqTyping
- type ReqUIAuthFallback
- type ReqUIAuthLogin
- type ReqUnbanUser
- type ReqUploadKeys
- type ReqUploadMedia
- type ReqUploadSignatures
- type RespAliasCreate
- type RespAliasDelete
- type RespAliasResolve
- type RespBanUser
- type RespClaimKeys
- type RespCreateFilter
- type RespCreateRoom
- type RespDeviceInfo
- type RespDevicesInfo
- type RespError
- type RespForgetRoom
- type RespInviteUser
- type RespJoinRoom
- type RespJoinedMembers
- type RespJoinedRooms
- type RespKeyChanges
- type RespKickUser
- type RespLeaveRoom
- type RespLogin
- type RespLoginFlows
- type RespLogout
- type RespMediaUpload
- type RespMembers
- type RespMessages
- type RespQueryKeys
- type RespRegister
- type RespSendEvent
- type RespSendToDevice
- type RespSync
- type RespTurnServer
- type RespTyping
- type RespUnbanUser
- type RespUploadKeys
- type RespUploadSignatures
- type RespUserDisplayName
- type RespUserInteractive
- type RespVersions
- type RespWhoami
- type Room
- type RoomFilter
- type Signatures
- type Storer
- type Stringifiable
- type SyncHandler
- type SyncInvitedRoom
- type SyncJoinedRoom
- type SyncLeftRoom
- type Syncer
- type UIACallback
- type URLPath
- type UploadCrossSigningKeysReq
- type UserIdentifier
Constants ¶
const ( AuthTypePassword = "m.login.password" AuthTypeReCAPTCHA = "m.login.recaptcha" AuthTypeOAuth2 = "m.login.oauth2" AuthTypeSSO = "m.login.sso" AuthTypeEmail = "m.login.email.identity" AuthTypeMSISDN = "m.login.msisdn" AuthTypeToken = "m.login.token" AuthTypeDummy = "m.login.dummy" AuthTypeAppservice = "uk.half-shot.msc2778.login.application_service" )
const ( IdentifierTypeUser = "m.id.user" IdentifierTypeThirdParty = "m.id.thirdparty" IdentifierTypePhone = "m.id.phone" )
const Version = "v0.8.5"
Variables ¶
var ( // Forbidden access, e.g. joining a room without permission, failed login. MForbidden = RespError{ErrCode: "M_FORBIDDEN"} // The access token specified was not recognised. MUnknownToken = RespError{ErrCode: "M_UNKNOWN_TOKEN"} // No access token was specified for the request. MMissingToken = RespError{ErrCode: "M_MISSING_TOKEN"} // Request contained valid JSON, but it was malformed in some way, e.g. missing required keys, invalid values for keys. MBadJSON = RespError{ErrCode: "M_BAD_JSON"} // Request did not contain valid JSON. MNotJSON = RespError{ErrCode: "M_NOT_JSON"} // No resource was found for this request. MNotFound = RespError{ErrCode: "M_NOT_FOUND"} // Too many requests have been sent in a short period of time. Wait a while then try again. MLimitExceeded = RespError{ErrCode: "M_LIMIT_EXCEEDED"} // The user ID associated with the request has been deactivated. // Typically for endpoints that prove authentication, such as /login. MUserDeactivated = RespError{ErrCode: "M_USER_DEACTIVATED"} // Encountered when trying to register a user ID which has been taken. MUserInUse = RespError{ErrCode: "M_USER_IN_USE"} // Encountered when trying to register a user ID which is not valid. MInvalidUsername = RespError{ErrCode: "M_INVALID_USERNAME"} // Sent when the room alias given to the createRoom API is already in use. MRoomInUse = RespError{ErrCode: "M_ROOM_IN_USE"} // The state change requested cannot be performed, such as attempting to unban a user who is not banned. MBadState = RespError{ErrCode: "M_BAD_STATE"} // The request or entity was too large. MTooLarge = RespError{ErrCode: "M_TOO_LARGE"} // The resource being requested is reserved by an application service, or the application service making the request has not created the resource. MExclusive = RespError{ErrCode: "M_EXCLUSIVE"} // The client's request to create a room used a room version that the server does not support. MUnsupportedRoomVersion = RespError{ErrCode: "M_UNSUPPORTED_ROOM_VERSION"} // The client attempted to join a room that has a version the server does not support. // Inspect the room_version property of the error response for the room's version. MIncompatibleRoomVersion = RespError{ErrCode: "M_INCOMPATIBLE_ROOM_VERSION"} )
Common error codes from https://matrix.org/docs/spec/client_server/latest#api-standards
Can be used with errors.Is() to check the response code without casting the error:
err := client.Sync() if errors.Is(err, MUnknownToken) { // logout }
Functions ¶
This section is empty.
Types ¶
type AccountDataStore ¶ added in v0.8.1
type AccountDataStore struct { *InMemoryStore // contains filtered or unexported fields }
AccountDataStore uses account data to store the next batch token, and reuses the InMemoryStore for all other operations.
func NewAccountDataStore ¶ added in v0.8.1
func NewAccountDataStore(eventType string, client *Client) *AccountDataStore
NewAccountDataStore returns a new AccountDataStore, which stores the next_batch token as a custom event in account data in the homeserver.
AccountDataStore is only appropriate for bots, not appservices.
eventType should be a reversed DNS name like tld.domain.sub.internal and must be unique for a client. The data stored in it is considered internal and must not be modified through outside means. You should also add a filter for account data changes of this event type, to avoid ending up in a sync loop:
mautrix.Filter{ AccountData: mautrix.FilterPart{ Limit: 20, NotTypes: []event.Type{ event.NewEventType(eventType), }, }, } mautrix.Client.CreateFilter(...)
func (*AccountDataStore) LoadNextBatch ¶ added in v0.8.1
func (s *AccountDataStore) LoadNextBatch(userID id.UserID) string
LoadNextBatch from account data.
func (*AccountDataStore) SaveNextBatch ¶ added in v0.8.1
func (s *AccountDataStore) SaveNextBatch(userID id.UserID, nextBatchToken string)
SaveNextBatch to account data.
type BaseAuthData ¶ added in v0.7.1
type Client ¶
type Client struct { HomeserverURL *url.URL // The base homeserver URL Prefix URLPath // The API prefix eg '/_matrix/client/r0' UserID id.UserID // The user ID of the client. Used for forming HTTP paths which use the client's user ID. DeviceID id.DeviceID // The device ID of the client. AccessToken string // The access_token for the client. UserAgent string // The value for the User-Agent header Client *http.Client // The underlying HTTP client which will be used to make HTTP requests. Syncer Syncer // The thing which can process /sync responses Store Storer // The thing which can store rooms/tokens/ids Logger Logger SyncPresence event.Presence // The ?user_id= query parameter for application services. This must be set *prior* to calling a method. If this is empty, // no user_id parameter will be sent. // See http://matrix.org/docs/spec/application_service/unstable.html#identity-assertion AppServiceUserID id.UserID // contains filtered or unexported fields }
Client represents a Matrix client.
func (*Client) BanUser ¶
func (cli *Client) BanUser(roomID id.RoomID, req *ReqBanUser) (resp *RespBanUser, err error)
BanUser bans a user from a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-ban
func (*Client) BuildBaseURL ¶
BuildBaseURL builds a URL with the Client's homeserver/access_token set already. You must supply the prefix in the path.
func (*Client) BuildURL ¶
BuildURL builds a URL with the Client's homserver/prefix/access_token set already.
func (*Client) BuildURLWithQuery ¶
BuildURLWithQuery builds a URL with query parameters in addition to the Client's homeserver/prefix/access_token set already.
func (*Client) ClaimKeys ¶
func (cli *Client) ClaimKeys(req *ReqClaimKeys) (resp *RespClaimKeys, err error)
func (*Client) ClearCredentials ¶
func (cli *Client) ClearCredentials()
ClearCredentials removes the user ID and access token on this client instance.
func (*Client) CreateAlias ¶
func (*Client) CreateFilter ¶
func (cli *Client) CreateFilter(filter *Filter) (resp *RespCreateFilter, err error)
CreateFilter makes an HTTP request according to http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-user-userid-filter
func (*Client) CreateRoom ¶
func (cli *Client) CreateRoom(req *ReqCreateRoom) (resp *RespCreateRoom, err error)
CreateRoom creates a new Matrix room. See https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom
resp, err := cli.CreateRoom(&mautrix.ReqCreateRoom{ Preset: "public_chat", }) fmt.Println("Room:", resp.RoomID)
func (*Client) DeleteAlias ¶
func (cli *Client) DeleteAlias(alias id.RoomAlias) (resp *RespAliasDelete, err error)
func (*Client) DeleteDevice ¶ added in v0.8.3
func (cli *Client) DeleteDevice(deviceID id.DeviceID, req *ReqDeleteDevice) error
func (*Client) DeleteDevices ¶ added in v0.8.3
func (cli *Client) DeleteDevices(req *ReqDeleteDevices) error
func (*Client) DeletePushRule ¶ added in v0.4.11
func (*Client) Download ¶
func (cli *Client) Download(mxcURL id.ContentURI) (io.ReadCloser, error)
func (*Client) DownloadBytes ¶
func (cli *Client) DownloadBytes(mxcURL id.ContentURI) ([]byte, error)
func (*Client) ForgetRoom ¶
func (cli *Client) ForgetRoom(roomID id.RoomID) (resp *RespForgetRoom, err error)
ForgetRoom forgets a room entirely. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-forget
func (*Client) GetAccountData ¶ added in v0.7.2
GetAccountData gets the user's account data of this type. See https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-user-userid-account-data-type
func (*Client) GetAvatarURL ¶
GetAvatarURL gets the avatar URL of the user with the specified MXID. See http://matrix.org/docs/spec/client_server/r0.6.1.html#get-matrix-client-r0-profile-userid-avatar-url
func (*Client) GetDeviceInfo ¶ added in v0.8.3
func (cli *Client) GetDeviceInfo(deviceID id.DeviceID) (resp *RespDeviceInfo, err error)
func (*Client) GetDevicesInfo ¶ added in v0.8.3
func (cli *Client) GetDevicesInfo() (resp *RespDevicesInfo, err error)
func (*Client) GetDisplayName ¶
func (cli *Client) GetDisplayName(mxid id.UserID) (resp *RespUserDisplayName, err error)
GetDisplayName returns the display name of the user with the specified MXID. See https://matrix.org/docs/spec/client_server/r0.6.1.html#get-matrix-client-r0-profile-userid-displayname
func (*Client) GetDownloadURL ¶
func (cli *Client) GetDownloadURL(mxcURL id.ContentURI) string
func (*Client) GetKeyChanges ¶
func (cli *Client) GetKeyChanges(from, to string) (resp *RespKeyChanges, err error)
func (*Client) GetLoginFlows ¶
func (cli *Client) GetLoginFlows() (resp *RespLoginFlows, err error)
func (*Client) GetOwnAvatarURL ¶ added in v0.7.5
func (cli *Client) GetOwnAvatarURL() (url id.ContentURI, err error)
GetOwnAvatarURL gets the user's avatar URL. See http://matrix.org/docs/spec/client_server/r0.6.1.html#get-matrix-client-r0-profile-userid-avatar-url
func (*Client) GetOwnDisplayName ¶
func (cli *Client) GetOwnDisplayName() (resp *RespUserDisplayName, err error)
GetOwnDisplayName returns the user's display name. See https://matrix.org/docs/spec/client_server/r0.6.1.html#get-matrix-client-r0-profile-userid-displayname
func (*Client) GetPushRule ¶ added in v0.4.11
func (*Client) GetPushRules ¶
func (cli *Client) GetPushRules() (*pushrules.PushRuleset, error)
GetPushRules returns the push notification rules for the global scope.
func (*Client) GetScopedPushRules ¶
func (cli *Client) GetScopedPushRules(scope string) (resp *pushrules.PushRuleset, err error)
GetScopedPushRules returns the push notification rules for the given scope.
func (*Client) InviteUser ¶
func (cli *Client) InviteUser(roomID id.RoomID, req *ReqInviteUser) (resp *RespInviteUser, err error)
InviteUser invites a user to a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite
func (*Client) InviteUserByThirdParty ¶
func (cli *Client) InviteUserByThirdParty(roomID id.RoomID, req *ReqInvite3PID) (resp *RespInviteUser, err error)
InviteUserByThirdParty invites a third-party identifier to a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#invite-by-third-party-id-endpoint
func (*Client) JoinRoom ¶
func (cli *Client) JoinRoom(roomIDorAlias, serverName string, content interface{}) (resp *RespJoinRoom, err error)
JoinRoom joins the client to a room ID or alias. See http://matrix.org/docs/spec/client_server/r0.6.1.html#post-matrix-client-r0-join-roomidoralias
If serverName is specified, this will be added as a query param to instruct the homeserver to join via that server. If content is specified, it will be JSON encoded and used as the request body.
func (*Client) JoinRoomByID ¶ added in v0.3.5
func (cli *Client) JoinRoomByID(roomID id.RoomID) (resp *RespJoinRoom, err error)
JoinRoomByID joins the client to a room ID. See https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-join
Unlike JoinRoom, this method can only be used to join rooms that the server already knows about. It's mostly intended for bridges and other things where it's already certain that the server is in the room.
func (*Client) JoinedMembers ¶
func (cli *Client) JoinedMembers(roomID id.RoomID) (resp *RespJoinedMembers, err error)
JoinedMembers returns a map of joined room members. See https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-joined-rooms
In general, usage of this API is discouraged in favour of /sync, as calling this API can race with incoming membership changes. This API is primarily designed for application services which may want to efficiently look up joined members in a room.
func (*Client) JoinedRooms ¶
func (cli *Client) JoinedRooms() (resp *RespJoinedRooms, err error)
JoinedRooms returns a list of rooms which the client is joined to. See https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-joined-rooms
In general, usage of this API is discouraged in favour of /sync, as calling this API can race with incoming membership changes. This API is primarily designed for application services which may want to efficiently look up joined rooms.
func (*Client) KickUser ¶
func (cli *Client) KickUser(roomID id.RoomID, req *ReqKickUser) (resp *RespKickUser, err error)
KickUser kicks a user from a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-kick
func (*Client) LeaveRoom ¶
func (cli *Client) LeaveRoom(roomID id.RoomID) (resp *RespLeaveRoom, err error)
LeaveRoom leaves the given room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-leave
func (*Client) Login ¶
Login a user to the homeserver according to http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login
func (*Client) Logout ¶
func (cli *Client) Logout() (resp *RespLogout, err error)
Logout the current user. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-logout This does not clear the credentials from the client instance. See ClearCredentials() instead.
func (*Client) MakeFullRequest ¶ added in v0.7.2
func (cli *Client) MakeFullRequest(method string, httpURL string, headers http.Header, reqBody interface{}, resBody interface{}) ([]byte, error)
MakeFullRequest makes a JSON HTTP request to the given URL. If "resBody" is not nil, the response body will be json.Unmarshalled into it.
Returns the HTTP body as bytes on 2xx with a nil error. Returns an error if the response is not 2xx along with the HTTP body bytes if it got that far. This error is an HTTPError which includes the returned HTTP status code and possibly a RespError as the WrappedError, if the HTTP body could be decoded as a RespError.
func (*Client) MakeRequest ¶
func (*Client) Members ¶
func (cli *Client) Members(roomID id.RoomID, req ...ReqMembers) (resp *RespMembers, err error)
func (*Client) Messages ¶
func (cli *Client) Messages(roomID id.RoomID, from, to string, dir rune, limit int) (resp *RespMessages, err error)
Messages returns a list of message and state events for a room. It uses pagination query parameters to paginate history in the room. See https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-messages
func (*Client) PutPushRule ¶ added in v0.4.11
func (cli *Client) PutPushRule(scope string, kind pushrules.PushRuleType, ruleID string, req *ReqPutPushRule) error
func (*Client) QueryKeys ¶
func (cli *Client) QueryKeys(req *ReqQueryKeys) (resp *RespQueryKeys, err error)
func (*Client) RedactEvent ¶
func (cli *Client) RedactEvent(roomID id.RoomID, eventID id.EventID, extra ...ReqRedact) (resp *RespSendEvent, err error)
RedactEvent redacts the given event. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid
func (*Client) Register ¶
func (cli *Client) Register(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
Register makes an HTTP request according to http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register
Registers with kind=user. For kind=guest, see RegisterGuest.
func (*Client) RegisterDummy ¶
func (cli *Client) RegisterDummy(req *ReqRegister) (*RespRegister, error)
RegisterDummy performs m.login.dummy registration according to https://matrix.org/docs/spec/client_server/r0.2.0.html#dummy-auth
Only a username and password need to be provided on the ReqRegister struct. Most local/developer homeservers will allow registration this way. If the homeserver does not, an error is returned.
This does not set credentials on the client instance. See SetCredentials() instead.
res, err := cli.RegisterDummy(&mautrix.ReqRegister{ Username: "alice", Password: "wonderland", }) if err != nil { panic(err) } token := res.AccessToken
func (*Client) RegisterGuest ¶
func (cli *Client) RegisterGuest(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
RegisterGuest makes an HTTP request according to http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register with kind=guest.
For kind=user, see Register.
func (*Client) ResolveAlias ¶
func (cli *Client) ResolveAlias(alias id.RoomAlias) (resp *RespAliasResolve, err error)
func (*Client) SendImage ¶
func (cli *Client) SendImage(roomID id.RoomID, body string, url id.ContentURI) (*RespSendEvent, error)
SendImage sends an m.room.message event into the given room with a msgtype of m.image See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
func (*Client) SendMassagedStateEvent ¶
func (cli *Client) SendMassagedStateEvent(roomID id.RoomID, eventType event.Type, stateKey string, contentJSON interface{}, ts int64) (resp *RespSendEvent, err error)
SendStateEvent sends a state event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
func (*Client) SendMessageEvent ¶
func (cli *Client) SendMessageEvent(roomID id.RoomID, eventType event.Type, contentJSON interface{}, extra ...ReqSendEvent) (resp *RespSendEvent, err error)
SendMessageEvent sends a message event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
func (*Client) SendNotice ¶
SendNotice sends an m.room.message event into the given room with a msgtype of m.notice See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-notice
func (*Client) SendReaction ¶
func (*Client) SendStateEvent ¶
func (cli *Client) SendStateEvent(roomID id.RoomID, eventType event.Type, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error)
SendStateEvent sends a state event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
func (*Client) SendText ¶
SendText sends an m.room.message event into the given room with a msgtype of m.text See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-text
func (*Client) SendToDevice ¶
func (cli *Client) SendToDevice(eventType event.Type, req *ReqSendToDevice) (resp *RespSendToDevice, err error)
func (*Client) SendVideo ¶
func (cli *Client) SendVideo(roomID id.RoomID, body string, url id.ContentURI) (*RespSendEvent, error)
SendVideo sends an m.room.message event into the given room with a msgtype of m.video See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-video
func (*Client) SetAccountData ¶ added in v0.7.2
SetAccountData sets the user's account data of this type. See https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-user-userid-account-data-type
func (*Client) SetAvatarURL ¶
func (cli *Client) SetAvatarURL(url id.ContentURI) (err error)
SetAvatarURL sets the user's avatar URL. See http://matrix.org/docs/spec/client_server/r0.6.1.html#put-matrix-client-r0-profile-userid-avatar-url
func (*Client) SetCredentials
deprecated
func (*Client) SetDeviceInfo ¶ added in v0.8.3
func (cli *Client) SetDeviceInfo(deviceID id.DeviceID, req *ReqDeviceInfo) error
func (*Client) SetDisplayName ¶
SetDisplayName sets the user's profile display name. See http://matrix.org/docs/spec/client_server/r0.6.1.html#put-matrix-client-r0-profile-userid-displayname
func (*Client) StateEvent ¶
func (cli *Client) StateEvent(roomID id.RoomID, eventType event.Type, stateKey string, outContent interface{}) (err error)
StateEvent gets a single state event in a room. It will attempt to JSON unmarshal into the given "outContent" struct with the HTTP response body, or return an error. See http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-statekey
func (*Client) StopSync ¶
func (cli *Client) StopSync()
StopSync stops the ongoing sync started by Sync.
func (*Client) Sync ¶
Sync starts syncing with the provided Homeserver. If Sync() is called twice then the first sync will be stopped and the error will be nil.
This function will block until a fatal /sync error occurs, so it should almost always be started as a new goroutine. Fatal sync errors can be caused by:
- The failure to create a filter.
- Client.Syncer.OnFailedSync returning an error in response to a failed sync.
- Client.Syncer.ProcessResponse returning an error.
If you wish to continue retrying in spite of these fatal errors, call Sync() again.
func (*Client) SyncRequest ¶
func (cli *Client) SyncRequest(timeout int, since, filterID string, fullState bool, setPresence event.Presence) (resp *RespSync, err error)
SyncRequest makes an HTTP request according to http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync
func (*Client) TurnServer ¶
func (cli *Client) TurnServer() (resp *RespTurnServer, err error)
TurnServer returns turn server details and credentials for the client to use when initiating calls. See http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-voip-turnserver
func (*Client) UnbanUser ¶
func (cli *Client) UnbanUser(roomID id.RoomID, req *ReqUnbanUser) (resp *RespUnbanUser, err error)
UnbanUser unbans a user from a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-unban
func (*Client) UploadBytes ¶
func (cli *Client) UploadBytes(data []byte, contentType string) (*RespMediaUpload, error)
func (*Client) UploadBytesWithName ¶ added in v0.5.0
func (cli *Client) UploadBytesWithName(data []byte, contentType, fileName string) (*RespMediaUpload, error)
func (*Client) UploadCrossSigningKeys ¶ added in v0.8.0
func (cli *Client) UploadCrossSigningKeys(keys *UploadCrossSigningKeysReq, uiaCallback UIACallback) error
UploadCrossSigningKeys uploads the given cross-signing keys to the server. Because the endpoint requires user-interactive authentication a callback must be provided that, given the UI auth parameters, produces the required result (or nil to end the flow).
func (*Client) UploadKeys ¶
func (cli *Client) UploadKeys(req *ReqUploadKeys) (resp *RespUploadKeys, err error)
func (*Client) UploadLink ¶
func (cli *Client) UploadLink(link string) (*RespMediaUpload, error)
UploadLink uploads an HTTP URL and then returns an MXC URI.
func (*Client) UploadMedia ¶ added in v0.5.0
func (cli *Client) UploadMedia(data ReqUploadMedia) (*RespMediaUpload, error)
UploadMedia uploads the given data to the content repository and returns an MXC URI. See http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-media-r0-upload
func (*Client) UploadSignatures ¶ added in v0.8.0
func (cli *Client) UploadSignatures(req *ReqUploadSignatures) (resp *RespUploadSignatures, err error)
func (*Client) UserTyping ¶
func (cli *Client) UserTyping(roomID id.RoomID, typing bool, timeout int64) (resp *RespTyping, err error)
UserTyping sets the typing status of the user. See https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid
func (*Client) Versions ¶
func (cli *Client) Versions() (resp *RespVersions, err error)
Versions returns the list of supported Matrix versions on this homeserver. See http://matrix.org/docs/spec/client_server/r0.6.1.html#get-matrix-client-versions
func (*Client) Whoami ¶ added in v0.3.6
func (cli *Client) Whoami() (resp *RespWhoami, err error)
Whoami gets the user ID of the current user. See https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-rooms-roomid-join
type ClientWellKnown ¶
type ClientWellKnown struct { Homeserver HomeserverInfo `json:"m.homeserver"` IdentityServer IdentityServerInfo `json:"m.identity_server"` }
func DiscoverClientAPI ¶
func DiscoverClientAPI(serverName string) (*ClientWellKnown, error)
DiscoverClientAPI resolves the client API URL from a Matrix server name. Use ParseUserID to extract the server name from a user ID. https://matrix.org/docs/spec/client_server/r0.6.0#server-discovery
type CrossSigningKeys ¶ added in v0.8.0
type CrossSigningKeys struct { UserID id.UserID `json:"user_id"` Usage []id.CrossSigningUsage `json:"usage"` Keys map[id.KeyID]id.Ed25519 `json:"keys"` Signatures map[id.UserID]map[id.KeyID]string `json:"signatures,omitempty"` }
func (*CrossSigningKeys) FirstKey ¶ added in v0.8.0
func (csk *CrossSigningKeys) FirstKey() id.Ed25519
type DefaultSyncer ¶
type DefaultSyncer struct { // ParseEventContent determines whether or not event content should be parsed before passing to handlers. ParseEventContent bool // ParseErrorHandler is called when event.Content.ParseRaw returns an error. // If it returns false, the event will not be forwarded to listeners. ParseErrorHandler func(evt *event.Event, err error) bool // contains filtered or unexported fields }
DefaultSyncer is the default syncing implementation. You can either write your own syncer, or selectively replace parts of this default syncer (e.g. the ProcessResponse method). The default syncer uses the observer pattern to notify callers about incoming events. See DefaultSyncer.OnEventType for more information.
func NewDefaultSyncer ¶
func NewDefaultSyncer() *DefaultSyncer
NewDefaultSyncer returns an instantiated DefaultSyncer
func (*DefaultSyncer) GetFilterJSON ¶
func (s *DefaultSyncer) GetFilterJSON(userID id.UserID) *Filter
GetFilterJSON returns a filter with a timeline limit of 50.
func (*DefaultSyncer) OnEvent ¶ added in v0.5.0
func (s *DefaultSyncer) OnEvent(callback EventHandler)
func (*DefaultSyncer) OnEventType ¶
func (s *DefaultSyncer) OnEventType(eventType event.Type, callback EventHandler)
OnEventType allows callers to be notified when there are new events for the given event type. There are no duplicate checks.
func (*DefaultSyncer) OnFailedSync ¶
OnFailedSync always returns a 10 second wait period between failed /syncs, never a fatal error.
func (*DefaultSyncer) OnSync ¶ added in v0.5.0
func (s *DefaultSyncer) OnSync(callback SyncHandler)
func (*DefaultSyncer) ProcessResponse ¶
func (s *DefaultSyncer) ProcessResponse(res *RespSync, since string) (err error)
ProcessResponse processes the /sync response in a way suitable for bots. "Suitable for bots" means a stream of unrepeating events. Returns a fatal error if a listener panics.
type DeviceIDList ¶
type DeviceKeys ¶
type DeviceKeysRequest ¶
type DeviceKeysRequest map[id.UserID]DeviceIDList
type EventFormat ¶
type EventFormat string
const ( EventFormatClient EventFormat = "client" EventFormatFederation EventFormat = "federation" )
type EventHandler ¶ added in v0.5.0
type EventHandler func(source EventSource, evt *event.Event)
EventHandler handles a single event from a sync response.
type EventSource ¶ added in v0.3.5
type EventSource int
EventSource represents the part of the sync response that an event came from.
const ( EventSourcePresence EventSource = 1 << iota EventSourceJoin EventSourceInvite EventSourceLeave EventSourceAccountData EventSourceTimeline EventSourceState EventSourceEphemeral EventSourceToDevice )
func (EventSource) String ¶ added in v0.3.5
func (es EventSource) String() string
type ExtensibleSyncer ¶ added in v0.5.0
type ExtensibleSyncer interface { OnSync(callback SyncHandler) OnEvent(callback EventHandler) OnEventType(eventType event.Type, callback EventHandler) }
type Filter ¶
type Filter struct { AccountData FilterPart `json:"account_data,omitempty"` EventFields []string `json:"event_fields,omitempty"` EventFormat EventFormat `json:"event_format,omitempty"` Presence FilterPart `json:"presence,omitempty"` Room RoomFilter `json:"room,omitempty"` }
Filter is used by clients to specify how the server should filter responses to e.g. sync requests Specified by: https://matrix.org/docs/spec/client_server/r0.6.0.html#filtering
func DefaultFilter ¶
func DefaultFilter() Filter
DefaultFilter returns the default filter used by the Matrix server if no filter is provided in the request
type FilterPart ¶
type FilterPart struct { NotRooms []id.RoomID `json:"not_rooms,omitempty"` Rooms []id.RoomID `json:"rooms,omitempty"` Limit int `json:"limit,omitempty"` NotSenders []id.UserID `json:"not_senders,omitempty"` NotTypes []event.Type `json:"not_types,omitempty"` Senders []id.UserID `json:"senders,omitempty"` Types []event.Type `json:"types,omitempty"` ContainsURL *bool `json:"contains_url,omitempty"` LazyLoadMembers bool `json:"lazy_load_members,omitempty"` IncludeRedundantMembers bool `json:"include_redundant_members,omitempty"` }
FilterPart is used to define filtering rules for specific categories of events
func DefaultFilterPart ¶
func DefaultFilterPart() FilterPart
DefaultFilterPart returns the default filter part used by the Matrix server if no filter is provided in the request
type HTTPError ¶
type HTTPError struct { Request *http.Request Response *http.Response ResponseBody string WrappedError error RespError *RespError Message string }
HTTPError An HTTP Error response, which may wrap an underlying native Go Error.
type HomeserverInfo ¶
type HomeserverInfo struct {
BaseURL string `json:"base_url"`
}
type IdentifierType ¶ added in v0.7.1
type IdentifierType string
type IdentityServerInfo ¶
type IdentityServerInfo struct {
BaseURL string `json:"base_url"`
}
type InMemoryStore ¶
type InMemoryStore struct { Filters map[id.UserID]string NextBatch map[id.UserID]string Rooms map[id.RoomID]*Room }
InMemoryStore implements the Storer interface.
Everything is persisted in-memory as maps. It is not safe to load/save filter IDs or next batch tokens on any goroutine other than the syncing goroutine: the one which called Client.Sync().
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
NewInMemoryStore constructs a new InMemoryStore.
func (*InMemoryStore) LoadFilterID ¶
func (s *InMemoryStore) LoadFilterID(userID id.UserID) string
LoadFilterID from memory.
func (*InMemoryStore) LoadNextBatch ¶
func (s *InMemoryStore) LoadNextBatch(userID id.UserID) string
LoadNextBatch from memory.
func (*InMemoryStore) LoadRoom ¶
func (s *InMemoryStore) LoadRoom(roomID id.RoomID) *Room
LoadRoom from memory.
func (*InMemoryStore) SaveFilterID ¶
func (s *InMemoryStore) SaveFilterID(userID id.UserID, filterID string)
SaveFilterID to memory.
func (*InMemoryStore) SaveNextBatch ¶
func (s *InMemoryStore) SaveNextBatch(userID id.UserID, nextBatchToken string)
SaveNextBatch to memory.
func (*InMemoryStore) UpdateState ¶ added in v0.5.0
func (s *InMemoryStore) UpdateState(_ EventSource, evt *event.Event)
UpdateState stores a state event. This can be passed to DefaultSyncer.OnEvent to keep all room state cached.
type KeyMap ¶
type KeyMap map[id.DeviceKeyID]string
func (KeyMap) GetCurve25519 ¶
func (km KeyMap) GetCurve25519(deviceID id.DeviceID) id.Curve25519
type LazyLoadSummary ¶
type OldEventIgnorer ¶ added in v0.5.0
OldEventIgnorer is an utility struct for bots to ignore events from before the bot joined the room. Create a struct and call Register with your DefaultSyncer to register the sync handler.
func (*OldEventIgnorer) DontProcessOldEvents ¶ added in v0.5.0
func (oei *OldEventIgnorer) DontProcessOldEvents(resp *RespSync, since string) bool
DontProcessOldEvents returns true if a sync response should be processed. May modify the response to remove stuff that shouldn't be processed.
func (*OldEventIgnorer) Register ¶ added in v0.5.0
func (oei *OldEventIgnorer) Register(syncer ExtensibleSyncer)
type OneTimeKey ¶
type OneTimeKey struct { Key id.Curve25519 `json:"key"` IsSigned bool `json:"-"` Signatures Signatures `json:"signatures,omitempty"` Unsigned map[string]interface{} `json:"unsigned,omitempty"` }
func (*OneTimeKey) MarshalJSON ¶
func (otk *OneTimeKey) MarshalJSON() ([]byte, error)
func (*OneTimeKey) UnmarshalJSON ¶
func (otk *OneTimeKey) UnmarshalJSON(data []byte) (err error)
type OneTimeKeysCount ¶
type OneTimeKeysRequest ¶
type ReqAliasCreate ¶
type ReqBanUser ¶
type ReqBanUser struct { Reason string `json:"reason,omitempty"` UserID id.UserID `json:"user_id"` }
ReqBanUser is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-ban
type ReqClaimKeys ¶
type ReqClaimKeys struct { OneTimeKeys OneTimeKeysRequest `json:"one_time_keys"` Timeout int64 `json:"timeout,omitempty"` }
type ReqCreateRoom ¶
type ReqCreateRoom struct { Visibility string `json:"visibility,omitempty"` RoomAliasName string `json:"room_alias_name,omitempty"` Name string `json:"name,omitempty"` Topic string `json:"topic,omitempty"` Invite []id.UserID `json:"invite,omitempty"` Invite3PID []ReqInvite3PID `json:"invite_3pid,omitempty"` CreationContent map[string]interface{} `json:"creation_content,omitempty"` InitialState []*event.Event `json:"initial_state,omitempty"` Preset string `json:"preset,omitempty"` IsDirect bool `json:"is_direct,omitempty"` }
ReqCreateRoom is the JSON request for https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom
type ReqDeleteDevice ¶ added in v0.8.3
type ReqDeleteDevice struct {
Auth interface{} `json:"auth,omitempty"`
}
ReqDeleteDevice is the JSON request for https://matrix.org/docs/spec/client_server/r0.6.1#delete-matrix-client-r0-devices-deviceid
type ReqDeleteDevices ¶ added in v0.8.3
type ReqDeleteDevices struct { Devices []id.DeviceID `json:"devices"` Auth interface{} `json:"auth,omitempty"` }
ReqDeleteDevices is the JSON request for https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-delete-devices
type ReqDeviceInfo ¶ added in v0.8.3
type ReqDeviceInfo struct {
DisplayName string `json:"display_name,omitempty"`
}
ReqDeviceInfo is the JSON request for https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-devices-deviceid
type ReqInvite3PID ¶
type ReqInvite3PID struct { IDServer string `json:"id_server"` Medium string `json:"medium"` Address string `json:"address"` }
ReqInvite3PID is the JSON request for https://matrix.org/docs/spec/client_server/r0.2.0.html#id57 It is also a JSON object used in https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom
type ReqInviteUser ¶
ReqInviteUser is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite
type ReqKeysSignatures ¶ added in v0.8.0
type ReqKeysSignatures struct { UserID id.UserID `json:"user_id"` DeviceID id.DeviceID `json:"device_id,omitempty"` Algorithms []id.Algorithm `json:"algorithms,omitempty"` Usage []id.CrossSigningUsage `json:"usage,omitempty"` Keys map[id.KeyID]string `json:"keys"` Signatures Signatures `json:"signatures"` }
type ReqKickUser ¶
type ReqKickUser struct { Reason string `json:"reason,omitempty"` UserID id.UserID `json:"user_id"` }
ReqKickUser is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-kick
type ReqLogin ¶
type ReqLogin struct { Type AuthType `json:"type"` Identifier UserIdentifier `json:"identifier"` Password string `json:"password,omitempty"` Token string `json:"token,omitempty"` DeviceID id.DeviceID `json:"device_id,omitempty"` InitialDeviceDisplayName string `json:"initial_device_display_name,omitempty"` // Whether or not the returned credentials should be stored in the Client StoreCredentials bool `json:"-"` }
ReqLogin is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login
type ReqMembers ¶
type ReqMembers struct { At string `json:"at"` Membership event.Membership `json:"membership,omitempty"` NotMembership event.Membership `json:"not_membership,omitempty"` }
type ReqPresence ¶
type ReqPutPushRule ¶ added in v0.4.11
type ReqPutPushRule struct { Before string `json:"-"` After string `json:"-"` Actions []pushrules.PushActionType `json:"actions"` Conditions []pushrules.PushCondition `json:"conditions"` Pattern string `json:"pattern"` }
type ReqQueryKeys ¶
type ReqQueryKeys struct { DeviceKeys DeviceKeysRequest `json:"device_keys"` Timeout int64 `json:"timeout,omitempty"` Token string `json:"token,omitempty"` }
type ReqRedact ¶
ReqRedact is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid
type ReqRegister ¶
type ReqRegister struct { Username string `json:"username,omitempty"` BindEmail bool `json:"bind_email,omitempty"` Password string `json:"password,omitempty"` DeviceID id.DeviceID `json:"device_id,omitempty"` InitialDeviceDisplayName string `json:"initial_device_display_name"` Auth interface{} `json:"auth,omitempty"` }
ReqRegister is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register
type ReqSendEvent ¶
type ReqSendEvent struct { Timestamp int64 TransactionID string ParentID string RelType event.RelationType }
type ReqSendToDevice ¶
type ReqTyping ¶
ReqTyping is the JSON request for https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid
type ReqUIAuthFallback ¶ added in v0.8.0
type ReqUIAuthLogin ¶ added in v0.8.0
type ReqUIAuthLogin struct { BaseAuthData User string `json:"user"` Password string `json:"password"` }
type ReqUnbanUser ¶
ReqUnbanUser is the JSON request for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-unban
type ReqUploadKeys ¶
type ReqUploadKeys struct { DeviceKeys *DeviceKeys `json:"device_keys,omitempty"` OneTimeKeys map[id.KeyID]OneTimeKey `json:"one_time_keys"` }
type ReqUploadMedia ¶ added in v0.5.0
type ReqUploadSignatures ¶ added in v0.8.0
type ReqUploadSignatures map[id.UserID]map[string]ReqKeysSignatures
type RespAliasCreate ¶
type RespAliasCreate struct{}
type RespAliasDelete ¶
type RespAliasDelete struct{}
type RespAliasResolve ¶
type RespBanUser ¶
type RespBanUser struct{}
RespBanUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-ban
type RespClaimKeys ¶
type RespCreateFilter ¶
type RespCreateFilter struct {
FilterID string `json:"filter_id"`
}
RespCreateFilter is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-user-userid-filter
type RespCreateRoom ¶
RespCreateRoom is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.0.html#post-matrix-client-r0-createroom
type RespDeviceInfo ¶ added in v0.8.3
type RespDeviceInfo struct { DeviceID id.DeviceID `json:"device_id"` DisplayName string `json:"display_name"` LastSeenIP string `json:"last_seen_ip"` LastSeenTS int64 `json:"last_seen_ts"` }
RespDeviceInfo is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-devices-deviceid
type RespDevicesInfo ¶ added in v0.8.3
type RespDevicesInfo struct {
Devices []RespDeviceInfo `json:"devices"`
}
RespDevicesInfo is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-devices
type RespError ¶
RespError is the standard JSON error response from Homeservers. It also implements the Golang "error" interface. See http://matrix.org/docs/spec/client_server/r0.6.1.html#api-standards
func (*RespError) MarshalJSON ¶ added in v0.7.7
func (*RespError) UnmarshalJSON ¶ added in v0.7.7
type RespForgetRoom ¶
type RespForgetRoom struct{}
RespForgetRoom is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-forget
type RespInviteUser ¶
type RespInviteUser struct{}
RespInviteUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite
type RespJoinRoom ¶
RespJoinRoom is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-join
type RespJoinedMembers ¶
type RespJoinedMembers struct { Joined map[id.UserID]struct { DisplayName *string `json:"display_name"` AvatarURL *string `json:"avatar_url"` } `json:"joined"` }
RespJoinedMembers is the JSON response for https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-joined-rooms
type RespJoinedRooms ¶
RespJoinedRooms is the JSON response for https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-joined-rooms
type RespKeyChanges ¶
type RespKickUser ¶
type RespKickUser struct{}
RespKickUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-kick
type RespLeaveRoom ¶
type RespLeaveRoom struct{}
RespLeaveRoom is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-leave
type RespLogin ¶
type RespLogin struct { AccessToken string `json:"access_token"` DeviceID id.DeviceID `json:"device_id"` UserID id.UserID `json:"user_id"` }
RespLogin is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login
type RespLoginFlows ¶
type RespLoginFlows struct { Flows []struct { Type AuthType `json:"type"` } `json:"flows"` }
func (*RespLoginFlows) HasFlow ¶ added in v0.7.13
func (rlf *RespLoginFlows) HasFlow(flowType AuthType) bool
type RespLogout ¶
type RespLogout struct{}
RespLogout is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-logout
type RespMediaUpload ¶
type RespMediaUpload struct {
ContentURI id.ContentURI `json:"content_uri"`
}
RespMediaUpload is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-media-r0-upload
type RespMembers ¶
type RespMessages ¶
type RespMessages struct { Start string `json:"start"` Chunk []*event.Event `json:"chunk"` State []*event.Event `json:"state"` End string `json:"end"` }
RespMessages is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-messages
type RespQueryKeys ¶
type RespQueryKeys struct { Failures map[string]interface{} `json:"failures"` DeviceKeys map[id.UserID]map[id.DeviceID]DeviceKeys `json:"device_keys"` MasterKeys map[id.UserID]CrossSigningKeys `json:"master_keys"` SelfSigningKeys map[id.UserID]CrossSigningKeys `json:"self_signing_keys"` UserSigningKeys map[id.UserID]CrossSigningKeys `json:"user_signing_keys"` }
type RespRegister ¶
type RespRegister struct { AccessToken string `json:"access_token"` DeviceID id.DeviceID `json:"device_id"` HomeServer string `json:"home_server"` RefreshToken string `json:"refresh_token"` UserID id.UserID `json:"user_id"` }
RespRegister is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register
type RespSendEvent ¶
RespSendEvent is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid
type RespSendToDevice ¶
type RespSendToDevice struct{}
type RespSync ¶
type RespSync struct { NextBatch string `json:"next_batch"` AccountData struct { Events []*event.Event `json:"events"` } `json:"account_data"` Presence struct { Events []*event.Event `json:"events"` } `json:"presence"` ToDevice struct { Events []*event.Event `json:"events"` } `json:"to_device"` DeviceLists struct { Changed []id.UserID `json:"changed"` Left []id.UserID `json:"left"` } `json:"device_lists"` DeviceOneTimeKeysCount OneTimeKeysCount `json:"device_one_time_keys_count"` Rooms struct { Leave map[id.RoomID]SyncLeftRoom `json:"leave"` Join map[id.RoomID]SyncJoinedRoom `json:"join"` Invite map[id.RoomID]SyncInvitedRoom `json:"invite"` } `json:"rooms"` }
RespSync is the JSON response for http://matrix.org/docs/spec/client_server/r0.6.0.html#get-matrix-client-r0-sync
type RespTurnServer ¶
type RespTyping ¶
type RespTyping struct{}
RespTyping is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid
type RespUnbanUser ¶
type RespUnbanUser struct{}
RespUnbanUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-unban
type RespUploadKeys ¶
type RespUploadKeys struct {
OneTimeKeyCounts OneTimeKeysCount `json:"one_time_key_counts"`
}
type RespUploadSignatures ¶ added in v0.8.0
type RespUploadSignatures struct {
Failures map[string]interface{} `json:"failures"`
}
type RespUserDisplayName ¶
type RespUserDisplayName struct {
DisplayName string `json:"displayname"`
}
RespUserDisplayName is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-displayname
type RespUserInteractive ¶
type RespUserInteractive struct { Flows []struct { Stages []AuthType `json:"stages"` } `json:"flows"` Params map[AuthType]interface{} `json:"params"` Session string `json:"session"` Completed []string `json:"completed"` ErrCode string `json:"errcode"` Error string `json:"error"` }
RespUserInteractive is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#user-interactive-authentication-api
func (RespUserInteractive) HasSingleStageFlow ¶
func (r RespUserInteractive) HasSingleStageFlow(stageName AuthType) bool
HasSingleStageFlow returns true if there exists at least 1 Flow with a single stage of stageName.
type RespVersions ¶
type RespVersions struct { Versions []string `json:"versions"` UnstableFeatures map[string]bool `json:"unstable_features"` }
RespVersions is the JSON response for http://matrix.org/docs/spec/client_server/r0.6.1.html#get-matrix-client-versions
type RespWhoami ¶ added in v0.3.6
type RespWhoami struct { UserID id.UserID `json:"user_id"` // N.B. This field is not in the spec yet, it's expected to land in r0.6.2 or r0.7.0 DeviceID id.DeviceID `json:"device_id"` }
RespWhoami is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-account-whoami
type Room ¶
Room represents a single Matrix room.
func (Room) GetMembershipState ¶
func (room Room) GetMembershipState(userID id.UserID) event.Membership
GetMembershipState returns the membership state of the given user ID in this room. If there is no entry for this member, 'leave' is returned for consistency with left users.
func (Room) GetStateEvent ¶
GetStateEvent returns the state event for the given type/state_key combo, or nil.
func (Room) UpdateState ¶
UpdateState updates the room's current state with the given Event. This will clobber events based on the type/state_key combination.
type RoomFilter ¶
type RoomFilter struct { AccountData FilterPart `json:"account_data,omitempty"` Ephemeral FilterPart `json:"ephemeral,omitempty"` IncludeLeave bool `json:"include_leave,omitempty"` NotRooms []id.RoomID `json:"not_rooms,omitempty"` Rooms []id.RoomID `json:"rooms,omitempty"` State FilterPart `json:"state,omitempty"` Timeline FilterPart `json:"timeline,omitempty"` }
RoomFilter is used to define filtering rules for room events
type Storer ¶
type Storer interface { SaveFilterID(userID id.UserID, filterID string) LoadFilterID(userID id.UserID) string SaveNextBatch(userID id.UserID, nextBatchToken string) LoadNextBatch(userID id.UserID) string SaveRoom(room *Room) LoadRoom(roomID id.RoomID) *Room }
Storer is an interface which must be satisfied to store client data.
You can either write a struct which persists this data to disk, or you can use the provided "InMemoryStore" which just keeps data around in-memory which is lost on restarts.
type Stringifiable ¶
type Stringifiable interface {
String() string
}
type SyncHandler ¶ added in v0.5.0
SyncHandler handles a whole sync response. If the return value is false, handling will be stopped completely.
type SyncInvitedRoom ¶
type SyncInvitedRoom struct { Summary LazyLoadSummary `json:"summary"` State struct { Events []*event.Event `json:"events"` } `json:"invite_state"` }
type SyncJoinedRoom ¶
type SyncJoinedRoom struct { Summary LazyLoadSummary `json:"summary"` State struct { Events []*event.Event `json:"events"` } `json:"state"` Timeline struct { Events []*event.Event `json:"events"` Limited bool `json:"limited"` PrevBatch string `json:"prev_batch"` } `json:"timeline"` Ephemeral struct { Events []*event.Event `json:"events"` } `json:"ephemeral"` AccountData struct { Events []*event.Event `json:"events"` } `json:"account_data"` }
type SyncLeftRoom ¶
type Syncer ¶
type Syncer interface { // Process the /sync response. The since parameter is the since= value that was used to produce the response. // This is useful for detecting the very first sync (since=""). If an error is return, Syncing will be stopped // permanently. ProcessResponse(resp *RespSync, since string) error // OnFailedSync returns either the time to wait before retrying or an error to stop syncing permanently. OnFailedSync(res *RespSync, err error) (time.Duration, error) // GetFilterJSON for the given user ID. NOT the filter ID. GetFilterJSON(userID id.UserID) *Filter }
Syncer is an interface that must be satisfied in order to do /sync requests on a client.
type UIACallback ¶ added in v0.8.0
type UIACallback = func(*RespUserInteractive) interface{}
type UploadCrossSigningKeysReq ¶ added in v0.8.0
type UploadCrossSigningKeysReq struct { Master CrossSigningKeys `json:"master_key"` SelfSigning CrossSigningKeys `json:"self_signing_key"` UserSigning CrossSigningKeys `json:"user_signing_key"` Auth interface{} `json:"auth,omitempty"` }
type UserIdentifier ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package format contains utilities for working with Matrix HTML, specifically methods to parse Markdown into HTML and to parse Matrix HTML into text or markdown.
|
Package format contains utilities for working with Matrix HTML, specifically methods to parse Markdown into HTML and to parse Matrix HTML into text or markdown. |
Package pushrules contains utilities to parse push notification rules.
|
Package pushrules contains utilities to parse push notification rules. |
glob
Package glob provides objects for matching strings with globs
|
Package glob provides objects for matching strings with globs |