add msgtype m.file

This commit is contained in:
Andreas Peters 2017-09-06 15:06:53 +02:00
parent 9b757298e3
commit ace302431c
2 changed files with 23 additions and 0 deletions

View File

@ -486,6 +486,17 @@ func (cli *Client) SendVideo(roomID, body, url string) (*RespSendEvent, error) {
})
}
// SendImage send an m.room.message event intor the given room with a msgtyope of m.file
// See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-file
func (cli *Client) SendFile(roomID, body, url string) (*RespSendEvent, error) {
return cli.SendMessageEvent(roomID, "m.room.message",
FileMessage{
MsgType: "m.file",
Body: body,
URL: url,
})
}
// SendNotice sends an m.room.message event into the given room with a msgtype of m.notice
// See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-notice
func (cli *Client) SendNotice(roomID, text string) (*RespSendEvent, error) {

View File

@ -86,6 +86,18 @@ type HTMLMessage struct {
Format string `json:"format"`
FormattedBody string `json:"formatted_body"`
}
// An FileMessage is the contents of a MATRIX File upload
type FileMessage struct {
Body string `json:"body"`
MsgType string `json:"msgtype"`
URL string `json:"url"`
Info FileInfo `json:"info"`
}
type FileInfo struct {
MimeType string `json:"mimetype"`
Size int64 `json:size"`
}
var htmlRegex = regexp.MustCompile("<[^<]+?>")