Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

add msgtype m.file #41

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,17 @@ func (cli *Client) SendVideo(roomID, body, url string) (*RespSendEvent, error) {
})
}

// SendFile 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) {
Expand Down
14 changes: 14 additions & 0 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ type HTMLMessage struct {
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"`
}

// FileInfo contains information about a file
type FileInfo struct {
MimeType string `json:"mimetype"`
Size int64 `json:"size"`
}

var htmlRegex = regexp.MustCompile("<[^<]+?>")

// GetHTMLMessage returns an HTMLMessage with the body set to a stripped version of the provided HTML, in addition
Expand Down
1 change: 1 addition & 0 deletions responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ type RespSync struct {
} `json:"rooms"`
}

// RespTurnServer have information about the Rurtn Server Authentication
type RespTurnServer struct {
Username string `json:"username"`
Password string `json:"password"`
Expand Down