Documentation ¶
Index ¶
- Variables
- func Register(eventType Type, p func(RawEvent) (Event, error))
- type AudioInfo
- type CallAnswerEvent
- type CallCandidatesEvent
- type CallHangupEvent
- type CallHangupReason
- type CallInviteEvent
- type DirectEvent
- type Event
- type FileInfo
- type Filter
- type GlobalFilter
- type GuestAccess
- type HistoryVisibility
- type ImageInfo
- type JoinRule
- type LocationInfo
- type MemberType
- type MessageFormat
- type MessageType
- type PresenceEvent
- type RawEvent
- type Receipt
- type ReceiptEvent
- type RoomAvatarEvent
- type RoomCanonicalAliasEvent
- type RoomCreateEvent
- type RoomEvent
- type RoomEventFilter
- type RoomEventInfo
- type RoomFilter
- type RoomGuestAccessEvent
- type RoomHistoryVisibilityEvent
- type RoomJoinRulesEvent
- type RoomMemberEvent
- type RoomMessageEvent
- func (e RoomMessageEvent) AudioInfo() (AudioInfo, error)
- func (e RoomMessageEvent) FileInfo() (FileInfo, error)
- func (e RoomMessageEvent) ImageInfo() (ImageInfo, error)
- func (e RoomMessageEvent) LocationInfo() (LocationInfo, error)
- func (e *RoomMessageEvent) SetRoomEventInfo(i RoomEventInfo)
- func (e RoomMessageEvent) StrippedBody() string
- func (RoomMessageEvent) Type() Type
- func (e RoomMessageEvent) VideoInfo() (VideoInfo, error)
- type RoomNameEvent
- type RoomPinnedEvent
- type RoomPowerLevelsEvent
- type RoomRedactionEvent
- type RoomTombstoneEvent
- type RoomTopicEvent
- type StateEvent
- type StateFilter
- type StrippedEvent
- type TagEvent
- type ThumbnailInfo
- type Type
- type TypingEvent
- type VideoInfo
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownEventType = errors.New("unknown event type")
ErrUnknownEventType represents an error where the event type is unknown and therefore cannot be mapped to its concrete type.
Functions ¶
Types ¶
type AudioInfo ¶
type AudioInfo struct { Duration int // Duration of audio in millisecond. MimeType string // MIME type of audio. Size int // Size in bytes. }
AudioInfo stores the info of an audio.
type CallAnswerEvent ¶
type CallAnswerEvent struct { RoomEventInfo CallID string `json:"call_id"` Version int `json:"int"` Answer struct { Type string `json:"type"` // Must be "answer". SDP string `json:"sdp"` // Session Description Protocol } `json:"answer"` }
CallAnswerEvent is a message event where a callee wishes to answer the call.
It has the type ID of `m.call.answer`.
func (*CallAnswerEvent) SetRoomEventInfo ¶ added in v0.3.0
func (c *CallAnswerEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (CallAnswerEvent) Type ¶ added in v0.2.0
func (CallAnswerEvent) Type() Type
Type satisfies RoomEvent.
type CallCandidatesEvent ¶
type CallCandidatesEvent struct { RoomEventInfo CallID string `json:"call_id"` Version int `json:"version"` // Currently always 0. Candidates []struct { SDPMediaType string `json:"sdpMid"` SDPMediaLineIndex int `json:"sdpMLineIndex"` Candidate string `json:"candidate"` } `json:"candidates"` }
CallCandidatesEvent is a message event where additional ICE candidates are provided to foster communication.
It has the type ID of `m.call.candidates`.
func (*CallCandidatesEvent) SetRoomEventInfo ¶ added in v0.3.0
func (c *CallCandidatesEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (CallCandidatesEvent) Type ¶ added in v0.2.0
func (CallCandidatesEvent) Type() Type
Type satisfies RoomEvent.
type CallHangupEvent ¶
type CallHangupEvent struct { RoomEventInfo CallID string `json:"call_id"` Version int `json:"version"` // Currently always 0. Reason CallHangupReason `json:"reason"` }
CallHangupEvent is a message event where the call is ended. This can be sent to hang up a call or to reject a call.
It has the type ID of `m.call.hangup`.
func (*CallHangupEvent) SetRoomEventInfo ¶ added in v0.3.0
func (c *CallHangupEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (CallHangupEvent) Type ¶ added in v0.2.0
func (CallHangupEvent) Type() Type
Type satisfies RoomEvent.
type CallHangupReason ¶
type CallHangupReason string
CallHangupReason is the reason we hung up.
const ( CallHangupNormal CallHangupReason = "" CallHangupICEFailed CallHangupReason = "ice_failed" // ICE negotiation failed. CallHangupInviteTimeout CallHangupReason = "invite_timeout" )
Possible reasons to hang up. List available at https://matrix.org/docs/spec/client_server/r0.6.1#m-call-hangup.
type CallInviteEvent ¶
type CallInviteEvent struct { RoomEventInfo CallID string `json:"call_id"` Version int `json:"version"` // Currently always 0. Lifetime int `json:"lifetime"` // Milliseconds the offer is valid for. Offer struct { Type string `json:"type"` // Must be "offer". SDP string `json:"sdp"` // Session Description Protocol } `json:"offer"` }
CallInviteEvent is a message event where someone is inviting to establish a call.
It has the type ID of `m.call.invite`.
func (*CallInviteEvent) SetRoomEventInfo ¶ added in v0.3.0
func (c *CallInviteEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (CallInviteEvent) Type ¶ added in v0.2.0
func (CallInviteEvent) Type() Type
Type satisfies RoomEvent.
type DirectEvent ¶ added in v0.3.0
DirectEvent is an event that lists all the DM channels the user is in.
func (DirectEvent) Raw ¶ added in v0.3.0
func (d DirectEvent) Raw() (RawEvent, error)
Raw returns DirectEvent in the form of a RawEvent.
type FileInfo ¶
type FileInfo struct { MimeType string `json:"mimetype,omitempty"` // MIME type of image. Size int `json:"size,omitempty"` // Size in bytes. ThumbnailURL matrix.URL `json:"thumbnail_url,omitempty"` // Present if thumbnail is unencrypted. ThumbnailFile encrypt.File `json:"thumbnail_file,omitempty"` // Present if thumbnail is encrypted. ThumbnailInfo ThumbnailInfo `json:"thumbnail_info,omitempty"` }
FileInfo stores the info of a file.
type Filter ¶
type Filter struct { // Maximum number of events to return. Limit int `json:"limit,omitempty"` // List of senders to include. All if not provided. IncludedSenders []matrix.UserID `json:"senders,omitempty"` // List of event types to include. All if not provided. // '*' can be used as a wildcard. IncludedTypes []Type `json:"types,omitempty"` // List of senders to exclude. Overrides IncludedSenders. ExcludedSenders []matrix.UserID `json:"not_senders,omitempty"` // List of event types to exclude. Overrides IncludedTypes. // '*' can be used as a wildcard. ExcludedTypes []Type `json:"not_types,omitempty"` }
Filter represents a filter that filters events that should be sent to the client.
type GlobalFilter ¶
type GlobalFilter struct { // List of event fields that should be included. EventFields []string `json:"event_fields,omitempty"` // The format to use. This implementation recommends the // use of "client" (default). // // Don't include if you don't know what you're doing. EventFormat string `json:"event_format,omitempty"` // List of presence updates to include. Presence Filter `json:"presence,omitempty"` // List of user account data updates to include. // This does not affect data associated with room. AccountData Filter `json:"account_data,omitempty"` // Filter to be applied to room data. Room RoomFilter `json:"room,omitempty"` }
GlobalFilter represents a filter that can be uploaded to/downloaded from the homeserver.
Servers MAY still send data that has been excluded by the filter. The filter only tells the server what is safe to not include.
type GuestAccess ¶ added in v0.3.0
type GuestAccess string
GuestAccess is an enum that decides if a guest can join a room.
const ( GuestAccessCanJoin GuestAccess = "can_join" GuestAccessForbidden GuestAccess = "forbidden" )
The two possible values of GuestAccess.
type HistoryVisibility ¶ added in v0.3.0
type HistoryVisibility string
HistoryVisibility specifies the group that can view the room history.
const ( // VisibilityInvited allows members to see history from the moment they were invited until // they are no longer invited or in the room. VisibilityInvited HistoryVisibility = "invited" // VisibilityJoined allows members to see history from the moment they join the room until // they are no longer in the room. VisibilityJoined HistoryVisibility = "joined" // as long as they are a member at some point. // ! THIS IS THE DEFAULT ! VisibilityShared HistoryVisibility = "shared" // VisibilityWorldReadable allows everyone to see all history including users who were never in the room. VisibilityWorldReadable HistoryVisibility = "world_readable" )
type ImageInfo ¶
type ImageInfo struct { FileInfo // Intended display size of image. Present if RoomMessageFileInfo is part of RoomMessageImage. Height int `json:"h,omitempty"` Width int `json:"w,omitempty"` }
ImageInfo stores the info of an image.
type JoinRule ¶
type JoinRule string
JoinRule represents the condition required to join a room.
const ( JoinPublic JoinRule = "public" JoinKnock JoinRule = "knock" JoinInvite JoinRule = "invite" JoinPrivate JoinRule = "private" )
"public" means the room can be joined by everyone while "invite" means the user must be invited before attempting to join.
"knock" and "private" are reserved keywords which are not implemented.
type LocationInfo ¶
type LocationInfo struct { ThumbnailURL matrix.URL `json:"thumbnail_url,omitempty"` // Present if thumbnail is unencrypted. ThumbnailFile encrypt.File `json:"thumbnail_file,omitempty"` // Present if thumbnail is encrypted. ThumbnailInfo ThumbnailInfo `json:"thumbnail_info,omitempty"` }
LocationInfo stores the info of a location.
type MemberType ¶
type MemberType string
MemberType represents the type of member the user is in a room.
const ( MemberInvited MemberType = "invite" MemberJoined MemberType = "join" MemberLeft MemberType = "leave" MemberBanned MemberType = "ban" MemberKnock MemberType = "knock" )
Invited means that the user is invited and could join the room. Joined means that the user is already in the room. Left means that the user has not joined the room/left it. Banned means that the user has been banned.
Knock is reserved and not implemented.
type MessageFormat ¶
type MessageFormat string
MessageFormat is the type of the custom formatted body.
const (
FormatHTML MessageFormat = "org.matrix.custom.html"
)
Currently, HTML is the only known RoomMessageFormat.
type MessageType ¶
type MessageType string
MessageType is the type of message sent.
const ( // Text, Emote and Notice are all messages. // Text is a regular message, Emote is similar to /me in IRC and Notice is a message sent by a bot. RoomMessageText MessageType = "m.text" RoomMessageEmote MessageType = "m.emote" RoomMessageNotice MessageType = "m.notice" RoomMessageImage MessageType = "m.image" RoomMessageFile MessageType = "m.file" RoomMessageAudio MessageType = "m.audio" RoomMessageLocation MessageType = "m.location" RoomMessageVideo MessageType = "m.video" )
All possible RoomMessageEvent types. List available at https://matrix.org/docs/spec/client_server/r0.6.1#m-room-message-msgtypes.
type PresenceEvent ¶ added in v0.3.0
type PresenceEvent struct { User matrix.UserID `json:"-"` AvatarURL *matrix.URL `json:"avatar_url,omitempty"` DisplayName *string `json:"displayname,omitempty"` // Last time since user performed some action, in ms. LastActiveAgo *int `json:"last_active_ago,omitempty"` Presence matrix.Presence `json:"presence"` CurrentlyActive *bool `json:"currently_active,omitempty"` Status *string `json:"status_msg,omitempty"` // contains filtered or unexported fields }
PresenceEvent is an event where the presence of a user is updated.
func (PresenceEvent) LastActive ¶ added in v0.3.0
func (p PresenceEvent) LastActive() *time.Time
LastActive calculates the last active time based on the time the event is parsed and the last active ago field. It is slightly off as the time the event is received is subject to network latency. It returns nil if the last active ago field is absent.
type RawEvent ¶ added in v0.2.0
type RawEvent struct { // Common data for all events. Type Type `json:"type"` Content json.RawMessage `json:"content"` // Data that are common for rooms and state events. ID matrix.EventID `json:"event_id,omitempty"` Sender matrix.UserID `json:"sender,omitempty"` OriginServerTime matrix.Timestamp `json:"origin_server_ts,omitempty"` RoomID matrix.RoomID `json:"room_id,omitempty"` // NOT included on `/sync` events. Unsigned struct { // Age is the time in milliseconds that has elapsed since the event was sent. // It is generated by local homeserver and may be incorrect if either server's // time is out of sync. Age matrix.Duration `json:"age,omitempty"` RedactReason *RawEvent `json:"redacted_because,omitempty"` TransactionID string `json:"transaction_id,omitempty"` } `json:"unsigned,omitempty"` // Data for state events. StateKey string `json:"state_key,omitempty"` PrevContent json.RawMessage `json:"prev_content,omitempty"` // Optional previous content, if available. // Data for `m.room.redaction`. The ID of the event that was actually redacted. Redacts string `json:"redacts,omitempty"` }
RawEvent represents events that can be sent from homeserver to the client.
type Receipt ¶ added in v0.3.0
Receipt is an aggregate of users that have acknowledged a certain event.
type ReceiptEvent ¶ added in v0.3.0
ReceiptEvent is an event where the read marker is updated.
type RoomAvatarEvent ¶
type RoomAvatarEvent struct { RoomEventInfo Info ImageInfo `json:"info,omitempty"` URL matrix.URL `json:"url"` }
RoomAvatarEvent represents a state event where the room avatar is set.
It has the type ID of `m.room.avatar` and a zero-length state key.
func (*RoomAvatarEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomAvatarEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomAvatarEvent) StateKey ¶ added in v0.2.0
func (RoomAvatarEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomAvatarEvent) Type ¶ added in v0.2.0
func (RoomAvatarEvent) Type() Type
Type satisfies StateEvent.
type RoomCanonicalAliasEvent ¶
type RoomCanonicalAliasEvent struct { RoomEventInfo // The canonical alias for the room. May be empty. Alias string `json:"alias,omitempty"` // Alternative aliases the room advertises. It can be present even if Alias is empty. AltAlias []string `json:"alt_aliases,omitempty"` }
RoomCanonicalAliasEvent represents a state event where the alias (name) of the room is set.
It has the type ID of `m.room.canonical_alias`. It has a zero-length StateKey.
func (*RoomCanonicalAliasEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomCanonicalAliasEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomCanonicalAliasEvent) StateKey ¶ added in v0.2.0
func (RoomCanonicalAliasEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomCanonicalAliasEvent) Type ¶ added in v0.2.0
func (RoomCanonicalAliasEvent) Type() Type
Type satisfies StateEvent.
type RoomCreateEvent ¶
type RoomCreateEvent struct { RoomEventInfo // The user ID of the room creator. This is set by the homeserver. Creator matrix.UserID `json:"creator"` // Whether users from other servers can join. Defaults to true. Federated *bool `json:"m.federate,omitempty"` // Room Version. Defaults to "1" if not specified. RoomVersion *string `json:"room_version,omitempty"` }
RoomCreateEvent represents a state event where the room is created or upgraded. Do note that there's no order of Matrix version and it is still considered upgrading for "upgrading" version 2 to 1. It is the first event in any room.
It has the type ID of `m.room.create` and a zero-length StateKey.
func (*RoomCreateEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomCreateEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomCreateEvent) StateKey ¶ added in v0.2.0
func (RoomCreateEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomCreateEvent) Type ¶ added in v0.2.0
func (RoomCreateEvent) Type() Type
Type satisfies StateEvent.
type RoomEvent ¶ added in v0.2.0
type RoomEvent interface { Event ID() matrix.EventID Room() matrix.RoomID Sender() matrix.UserID OriginServerTime() matrix.Timestamp }
RoomEvent is an event that is recorded in history and is not one-off. Typing is not a RoomEvent for example.
type RoomEventFilter ¶
type RoomEventFilter struct { // Limit is the maximum number of events to return. Limit int `json:"limit,omitempty"` // List of senders to include. All if omitted. IncludedSenders []matrix.UserID `json:"senders,omitempty"` // List of types to include. All if omitted. IncludedTypes []Type `json:"types,omitempty"` // List of rooms to include. All if omitted. IncludeRooms []matrix.RoomID `json:"rooms,omitempty"` // List of senders to exclude. Overrides IncludedSenders. ExcludedSenders []matrix.UserID `json:"not_senders,omitempty"` // List of types to exclude. Overrides IncludedTypes. ExcludedTypes []Type `json:"not_types,omitempty"` // List of rooms to exclude. Overrides IncludedRooms. ExcludedRooms []matrix.RoomID `json:"not_rooms,omitempty"` // Enable lazy loading members. If it's true, it'll only send // member info that are mentioned in events. // Other member data should be queried through the API if this // is true. LazyLoadMembers bool `json:"lazy_load_members,omitempty"` // The server does not send member info that it thinks the client // already knows by default. The server will include it instead if // this is set to true. IncludeRedundantMembers bool `json:"include_redundant_members,omitempty"` // Include only events with a `url` key in its content if `true`. // Include only events without a `url` key in its content if `false`. // `url` is not used to filter otherwise. ContainsURL *bool `json:"contains_url,omitempty"` }
RoomEventFilter represents a filter that filters room events.
type RoomEventInfo ¶ added in v0.2.0
type RoomEventInfo struct { RoomID matrix.RoomID EventID matrix.EventID SenderID matrix.UserID OriginTime matrix.Timestamp }
RoomEventInfo is a helper that satisfies the RoomEvent interface by providing info. It does not include Type info.
func (RoomEventInfo) ID ¶ added in v0.2.0
func (r RoomEventInfo) ID() matrix.EventID
ID satisfies RoomEvent.
func (RoomEventInfo) OriginServerTime ¶ added in v0.2.0
func (r RoomEventInfo) OriginServerTime() matrix.Timestamp
OriginServerTime satisfies RoomEvent.
func (RoomEventInfo) Room ¶ added in v0.2.0
func (r RoomEventInfo) Room() matrix.RoomID
Room satisfies RoomEvent.
func (RoomEventInfo) Sender ¶ added in v0.2.0
func (r RoomEventInfo) Sender() matrix.UserID
Sender satisfies RoomEvent.
type RoomFilter ¶
type RoomFilter struct { // Rooms to include. All if not provided. IncludedRooms []matrix.RoomID `json:"rooms,omitempty"` // Rooms to exclude. Overrides IncludedRoom. ExcludedRooms []matrix.RoomID `json:"not_rooms,omitempty"` // Ephemeral is the subfilter applied to events that are // not persistent (added to history) like typing. Ephemeral RoomEventFilter `json:"ephemeral,omitempty"` // The client will continue to listen to events from rooms // that the user has left if this is set to true. // Defaults to false. IncludeLeave bool `json:"include_leave,omitempty"` // State is the subfilter applied to state events. State StateFilter `json:"state,omitempty"` // Timeline is the subfilter applied to events that are // persistent (added to history) like messages. Timeline RoomEventFilter `json:"timeline,omitempty"` // AccountData is the subfilter applied to per user account // data. AccountData RoomEventFilter `json:"account_data,omitempty"` }
RoomFilter represents a filter that filters room data.
type RoomGuestAccessEvent ¶ added in v0.3.0
type RoomGuestAccessEvent struct { RoomEventInfo GuestAccess GuestAccess `json:"guest_access"` }
RoomGuestAccessEvent is an event that controls whether guest users are allowed to join rooms. If the event is not present, it's inferred to be forbidden.
func (*RoomGuestAccessEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomGuestAccessEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomGuestAccessEvent) StateKey ¶ added in v0.3.0
func (RoomGuestAccessEvent) StateKey() string
StateKey implements StateEvent.
func (RoomGuestAccessEvent) Type ¶ added in v0.3.0
func (RoomGuestAccessEvent) Type() Type
Type implements StateEvent.
type RoomHistoryVisibilityEvent ¶ added in v0.3.0
type RoomHistoryVisibilityEvent struct { RoomEventInfo Visibility HistoryVisibility `json:"history_visibility,omitempty"` }
RoomHistoryVisibilityEvent is an event where the visibility of history is changed.
func (RoomHistoryVisibilityEvent) StateKey ¶ added in v0.3.0
func (RoomHistoryVisibilityEvent) StateKey() string
StateKey implements StateEvent.
func (RoomHistoryVisibilityEvent) Type ¶ added in v0.3.0
func (RoomHistoryVisibilityEvent) Type() Type
Type implements StateEvent.
type RoomJoinRulesEvent ¶
type RoomJoinRulesEvent struct { RoomEventInfo // The new rules to be applied to users wishing to join the room. JoinRule JoinRule `json:"join_rule"` }
RoomJoinRulesEvent represents a state event where the room's join rules are set.
It has the type ID of `m.room.join_rules` and a zero-length StateKey.
func (*RoomJoinRulesEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomJoinRulesEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomJoinRulesEvent) StateKey ¶ added in v0.2.0
func (RoomJoinRulesEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomJoinRulesEvent) Type ¶ added in v0.2.0
func (RoomJoinRulesEvent) Type() Type
Type satisfies StateEvent.
type RoomMemberEvent ¶
type RoomMemberEvent struct { RoomEventInfo // The ID of the user for this event. UserID matrix.UserID `json:"-"` // The avatar URL of the user, if any. AvatarURL matrix.URL `json:"avatar_url,omitempty"` // The display name of the user, if any. DisplayName *string `json:"displayname,omitempty"` // The new state of the user in the room. NewState MemberType `json:"membership,omitempty"` // Flag indicating if the room was created with intention of being a DM. IsDirect bool `json:"is_direct,omitempty"` // ThirdPartyInvites is set when it's an invite event and is the successor of a // m.room.third_party_invite event. ThirdPartyInvite struct { DisplayName string `json:"display_name"` } `json:"third_party_invite,omitempty"` // A purely INFORMATIONAL source that SHOULD NOT be trusted for the state of the room. // It may be present or absent. Unsigned struct { InviteRoomState []StrippedEvent `json:"invite_room_state"` } `json:"unsigned,omitempty"` }
RoomMemberEvent represents a state event where a user's membership state changes.
It has the type ID of `m.room.member` and the StateKey of the user ID.
func (RoomMemberEvent) StateKey ¶ added in v0.2.0
func (e RoomMemberEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomMemberEvent) Type ¶ added in v0.2.0
func (RoomMemberEvent) Type() Type
Type satisfies StateEvent.
type RoomMessageEvent ¶
type RoomMessageEvent struct { RoomEventInfo Body string `json:"body"` MsgType MessageType `json:"msgtype"` // This message is a reply to RelatesTo if present. RelatesTo matrix.EventID `json:"relates_to,omitempty"` // Optionally present in Text, Emote and Notice. Format MessageFormat `json:"format,omitempty"` FormattedBody string `json:"formatted_body,omitempty"` // This field is present in Location. GeoURI matrix.GeoURI `json:"geo_uri,omitempty"` // These fields are present in Image, File, Audio, Video. URL matrix.URL `json:"url,omitempty"` // Present if content is not encrypted. File encrypt.File `json:"file,omitempty"` // Present if content is encrypted. // This field is present in Image, File, Audio, Video, Location. // The relevant parsing functions should be used. Info json.RawMessage `json:"info,omitempty"` // Also present in Location. }
RoomMessageEvent represents a room event where a message has been sent.
It has the type ID of `m.room.message`.
func (RoomMessageEvent) AudioInfo ¶
func (e RoomMessageEvent) AudioInfo() (AudioInfo, error)
AudioInfo parses info as an AudioInfo.
func (RoomMessageEvent) FileInfo ¶
func (e RoomMessageEvent) FileInfo() (FileInfo, error)
FileInfo parses info as a FileInfo.
func (RoomMessageEvent) ImageInfo ¶
func (e RoomMessageEvent) ImageInfo() (ImageInfo, error)
ImageInfo parses info as an ImageInfo.
func (RoomMessageEvent) LocationInfo ¶
func (e RoomMessageEvent) LocationInfo() (LocationInfo, error)
LocationInfo parses info as a LocationInfo.
func (*RoomMessageEvent) SetRoomEventInfo ¶ added in v0.3.0
func (e *RoomMessageEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomMessageEvent) StrippedBody ¶
func (e RoomMessageEvent) StrippedBody() string
StrippedBody should be used if the client is rich reply aware (uses the RelatesTo field) in place of Body.
func (RoomMessageEvent) Type ¶ added in v0.2.0
func (RoomMessageEvent) Type() Type
Type satisfies RoomEvent.
func (RoomMessageEvent) VideoInfo ¶
func (e RoomMessageEvent) VideoInfo() (VideoInfo, error)
VideoInfo parses info as a VideoInfo.
type RoomNameEvent ¶
type RoomNameEvent struct { RoomEventInfo Name string `json:"name,omitempty"` // This must not exceed 255 bytes. }
RoomNameEvent represents a state event where the room name is set. This is only used to be displayed. It's not unique and names can be duplicated.
It has the type ID of `m.room.name` and a zero-length state key.
func (*RoomNameEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomNameEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomNameEvent) StateKey ¶ added in v0.2.0
func (RoomNameEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomNameEvent) Type ¶ added in v0.2.0
func (RoomNameEvent) Type() Type
Type satisfies StateEvent.
type RoomPinnedEvent ¶
type RoomPinnedEvent struct { RoomEventInfo Pinned []matrix.EventID `json:"pinned"` }
RoomPinnedEvent represents a state event where the list of events pinned are modified.
It has the type ID of `m.room.pinned_events` and a zero-length state key.
func (*RoomPinnedEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomPinnedEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomPinnedEvent) StateKey ¶ added in v0.2.0
func (RoomPinnedEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomPinnedEvent) Type ¶ added in v0.2.0
func (RoomPinnedEvent) Type() Type
Type satisfies StateEvent.
type RoomPowerLevelsEvent ¶
type RoomPowerLevelsEvent struct { RoomEventInfo // Ban, invite, kick and redact defaults to 50 if unspecified. BanRequirement *int `json:"ban,omitempty"` InviteRequirement *int `json:"invite,omitempty"` KickRequirement *int `json:"kick,omitempty"` RedactRequirement *int `json:"redact,omitempty"` // The power requirements of events. Events overrides the default. // The default for normal events is EventRequirement and // the default for state events is StateRequirement. Events map[Type]int `json:"events,omitempty"` EventRequirement int `json:"events_default,omitempty"` StateRequirement int `json:"state_default,omitempty"` // UserLevel is a map of user IDs to their power level. UserLevel map[matrix.UserID]int `json:"users,omitempty"` // The default power level of users (if not in UserLevel). UserDefault int `json:"users_default,omitempty"` Notifications struct { // The power level required to ping a room. Defaults to 50. Room *int `json:"room,omitempty"` } `json:"notifications,omitempty"` }
RoomPowerLevelsEvent represents a state event that establishes the power level and requirements for each event to be sent.
It has the type ID of `m.room.power_levels` and a zero-length StateKey.
func (*RoomPowerLevelsEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomPowerLevelsEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomPowerLevelsEvent) StateKey ¶ added in v0.2.0
func (RoomPowerLevelsEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomPowerLevelsEvent) Type ¶ added in v0.2.0
func (RoomPowerLevelsEvent) Type() Type
Type satisfies StateEvent.
type RoomRedactionEvent ¶
type RoomRedactionEvent struct { RoomEventInfo Reason string `json:"reason,omitempty"` }
RoomRedactionEvent is a message event where another event is redacted from the history. All keys associated with the event may be stripped off, causing the data to no longer be accessible. This can also be used for moderators to hide message events (which can be undone).
It has the type ID of `m.room.redaction`. The Redacts key will be present.
func (*RoomRedactionEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomRedactionEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomRedactionEvent) Type ¶ added in v0.2.0
func (RoomRedactionEvent) Type() Type
Type satisfies RoomEvent.
type RoomTombstoneEvent ¶ added in v0.3.0
type RoomTombstoneEvent struct { RoomEventInfo Message string `json:"body,omitempty"` ReplacementRoom matrix.RoomID `json:"replacement_room,omitempty"` }
RoomTombstoneEvent is an event where the current room has been upgraded and a new room should be used instead.
func (*RoomTombstoneEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomTombstoneEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomTombstoneEvent) StateKey ¶ added in v0.3.0
func (RoomTombstoneEvent) StateKey() string
StateKey implements StateEvent.
func (RoomTombstoneEvent) Type ¶ added in v0.3.0
func (RoomTombstoneEvent) Type() Type
Type implements StateEvent.
type RoomTopicEvent ¶
type RoomTopicEvent struct { RoomEventInfo Topic string `json:"topic,omitempty"` }
RoomTopicEvent represents a state event where the room topic is set.
It has the type ID of `m.room.topic` and a zero-length state key.
func (*RoomTopicEvent) SetRoomEventInfo ¶ added in v0.3.0
func (r *RoomTopicEvent) SetRoomEventInfo(i RoomEventInfo)
SetRoomEventInfo sets the room event info.
func (RoomTopicEvent) StateKey ¶ added in v0.2.0
func (RoomTopicEvent) StateKey() string
StateKey satisfies StateEvent.
func (RoomTopicEvent) Type ¶ added in v0.2.0
func (RoomTopicEvent) Type() Type
Type satisfies StateEvent.
type StateEvent ¶ added in v0.2.0
StateEvent is an event that records the change of a state.
type StateFilter ¶
type StateFilter struct { // Limit is the maximum number of events to return. Limit int `json:"limit,omitempty"` // List of senders to include. All if omitted. IncludedSenders []matrix.UserID `json:"senders,omitempty"` // List of types to include. All if omitted. IncludedTypes []Type `json:"types,omitempty"` // List of rooms to include. All if omitted. IncludeRooms []matrix.RoomID `json:"rooms,omitempty"` // List of senders to exclude. Overrides IncludedSenders. ExcludedSenders []matrix.UserID `json:"not_senders,omitempty"` // List of types to exclude. Overrides IncludedTypes. ExcludedTypes []Type `json:"not_types,omitempty"` // List of rooms to exclude. Overrides IncludedRooms. ExcludedRooms []matrix.RoomID `json:"not_rooms,omitempty"` // Enable lazy loading members. If it's true, it'll only send // member info that are mentioned in events. // Other member data should be queried through the API if this // is true. LazyLoadMembers bool `json:"lazy_load_members,omitempty"` // The server does not send member info that it thinks the client // already knows by default. The server will include it instead if // this is set to true. IncludeRedundantMembers bool `json:"include_redundant_members,omitempty"` // Include only events with a `url` key in its content if `true`. // Include only events without a `url` key in its content if `false`. // `url` is not used to filter otherwise. ContainsURL *bool `json:"contains_url,omitempty"` }
StateFilter represents a filter for state events.
type StrippedEvent ¶
type StrippedEvent struct {
RawEvent
}
StrippedEvent represents an event that has been stripped. This allows the client to display a room state correctly without its full timeline.
It has the Type, Content, StateKey and Sender field.
type TagEvent ¶ added in v0.3.1
type TagEvent struct { RoomID matrix.RoomID `json:"-"` Tags map[matrix.TagName]matrix.Tag `json:"tags"` }
TagEvent represents an event that informs the client of the tags on a room.
type ThumbnailInfo ¶
type ThumbnailInfo struct { Height int `json:"h,omitempty"` // Intended height of thumbnail. Width int `json:"w,omitempty"` // Intended width of thumbnail. MimeType string `json:"mimetype,omitempty"` // MIME type of thumbnail. Size int `json:"size,omitempty"` // Size in bytes. }
ThumbnailInfo stores the info of a thumbnail.
type Type ¶
type Type string
Type is the type of the event that is contained in the contents field.
const ( TypeRoomCanonicalAlias Type = "m.room.canonical_alias" TypeRoomCreate Type = "m.room.create" TypeRoomJoinRules Type = "m.room.join_rules" TypeRoomMember Type = "m.room.member" TypeRoomPowerLevels Type = "m.room.power_levels" TypeRoomRedaction Type = "m.room.redaction" // Events from the Instant Messaging module. TypeRoomMessage Type = "m.room.message" TypeRoomName Type = "m.room.name" TypeRoomTopic Type = "m.room.topic" TypeRoomAvatar Type = "m.room.avatar" TypeRoomPinned Type = "m.room.pinned_events" // Events from the Direct Messaging module. TypeDirect Type = "m.direct" // Events from the Voice over IP module. TypeCallInvite Type = "m.call.invite" TypeCallCandidates Type = "m.call.candidates" TypeCallAnswer Type = "m.call.answer" TypeCallHangup Type = "m.call.hangup" // Events from the Typing Notifications module. TypeTyping Type = "m.typing" // Events from the Receipts module. TypeReceipt Type = "m.receipt" // Events from the Presence module. TypePresence Type = "m.presence" // Events from the History Visibility module. TypeRoomHistoryVisibility Type = "m.room.history_visibility" // Events from the Guest Access module. TypeRoomGuestAccess Type = "m.room.guest_access" // Events from the Tag module. TypeTag = "m.tag" // Events from the Room Upgrade module. TypeRoomTombstone Type = "m.room.tombstone" )
List of all known room events. NOTE: Update the 'parser' variable below as well.