diff --git a/client.go b/client.go index 0ab2d1d..fd77fce 100644 --- a/client.go +++ b/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 diff --git a/events.go b/events.go index e82a6a3..e45c4f4 100644 --- a/events.go +++ b/events.go @@ -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