Documentation
¶
Overview ¶
Package room handles matrix rooms.
Index ¶
- Constants
- func IsMessageEvent(evt event.Metadata) bool
- func IsReactionEvent(evt event.Metadata) bool
- func Join(ctx context.Context, cli matrix.Client, id string) error
- func Joined(ctx context.Context, cli matrix.Client) ([]string, error)
- type MessageContent
- type MessageEvent
- type MessageReference
- type MessageRelates
- type ReactionContent
- type ReactionEvent
Constants ¶
const ( // EventTypeMessage in a event type field indicates that the event is a room message. EventTypeMessage = "m.room.message" // MessageTypeText in a message content message type field indicates that the event is a text message. MessageTypeText = "m.text" )
const EventTypeReaction = "m.reaction"
EventTypeReaction in a event type field indicates that the event is a room reaction.
Variables ¶
This section is empty.
Functions ¶
func IsMessageEvent ¶ added in v0.0.3
IsMessageEvent returns true if the given event metadata indicates that the event is a room message.
func IsReactionEvent ¶ added in v0.0.3
IsReactionEvent returns true if the given event metadata indicates that the event is a room reaction.
Types ¶
type MessageContent ¶
type MessageContent struct {
MessageType string `json:"msgtype"`
Body string `json:"body"`
RelatesTo *MessageRelates `json:"m.relates_to,omitempty"`
}
MessageContent represents the content of room message.
type MessageEvent ¶
type MessageEvent struct {
event.Metadata
Content MessageContent `struct:"content"`
}
MessageEvent is a message sent to a room.
func AsMessageEvent ¶ added in v0.0.3
func AsMessageEvent(evt event.Opaque) (MessageEvent, error)
AsMessageEvent converts the given opaque event to a room message. Panics is metadata indicates that the event is not a room message and returns an error if unmarshalling of the content failed.
func NewTextMessage ¶ added in v0.0.3
func NewTextMessage(room, body string) MessageEvent
NewTextMessage creates a new MessageEvent with the content of a text message with the given body and sets the room of the event.
func (MessageEvent) AsReplyTo ¶ added in v0.0.3
func (m MessageEvent) AsReplyTo(toID string) MessageEvent
AsReplyTo marks the message as a reply to the given event ID.
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 ReactionContent ¶ added in v0.0.2
type ReactionContent struct {
RelatesTo MessageReference `json:"m.relates_to"`
}
ReactionContent represents the content of room reaction.
type ReactionEvent ¶ added in v0.0.3
type ReactionEvent struct {
event.Metadata
Content ReactionContent `struct:"content"`
}
ReactionEvent is a reaction sent to a room.
func AsReactionEvent ¶ added in v0.0.3
func AsReactionEvent(evt event.Opaque) (ReactionEvent, error)
AsReactionEvent converts the given opaque event to a room reaction. Panics is metadata indicates that the event is not a room message and returns an error if unmarshalling of the content failed.
func NewReaction ¶ added in v0.0.3
func NewReaction(room, key, toID string) ReactionEvent
NewReaction creates a new ReactionEvent with the content of a reaction with the given key and reference to the given event ID and sets the room of the event.