Documentation ¶
Overview ¶
Package room interfaces with matrix rooms.
Index ¶
- Constants
- type EventWithoutContent
- type MessageContent
- type MessageEvent
- type MessageReference
- type MessageRelates
- type OpaqueContent
- type OpaqueEvent
- type ReactionContent
- type Room
- func (r *Room) Join(ctx context.Context) error
- func (r *Room) SendMessage(ctx context.Context, text string) error
- func (r *Room) SendReaction(ctx context.Context, source, key string) error
- func (r *Room) SendReply(ctx context.Context, source, text string) error
- func (r *Room) SyncEvents(ctx context.Context, log logr.Logger, handler func(MessageEvent))
Constants ¶
const MessageEventType = "m.room.message"
MessageEventType indicates a room event is a message.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventWithoutContent ¶
type EventWithoutContent struct { EventID string `json:"event_id"` OriginSenderTimestamp int `json:"origin_server_ts"` Sender string `json:"sender"` StateKey string `json:"state_key"` EventType string `json:"type"` }
EventWithoutContent represents a room event without the content field. This struct should be extended by more concrete types.
func (EventWithoutContent) IsRoomMessageEvent ¶
func (e EventWithoutContent) IsRoomMessageEvent() bool
IsRoomMessageEvent returns true if the event represents a message sent to a matrix room.
type MessageContent ¶
type MessageContent struct { MessageType string `json:"msgtype"` Body string `json:"body"` Format string `json:"format,omitempty"` FormattedBody string `json:"formatted_body,omitempty"` Relates *MessageRelates `json:"m.relates_to,omitempty"` }
MessageContent represents the content of room message.
type MessageEvent ¶
type MessageEvent struct { EventWithoutContent Content MessageContent `struct:"content"` }
MessageEvent is a message sent to a room.
type MessageReference ¶ added in v0.0.2
type MessageReference struct { ID string `json:"event_id"` Key string `json:"key,omitempty"` Type string `json:"rel_type,omitempty"` }
MessageReference references another message.
type MessageRelates ¶ added in v0.0.2
type MessageRelates struct {
RepliesTo MessageReference `json:"m.in_reply_to"`
}
MessageRelates indicates that a message relates so another one.
type OpaqueContent ¶
type OpaqueContent []byte
OpaqueContent is the marshalled form of a room event content.
func (*OpaqueContent) UnmarshalJSON ¶
func (o *OpaqueContent) UnmarshalJSON(b []byte) error
UnmarshalJSON tells the json unmarshaller to leave the content field as is.
type OpaqueEvent ¶
type OpaqueEvent struct { EventWithoutContent Content OpaqueContent `json:"content,string"` }
OpaqueEvent is a room event with opaque content.
func (OpaqueEvent) AsRoomMessageEvent ¶
func (r OpaqueEvent) AsRoomMessageEvent() (MessageEvent, error)
AsRoomMessageEvent converts this event to a MessageEvent. Panics if wrong type.
type ReactionContent ¶ added in v0.0.2
type ReactionContent struct {
RelatesTo MessageReference `json:"m.relates_to"`
}
ReactionContent is the payload of a reaction.
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
Room represents a matrix room.
func (*Room) SendMessage ¶
SendMessage with the given text content to the room.
func (*Room) SendReaction ¶ added in v0.0.2
SendReaction sends a reaction (emoticon) to a given source event id.
func (*Room) SyncEvents ¶
SyncEvents of this room and let all messages be handled by handler.