Documentation
¶
Overview ¶
Package gomatrix implements the Matrix Client-Server API.
Specification can be found at https://spec.matrix.org/v1.1/client-server-api/
Index ¶
- func DecodeUserLocalpart(str string) (string, error)
- func EncodeUserLocalpart(str string) string
- func ExtractUserLocalpart(userID string) (string, error)
- func HandleRetry(res *http.Response, duration time.Duration) (time.Duration, error)
- type AudioInfo
- type AudioMessage
- type Client
- func (cli *Client) BanUser(roomID string, req *ReqBanUser) (resp *RespBanUser, err error)
- func (cli *Client) BuildBaseURL(urlPath ...string) string
- func (cli *Client) BuildURL(urlPath ...string) string
- func (cli *Client) BuildURLWithQuery(urlPath []string, urlQuery map[string]string) string
- func (cli *Client) ClearCredentials()
- func (cli *Client) CreateFilter(filter json.RawMessage) (resp *RespCreateFilter, err error)
- func (cli *Client) CreateRoom(req *ReqCreateRoom) (resp *RespCreateRoom, err error)
- func (cli *Client) ForgetRoom(roomID string) (resp *RespForgetRoom, err error)
- func (cli *Client) GetEventByID(eventID, roomID string) (resp *Event, err error)
- func (cli *Client) GetFilter(filterID string) (resp *Filter, err error)
- func (cli *Client) GetMembers(at, membership, notMembership, roomID string) (resp *RespJoinedMembers, err error)
- func (cli *Client) GetRoomDir(roomID string) (resp *RespGetRoomDir, err error)
- func (cli *Client) GetStateEvents(roomID string) (resp *Event, err error)
- func (cli *Client) InviteUserByThirdParty(roomID string, req *ReqInvite3PID) (resp *RespInviteUser, err error)
- func (cli *Client) JoinRoom(roomID, serverName string, content interface{}) (resp *RespJoinRoom, err error)
- func (cli *Client) JoinRoomIDOrAlias(roomIDorAlias, serverName string, content interface{}) (resp *RespJoinRoom, err error)
- func (cli *Client) JoinedMembers(roomID string) (resp *RespJoinedMembers, err error)
- func (cli *Client) JoinedRooms() (resp *RespJoinedRooms, err error)
- func (cli *Client) KickUser(roomID string, req *ReqKickUser) (resp *RespKickUser, err error)
- func (cli *Client) KnockRoom(roomIDorAlias, serverName string, req *ReqKnockRoom) (resp *RespKnockRoom, err error)
- func (cli *Client) LeaveRoom(roomID string, req *ReqLeaveRoom) (resp *RespLeaveRoom, err error)
- func (cli *Client) Login(req *ReqLogin) (resp *RespLogin, err error)
- func (cli *Client) MakeRequest(method string, httpURL string, reqBody interface{}, resBody interface{}) error
- func (cli *Client) Messages(roomID, filter, from, to string, dir rune, limit int) (resp *RespMessages, err error)
- func (cli *Client) PowerLevels(roomID string) (resp *RespPowerLevels, err error)
- func (cli *Client) RedactEvent(roomID, eventID string, req *ReqRedact) (resp *RespSendEvent, err error)
- func (cli *Client) Register(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
- func (cli *Client) SearchUsers(req *ReqSearchUsers) (resp *RespSearchUsers, err error)
- func (cli *Client) SendFormattedText(roomID, text, formattedText string) (*RespSendEvent, error)
- func (cli *Client) SendMessageEvent(roomID, eventType string, contentJSON interface{}) (resp *RespSendEvent, err error)
- func (cli *Client) SendNotice(roomID, text string) (*RespSendEvent, error)
- func (cli *Client) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error)
- func (cli *Client) SendSticker(roomID, body, url string) (*RespSendEvent, error)
- func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error)
- func (cli *Client) SetCredentials(userID, accessToken string)
- func (cli *Client) SetRoomDir(roomID string, req *ReqSetRoomDir) (resp *RespSetRoomDir, err error)
- func (cli *Client) StateEvent(roomID, eventType, stateKey string, outContent interface{}) (err error)
- func (cli *Client) StopSync()
- func (cli *Client) Sync() error
- func (cli *Client) SyncRequest(timeout int, since, filterID string, fullState bool, setPresence string) (resp *RespSync, err error)
- func (cli *Client) UnbanUser(roomID string, req *ReqUnbanUser) (resp *RespUnbanUser, err error)
- func (cli *Client) UploadLink(link string) (*RespMediaUpload, error)
- func (cli *Client) UploadToContentRepo(content io.Reader, contentType string, contentLength int64) (*RespMediaUpload, error)
- type DefaultSyncer
- func (s *DefaultSyncer) GetFilterJSON(userID string) json.RawMessage
- func (s *DefaultSyncer) OnEventType(eventType string, callback OnEventListener)
- func (s *DefaultSyncer) OnFailedSync(res *RespSync, err error) (time.Duration, error)
- func (s *DefaultSyncer) ProcessResponse(res *RespSync, since string) (err error)
- type DiscoveryInformation
- type Event
- type FileInfo
- type FileMessage
- type Filter
- type FilterPart
- type HTMLMessage
- type HTTPError
- type Identifier
- type ImageInfo
- type ImageMessage
- type InMemoryStore
- func (s *InMemoryStore) LoadFilterID(userID string) string
- func (s *InMemoryStore) LoadNextBatch(userID string) string
- func (s *InMemoryStore) LoadRoom(roomID string) *Room
- func (s *InMemoryStore) SaveFilterID(userID, filterID string)
- func (s *InMemoryStore) SaveNextBatch(userID, nextBatchToken string)
- func (s *InMemoryStore) SaveRoom(room *Room)
- type Join
- type LocationMessage
- type OnEventListener
- type PhoneIdentifier
- type PublicRoom
- type ReqBanUser
- type ReqCreateRoom
- type ReqInvite3PID
- type ReqInviteUser
- type ReqKickUser
- type ReqKnockRoom
- type ReqLeaveRoom
- type ReqLogin
- type ReqPublicRoomsFiltered
- type ReqRedact
- type ReqRegister
- type ReqSearchUsers
- type ReqSetProfile
- type ReqSetRoomDir
- type ReqTyping
- type ReqUnbanUser
- type RespBanUser
- type RespCreateFilter
- type RespCreateRoom
- type RespError
- type RespForgetRoom
- type RespGetRoomDir
- type RespInviteUser
- type RespJoinRoom
- type RespJoinedMembers
- type RespJoinedRooms
- type RespKickUser
- type RespKnockRoom
- type RespLeaveRoom
- type RespLogin
- type RespMediaUpload
- type RespMessages
- type RespPowerLevels
- type RespPublicRooms
- type RespRegister
- type RespResolveRoomAlias
- type RespSearchUsers
- type RespSendEvent
- type RespServerCapabilities
- type RespSetRoomDir
- type RespSync
- type RespUnbanUser
- type RespUserInteractive
- type Room
- type RoomFilter
- type Storer
- type Syncer
- type TagContent
- type TagProperties
- type TextMessage
- type ThirdpartyIdentifier
- type ThumbnailInfo
- type Timeline
- type UserIdentifier
- type VideoInfo
- type VideoMessage
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeUserLocalpart ¶
DecodeUserLocalpart decodes the given string back into the original input string. Returns an error if the given string is not a valid user ID localpart encoding. See http://matrix.org/docs/spec/intro.html#mapping-from-other-character-sets
This decodes quoted-printable bytes back into UTF8, and unescapes casing. For example:
_alph=40_bet=5f50up => Alph@Bet_50up
Returns an error if the input string contains characters outside the range "a-z0-9._=-", has an invalid quote-printable byte (e.g. not hex), or has an invalid _ escaped byte (e.g. "_5").
Example ¶
localpart, err := DecodeUserLocalpart("_alph=40_bet__50up") if err != nil { panic(err) } fmt.Println(localpart)
Output: Alph@Bet_50up
func EncodeUserLocalpart ¶
EncodeUserLocalpart encodes the given string into Matrix-compliant user ID localpart form. See http://matrix.org/docs/spec/intro.html#mapping-from-other-character-sets
This returns a string with only the characters "a-z0-9._=-". The uppercase range A-Z are encoded using leading underscores ("_"). Characters outside the aforementioned ranges (including literal underscores ("_") and equals ("=")) are encoded as UTF8 code points (NOT NCRs) and converted to lower-case hex with a leading "=". For example:
Alph@Bet_50up => _alph=40_bet=5f50up
Example ¶
localpart := EncodeUserLocalpart("Alph@Bet_50up") fmt.Println(localpart)
Output: _alph=40_bet__50up
func ExtractUserLocalpart ¶
ExtractUserLocalpart extracts the localpart portion of a user ID. See http://matrix.org/docs/spec/intro.html#user-identifiers
Example ¶
localpart, err := ExtractUserLocalpart("@alice:matrix.org") if err != nil { panic(err) } fmt.Println(localpart)
Output: alice
Types ¶
type AudioInfo ¶
type AudioInfo struct { Mimetype string `json:"mimetype,omitempty"` Size uint `json:"size,omitempty"` //filesize in bytes Duration uint `json:"duration,omitempty"` //audio duration in ms }
AudioInfo contains info about an file - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-audio
type AudioMessage ¶
type AudioMessage struct { MsgType string `json:"msgtype"` Body string `json:"body"` URL string `json:"url"` Info AudioInfo `json:"info,omitempty"` }
AudioMessage is an m.audio event - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-audio
type Client ¶
type Client struct { HomeserverURL *url.URL // The base homeserver URL Prefix string // The API prefix eg '/_matrix/client/v3' UserID string // The user ID of the client. Used for forming HTTP paths which use the client's user ID. AccessToken string // The access_token for the client. 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 // 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 string // contains filtered or unexported fields }
Client represents a Matrix client.
func (*Client) BanUser ¶
func (cli *Client) BanUser(roomID string, req *ReqBanUser) (resp *RespBanUser, err error)
BanUser bans a user from a room. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidkick
func (*Client) BuildBaseURL ¶
BuildBaseURL builds a URL with the Client's homeserver set already. You must supply the prefix in the path.
func (*Client) BuildURLWithQuery ¶
BuildURLWithQuery builds a URL with query parameters in addition to the Client's homeserver/prefix set already.
func (*Client) ClearCredentials ¶
func (cli *Client) ClearCredentials()
ClearCredentials removes the user ID and access token on this client instance.
func (*Client) CreateFilter ¶
func (cli *Client) CreateFilter(filter json.RawMessage) (resp *RespCreateFilter, err error)
CreateFilter makes an HTTP request according to https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3useruseridfilter
func (*Client) CreateRoom ¶
func (cli *Client) CreateRoom(req *ReqCreateRoom) (resp *RespCreateRoom, err error)
CreateRoom creates a new Matrix room. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3createroom
resp, err := cli.CreateRoom(&gomatrix.ReqCreateRoom{ Preset: "public_chat", }) fmt.Println("Room:", resp.RoomID)
func (*Client) ForgetRoom ¶
func (cli *Client) ForgetRoom(roomID string) (resp *RespForgetRoom, err error)
ForgetRoom forgets a room entirely. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidforget
func (*Client) GetEventByID ¶
GetEventByID returns a single event based on roomId/eventId. See https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomideventeventid
func (*Client) GetFilter ¶
GetFilter makes an HTTP request according to https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3useruseridfilterfilterid
func (*Client) GetMembers ¶
func (cli *Client) GetMembers(at, membership, notMembership, roomID string) (resp *RespJoinedMembers, err error)
GetMembers returns the list of members for a room. See https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidmembers
func (*Client) GetRoomDir ¶
func (cli *Client) GetRoomDir(roomID string) (resp *RespGetRoomDir, err error)
GetRoomDir gets the visibility of a given room on the server’s public room directory. See https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3directorylistroomroomid
func (*Client) GetStateEvents ¶
GetStateEvent returns the state events for the current state of the room. See https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidstate
func (*Client) InviteUserByThirdParty ¶
func (cli *Client) InviteUserByThirdParty(roomID string, 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(roomID, serverName string, content interface{}) (resp *RespJoinRoom, err error)
JoinRoom joins the client to a room ID. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidjoin
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) JoinRoomIDOrAlias ¶
func (cli *Client) JoinRoomIDOrAlias(roomIDorAlias, serverName string, content interface{}) (resp *RespJoinRoom, err error)
JoinRoomIDOrAlias joins the client to a room ID or alias. See http://matrix.org/docs/spec/client_server/r0.2.0.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) JoinedMembers ¶
func (cli *Client) JoinedMembers(roomID string) (resp *RespJoinedMembers, err error)
JoinedMembers returns a map of joined room members. See https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidjoined_members
This API is primarily for Application Services and should be faster to respond than /members as it can be implemented more efficiently on the server.
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://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3joined_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 string, req *ReqKickUser) (resp *RespKickUser, err error)
KickUser kicks a user from a room. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidkick
func (*Client) KnockRoom ¶
func (cli *Client) KnockRoom(roomIDorAlias, serverName string, req *ReqKnockRoom) (resp *RespKnockRoom, err error)
KnockRoom “knocks” on the room to ask for permission to join. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3knockroomidoralias
func (*Client) LeaveRoom ¶
func (cli *Client) LeaveRoom(roomID string, req *ReqLeaveRoom) (resp *RespLeaveRoom, err error)
LeaveRoom leaves the given room. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidleave
func (*Client) Login ¶
Login a user to the homeserver according to https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3login This does not set credentials on this client instance. See SetCredentials() instead.
func (*Client) MakeRequest ¶
func (cli *Client) MakeRequest(method string, httpURL string, reqBody interface{}, resBody interface{}) error
MakeRequest makes a JSON HTTP request to the given URL. The response body will be stream decoded into an interface. This will automatically stop if the response body is nil.
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, byte contents of the response body and possibly a RespError as the WrappedError, if the HTTP body could be decoded as a RespError.
func (*Client) Messages ¶
func (cli *Client) Messages(roomID, filter, 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://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidmessages
func (*Client) PowerLevels ¶
func (cli *Client) PowerLevels(roomID string) (resp *RespPowerLevels, err error)
PowerLevels returns the power levels content for the current state of the room. See https://spec.matrix.org/v1.1/client-server-api/#mroompower_levels
func (*Client) RedactEvent ¶
func (cli *Client) RedactEvent(roomID, eventID string, req *ReqRedact) (resp *RespSendEvent, err error)
RedactEvent redacts the given event. See https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3roomsroomidredacteventidtxnid
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) SearchUsers ¶
func (cli *Client) SearchUsers(req *ReqSearchUsers) (resp *RespSearchUsers, err error)
SearchUsers performs a search for users on the homeserver. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3user_directorysearch
func (*Client) SendFormattedText ¶
func (cli *Client) SendFormattedText(roomID, text, formattedText string) (*RespSendEvent, error)
SendFormattedText sends an m.room.message event into the given room with a msgtype of m.text, supports a subset of HTML for formatting. See https://matrix.org/docs/spec/client_server/r0.6.0#m-text
func (*Client) SendMessageEvent ¶
func (cli *Client) SendMessageEvent(roomID, eventType string, contentJSON interface{}) (resp *RespSendEvent, err error)
SendMessageEvent sends a message event into a room. See https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
func (*Client) SendNotice ¶
func (cli *Client) SendNotice(roomID, text string) (*RespSendEvent, error)
SendNotice sends an m.room.message event into the given room with a msgtype of m.notice See https://spec.matrix.org/v1.1/client-server-api/#mnotice
func (*Client) SendStateEvent ¶
func (cli *Client) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error)
SendStateEvent sends a state event into a room. See https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3roomsroomidstateeventtypestatekey contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
func (*Client) SendSticker ¶
func (cli *Client) SendSticker(roomID, body, url string) (*RespSendEvent, error)
SendSticker sends an m.room.message event into the given room with a msgtype of m.sticker See https://spec.matrix.org/latest/client-server-api/#msticker
func (*Client) SendText ¶
func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error)
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) SetCredentials ¶
SetCredentials sets the user ID and access token on this client instance.
func (*Client) SetRoomDir ¶
func (cli *Client) SetRoomDir(roomID string, req *ReqSetRoomDir) (resp *RespSetRoomDir, err error)
SetRoomDir gets the visibility of a given room on the server’s public room directory. See https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3directorylistroomroomid
func (*Client) StateEvent ¶
func (cli *Client) StateEvent(roomID, eventType, 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 https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidstateeventtypestatekey
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 string) (resp *RespSync, err error)
SyncRequest makes an HTTP request according to https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3sync
func (*Client) UnbanUser ¶
func (cli *Client) UnbanUser(roomID string, req *ReqUnbanUser) (resp *RespUnbanUser, err error)
UnbanUser unbans a user from a room. See https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidunban
func (*Client) UploadLink ¶
func (cli *Client) UploadLink(link string) (*RespMediaUpload, error)
UploadLink uploads an HTTP URL and then returns an MXC URI.
func (*Client) UploadToContentRepo ¶
func (cli *Client) UploadToContentRepo(content io.Reader, contentType string, contentLength int64) (*RespMediaUpload, error)
UploadToContentRepo uploads the given bytes 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
type DefaultSyncer ¶
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(userID string, store Storer) *DefaultSyncer
NewDefaultSyncer returns an instantiated DefaultSyncer
func (*DefaultSyncer) GetFilterJSON ¶
func (s *DefaultSyncer) GetFilterJSON(userID string) json.RawMessage
GetFilterJSON returns a filter with a timeline limit of 50.
func (*DefaultSyncer) OnEventType ¶
func (s *DefaultSyncer) OnEventType(eventType string, callback OnEventListener)
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) 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 DiscoveryInformation ¶
type DiscoveryInformation struct { Homeserver struct { BaseURL string `json:"base_url"` } `json:"m.homeserver"` IdentityServer struct { BaseURL string `json:"base_url"` } `json:"m.identitiy_server"` }
DiscoveryInformation is the JSON Response for https://spec.matrix.org/latest/client-server-api/#getwell-knownmatrixclient and a part of the JSON Response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3login
type Event ¶
type Event struct { // The basic set of fields all events must have. Content map[string]interface{} `json:"content"` // The JSON content of the event. Type string `json:"type"` // The event type // Room Events have the following fields ID string `json:"event_id"` // The unique ID of this event RoomID string `json:"room_id"` // The room the event was sent to. May be nil (e.g. for presence) Sender string `json:"sender"` // The user ID of the sender of the event Timestamp int64 `json:"origin_server_ts"` // The unix timestamp when this message was sent by the origin server Unsigned map[string]interface{} `json:"unsigned"` // The unsigned portions of the event, such as age and prev_content // In addition to the fields of a Room Event, State Events have the following fields. PrevContent map[string]interface{} `json:"prev_content,omitempty"` // The JSON prev_content of the event. StateKey *string `json:"state_key,omitempty"` // The state key for the event. Only present on State Events. // Strictly for m.room.redaction events Redacts string `json:"redacts,omitempty"` // The event ID that was redacted if a m.room.redaction event }
Event represents a single Matrix event.
func (*Event) Body ¶
Body returns the value of the "body" key in the event content if it is present and is a string.
func (*Event) MessageType ¶
MessageType returns the value of the "msgtype" key in the event content if it is present and is a string.
type FileInfo ¶
type FileInfo struct { Mimetype string `json:"mimetype,omitempty"` Size uint `json:"size,omitempty"` //filesize in bytes }
FileInfo contains info about an file - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-file
type FileMessage ¶
type FileMessage struct { MsgType string `json:"msgtype"` Body string `json:"body"` URL string `json:"url"` Filename string `json:"filename"` Info FileInfo `json:"info,omitempty"` ThumbnailURL string `json:"thumbnail_url,omitempty"` ThumbnailInfo ImageInfo `json:"thumbnail_info,omitempty"` }
FileMessage is an m.file event - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-file
type Filter ¶
type Filter struct { AccountData FilterPart `json:"account_data,omitempty"` EventFields []string `json:"event_fields,omitempty"` EventFormat string `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://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3useruseridfilter
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 { Limit int `json:"limit,omitempty"` NotSenders []string `json:"not_senders,omitempty"` NotTypes []string `json:"not_types,omitempty"` Senders []string `json:"senders,omitempty"` Types []string `json:"types,omitempty"` ContainsURL *bool `json:"contains_url,omitempty"` IncludeRedundantMembers bool `json:"include_redundant_members,omitempty"` LazyLoadMembers bool `json:"lazy_load_members,omitempty"` NotRooms []string `json:"not_rooms,omitempty"` Rooms []string `json:"rooms,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 HTMLMessage ¶
type HTMLMessage struct { Body string `json:"body"` MsgType string `json:"msgtype"` Format string `json:"format"` FormattedBody string `json:"formatted_body"` }
An HTMLMessage is the contents of a Matrix HTML formated message event.
func GetHTMLMessage ¶
func GetHTMLMessage(msgtype, htmlText string) HTMLMessage
GetHTMLMessage returns an HTMLMessage with the body set to a stripped version of the provided HTML, in addition to the provided HTML.
type Identifier ¶
type Identifier interface { // Returns the identifier type // https://matrix.org/docs/spec/client_server/r0.6.0#identifier-types Type() string }
Identifier is the interface for https://matrix.org/docs/spec/client_server/r0.6.0#identifier-types
type ImageInfo ¶
type ImageInfo struct { Height uint `json:"h,omitempty"` Width uint `json:"w,omitempty"` Mimetype string `json:"mimetype,omitempty"` Size uint `json:"size,omitempty"` ThumbnailInfo ThumbnailInfo `json:"thumbnail_info,omitempty"` ThumbnailURL string `json:"thumbnail_url,omitempty"` }
ImageInfo contains info about an image - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
type ImageMessage ¶
type ImageMessage struct { MsgType string `json:"msgtype"` Body string `json:"body"` URL string `json:"url"` Info ImageInfo `json:"info"` }
ImageMessage is an m.image event
type InMemoryStore ¶
type InMemoryStore struct { Filters map[string]string NextBatch map[string]string Rooms map[string]*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 string) string
LoadFilterID from memory.
func (*InMemoryStore) LoadNextBatch ¶
func (s *InMemoryStore) LoadNextBatch(userID string) string
LoadNextBatch from memory.
func (*InMemoryStore) LoadRoom ¶
func (s *InMemoryStore) LoadRoom(roomID string) *Room
LoadRoom from memory.
func (*InMemoryStore) SaveFilterID ¶
func (s *InMemoryStore) SaveFilterID(userID, filterID string)
SaveFilterID to memory.
func (*InMemoryStore) SaveNextBatch ¶
func (s *InMemoryStore) SaveNextBatch(userID, nextBatchToken string)
SaveNextBatch to memory.
type Join ¶
type Join struct { AccountData struct { Events []Event `json:"events"` } `json:"account_data"` Ephemeral struct { Events []Event `json:"events"` } `json:"ephemeral"` State struct { Events []Event `json:"events"` } `json:"state"` Summary struct { Heros []string `json:"m.heros,omitempty"` InvitedMemberCount int `json:"m.invited_member_count,omitempty"` JoinedMemberCount int `json:"m.joined_member_count,omitempty"` } `json:"summary"` Timeline Timeline `json:"timeline"` UnreadNotifications struct { HighLightCount int `json:"highlight_count"` NotificationCount int `json:"notification_count"` } `json:"unread_notifications"` }
The join object
type LocationMessage ¶
type LocationMessage struct { MsgType string `json:"msgtype"` Body string `json:"body"` GeoURI string `json:"geo_uri"` ThumbnailURL string `json:"thumbnail_url,omitempty"` ThumbnailInfo ImageInfo `json:"thumbnail_info,omitempty"` }
LocationMessage is an m.location event - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-location
type OnEventListener ¶
type OnEventListener func(*Event)
OnEventListener can be used with DefaultSyncer.OnEventType to be informed of incoming events.
type PhoneIdentifier ¶
type PhoneIdentifier struct { IDType string `json:"type"` // Set by NewPhoneIdentifier Country string `json:"country"` Phone string `json:"phone"` }
PhoneIdentifier is the Identifier for https://matrix.org/docs/spec/client_server/r0.6.0#phone-number
func NewPhoneIdentifier ¶
func NewPhoneIdentifier(country, phone string) PhoneIdentifier
NewPhoneIdentifier creates a new UserIdentifier with IDType set to "m.id.user"
func (PhoneIdentifier) Type ¶
func (i PhoneIdentifier) Type() string
Type implements the Identifier interface
type PublicRoom ¶
type PublicRoom struct { Aliases []string `json:"aliases,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` CanonicalAlias string `json:"canonical_alias,omitempty"` GuestCanJoin bool `json:"guest_can_join"` JoinRule string `json:"join_rule,omitempty"` Name string `json:"name,omitempty"` NumJoinedMembers int `json:"num_joined_members"` RoomID string `json:"room_id"` Topic string `json:"topic,omitempty"` WorldReadable bool `json:"world_readable"` }
PublicRoom represents the information about a public room obtainable from the room directory
type ReqBanUser ¶
ReqBanUser is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidban
type ReqCreateRoom ¶
type ReqCreateRoom struct { CreationContent map[string]interface{} `json:"creation_content,omitempty"` InitialState []Event `json:"initial_state,omitempty"` Invite []string `json:"invite,omitempty"` Invite3PID []ReqInvite3PID `json:"invite_3pid,omitempty"` IsDirect bool `json:"is_direct,omitempty"` Name string `json:"name,omitempty"` PowerLevelContent []Event `json:"power_level_content_override,omitempty"` Preset string `json:"preset,omitempty"` RoomAliasName string `json:"room_alias_name,omitempty"` RoomVersion string `json:"room_version"` Topic string `json:"topic,omitempty"` Visibility string `json:"visibility,omitempty"` }
ReqCreateRoom is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3createroom
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 ¶
type ReqInviteUser struct { Reason string `json:"reason,omitempty"` UserID string `json:"user_id"` }
ReqInviteUser is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidinvite
type ReqKickUser ¶
ReqKickUser is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidkick
type ReqKnockRoom ¶
type ReqKnockRoom struct {
Reason string `json:"reason,omitempty"`
}
ReqKnockRoom is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3knockroomidoralias
type ReqLeaveRoom ¶
type ReqLeaveRoom struct {
Reason string `json:"reason,omitempty"`
}
ReqKnockRoom is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidleave
type ReqLogin ¶
type ReqLogin struct { DeviceID string `json:"device_id,omitempty"` Identifier Identifier `json:"identifier,omitempty"` InitialDeviceDisplayName string `json:"initial_device_display_name,omitempty"` Password string `json:"password,omitempty"` Token string `json:"token,omitempty"` Type string `json:"type"` }
ReqLogin is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3login
type ReqPublicRoomsFiltered ¶
type ReqPublicRoomsFiltered struct { Filter struct { GenericSearchTerm string `json:"generic_search_term"` } `json:"filter,omitempty"` IncludeAllNetworks bool `json:"include_all_networks,omitempty"` Limit int `json:"limit,omitempty"` Since string `json:"since,omitempty"` ThirdPartyInstanceID string `json:"third_party_instance_id"` }
ReqPublicRoomsFiltered is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3publicrooms
type ReqRedact ¶
type ReqRedact struct {
Reason string `json:"reason,omitempty"`
}
ReqRedact is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3roomsroomidredacteventidtxnid
type ReqRegister ¶
type ReqRegister struct { Username string `json:"username,omitempty"` BindEmail bool `json:"bind_email,omitempty"` Password string `json:"password,omitempty"` DeviceID string `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 ReqSearchUsers ¶
type ReqSetProfile ¶
type ReqSetProfile struct {
AvatarUrl string `json:"avatar_url"`
}
type ReqSetRoomDir ¶
type ReqSetRoomDir struct {
Visibility string `json:"visibility"`
}
ReqSetRoomDir is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3directorylistroomroomid
type ReqTyping ¶
ReqTyping is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3roomsroomidtypinguserid
type ReqUnbanUser ¶
ReqUnbanUser is the JSON request for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidunban
type RespBanUser ¶
type RespBanUser struct{}
RespBanUser is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidban
type RespCreateFilter ¶
type RespCreateFilter struct {
FilterID string `json:"filter_id"`
}
RespCreateFilter is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3useruseridfilter
type RespCreateRoom ¶
type RespCreateRoom struct {
RoomID string `json:"room_id"`
}
RespCreateRoom is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom
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.2.0.html#api-standards
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 RespGetRoomDir ¶
type RespGetRoomDir struct {
Visibility string `json:"visibility"`
}
RespGetRoomDir is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3directorylistroomroomid
type RespInviteUser ¶
type RespInviteUser struct{}
RespInviteUser is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidinvite
type RespJoinRoom ¶
type RespJoinRoom struct {
RoomID string `json:"room_id"`
}
RespJoinRoom is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidjoin
type RespJoinedMembers ¶
type RespJoinedMembers struct { Joined map[string]struct { AvatarURL string `json:"avatar_url,omitempty"` DisplayName string `json:"display_name,omitempty"` } `json:"joined"` }
RespJoinedMembers is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidjoined_members
type RespJoinedRooms ¶
type RespJoinedRooms struct {
JoinedRooms []string `json:"joined_rooms"`
}
RespJoinedRooms is the JSON response for TODO-SPEC https://github.com/matrix-org/synapse/pull/1680
type RespKickUser ¶
type RespKickUser struct{}
RespKickUser is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidkick
type RespKnockRoom ¶
type RespKnockRoom struct {
RoomID string `json:"room_id"`
}
RespKnockRoom is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3knockroomidoralias
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 string `json:"device_id"` UserID string `json:"user_id"` WellKnown DiscoveryInformation `json:"well_known"` }
RespLogin is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3login
type RespMediaUpload ¶
type RespMediaUpload struct {
ContentURI string `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 RespMessages ¶
type RespMessages struct { Chunk []Event `json:"chunk"` End string `json:"end"` Start string `json:"start"` State []Event `json:"state"` }
RespMessages is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3roomsroomidmessages
type RespPowerLevels ¶
type RespPowerLevels struct { Ban int `json:"ban,omitempty"` Events map[string]int `json:"events,omitempty"` EventsDefault int `json:"events_default,omitempty"` Invite int `json:"invite,omitempty"` Kick int `json:"kick,omitempty"` Notifications struct { Room int `json:"room,omitempty"` } `json:"notifications"` Redact int `json:"redact,omitempty"` StateDefault int `json:"state_default,omitempty"` Users map[string]int `json:"users"` UsersDefault int `json:"users_default,omitempty"` Room int `json:"room,omitempty"` }
RespPowerLevels is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#mroompower_levels
type RespPublicRooms ¶
type RespPublicRooms struct { Chunk []PublicRoom `json:"chunk"` NextBatch string `json:"next_batch,omitempty"` PrevBatch string `json:"prev_batch,omitempty"` TotalRoomCountEstimate int `json:"total_room_count_estimate,omitempty"` }
RespPublicRooms is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3directorylistroomroomid
type RespRegister ¶
type RespRegister struct { AccessToken string `json:"access_token"` DeviceID string `json:"device_id"` HomeServer string `json:"home_server"` RefreshToken string `json:"refresh_token"` UserID string `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 RespResolveRoomAlias ¶
type RespResolveRoomAlias struct { RoomID string `json:"room_id"` Servers []string `json:"servers"` }
RespResolveRoomAlias is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3directoryroomroomalias
type RespSearchUsers ¶
type RespSendEvent ¶
type RespSendEvent struct {
EventID string `json:"event_id"`
}
RespSendEvent is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid
type RespServerCapabilities ¶
type RespServerCapabilities struct {
Capabilities map[string]interface{} `json:"capabilities"`
}
RespServerCapabilities is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3capabilities
type RespSetRoomDir ¶
type RespSetRoomDir struct{}
RespSetRoomDir is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#put_matrixclientv3directorylistroomroomid
type RespSync ¶
type RespSync struct { AccountData struct { Events []Event `json:"events"` } `json:"account_data"` NextBatch string `json:"next_batch"` Presence struct { Events []Event `json:"events"` } `json:"presence"` Rooms struct { Invite map[string]struct { State struct { Events []Event `json:"events"` } `json:"invite_state"` } `json:"invite"` Join map[string]Join `json:"join"` Knock map[string]struct { State struct { Events []Event `json:"events"` } `json:"knock_state"` } Leave map[string]struct { AccountData struct { Events []Event `json:"events"` } `json:"account_data"` State struct { Events []Event `json:"events"` } `json:"state"` Timeline Timeline `json:"timeline"` } `json:"leave"` } `json:"rooms"` ToDevice struct { Events []Event `json:"events"` } `json:"to_device"` }
RespSync is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#get_matrixclientv3sync
type RespUnbanUser ¶
type RespUnbanUser struct{}
RespUnbanUser is the JSON response for https://spec.matrix.org/v1.1/client-server-api/#post_matrixclientv3roomsroomidunban
type RespUserInteractive ¶
type RespUserInteractive struct { Flows []struct { Stages []string `json:"stages"` } `json:"flows"` Params map[string]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 string) bool
HasSingleStageFlow returns true if there exists at least 1 Flow with a single stage of stageName.
type Room ¶
Room represents a single Matrix room.
func (Room) GetMembershipState ¶
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 []string `json:"not_rooms,omitempty"` Rooms []string `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, filterID string) LoadFilterID(userID string) string SaveNextBatch(userID, nextBatchToken string) LoadNextBatch(userID string) string SaveRoom(room *Room) LoadRoom(roomID string) *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 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 string) json.RawMessage }
Syncer represents an interface that must be satisfied in order to do /sync requests on a client.
type TagContent ¶
type TagContent struct {
Tags map[string]TagProperties `json:"tags"`
}
TagContent contains the data for an m.tag message type https://matrix.org/docs/spec/client_server/r0.4.0.html#m-tag
type TagProperties ¶
type TagProperties struct {
Order float32 `json:"order,omitempty"` // Empty values must be neglected
}
TagProperties contains the properties of a Tag
type TextMessage ¶
type TextMessage struct { Body string `json:"body"` Format string `json:"format"` FormattedBody string `json:"formatted_body"` MsgType string `json:"msgtype"` }
TextMessage is the contents of a Matrix formated message event.
type ThirdpartyIdentifier ¶
type ThirdpartyIdentifier struct { IDType string `json:"type"` // Set by NewThirdpartyIdentifier Medium string `json:"medium"` Address string `json:"address"` }
ThirdpartyIdentifier is the Identifier for https://matrix.org/docs/spec/client_server/r0.6.0#third-party-id
func NewThirdpartyIdentifier ¶
func NewThirdpartyIdentifier(medium, address string) ThirdpartyIdentifier
NewThirdpartyIdentifier creates a new UserIdentifier with IDType set to "m.id.user"
func (ThirdpartyIdentifier) Type ¶
func (i ThirdpartyIdentifier) Type() string
Type implements the Identifier interface
type ThumbnailInfo ¶
type ThumbnailInfo struct { Height uint `json:"h,omitempty"` Width uint `json:"w,omitempty"` Mimetype string `json:"mimetype,omitempty"` Size uint `json:"size,omitempty"` }
ThumbnailInfo contains info about an thumbnail image - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
type Timeline ¶
type Timeline struct { Events []Event `json:"events"` Limited bool `json:"limited"` PrevBatch string `json:"prev_batch,omitempty"` }
The timeline object
type UserIdentifier ¶
type UserIdentifier struct { IDType string `json:"type"` // Set by NewUserIdentifer User string `json:"user"` }
UserIdentifier is the Identifier for https://matrix.org/docs/spec/client_server/r0.6.0#matrix-user-id
func NewUserIdentifier ¶
func NewUserIdentifier(user string) UserIdentifier
NewUserIdentifier creates a new UserIdentifier with IDType set to "m.id.user"
func (UserIdentifier) Type ¶
func (i UserIdentifier) Type() string
Type implements the Identifier interface
type VideoInfo ¶
type VideoInfo struct { Mimetype string `json:"mimetype,omitempty"` ThumbnailInfo ThumbnailInfo `json:"thumbnail_info"` ThumbnailURL string `json:"thumbnail_url,omitempty"` Height uint `json:"h,omitempty"` Width uint `json:"w,omitempty"` Duration uint `json:"duration,omitempty"` Size uint `json:"size,omitempty"` }
VideoInfo contains info about a video - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-video
type VideoMessage ¶
type VideoMessage struct { MsgType string `json:"msgtype"` Body string `json:"body"` URL string `json:"url"` Info VideoInfo `json:"info"` }
VideoMessage is an m.video - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-video