mirror of https://github.com/matrix-org/gomatrix
Support sending formatted text (r0.6.0). (#82)
This commit is contained in:
parent
5891715dc5
commit
bceb63bac6
11
client.go
11
client.go
|
@ -538,7 +538,14 @@ func (cli *Client) SendStateEvent(roomID, eventType, stateKey string, contentJSO
|
|||
// See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-text
|
||||
func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) {
|
||||
return cli.SendMessageEvent(roomID, "m.room.message",
|
||||
TextMessage{"m.text", text})
|
||||
TextMessage{MsgType: "m.text", Body: text})
|
||||
}
|
||||
|
||||
// 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 (cli *Client) SendFormattedText(roomID, text, formattedText string) (*RespSendEvent, error) {
|
||||
return cli.SendMessageEvent(roomID, "m.room.message",
|
||||
TextMessage{MsgType: "m.text", Body: text, FormattedBody: formattedText, Format: "org.matrix.custom.html"})
|
||||
}
|
||||
|
||||
// SendImage sends an m.room.message event into the given room with a msgtype of m.image
|
||||
|
@ -567,7 +574,7 @@ func (cli *Client) SendVideo(roomID, body, url string) (*RespSendEvent, error) {
|
|||
// See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-notice
|
||||
func (cli *Client) SendNotice(roomID, text string) (*RespSendEvent, error) {
|
||||
return cli.SendMessageEvent(roomID, "m.room.message",
|
||||
TextMessage{"m.notice", text})
|
||||
TextMessage{MsgType: "m.notice", Body: text})
|
||||
}
|
||||
|
||||
// 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
|
||||
|
|
|
@ -43,8 +43,10 @@ func (event *Event) MessageType() (msgtype string, ok bool) {
|
|||
|
||||
// TextMessage is the contents of a Matrix formated message event.
|
||||
type TextMessage struct {
|
||||
MsgType string `json:"msgtype"`
|
||||
Body string `json:"body"`
|
||||
MsgType string `json:"msgtype"`
|
||||
Body string `json:"body"`
|
||||
FormattedBody string `json:"formatted_body"`
|
||||
Format string `json:"format"`
|
||||
}
|
||||
|
||||
// ThumbnailInfo contains info about an thumbnail image - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
|
||||
|
|
Loading…
Reference in New Issue