mirror of
				https://github.com/matrix-org/gomatrix
				synced 2025-11-04 06:18:05 +00:00 
			
		
		
		
	Support sending formatted text (r0.6.0). (#82)
This commit is contained in:
		
							parent
							
								
									5891715dc5
								
							
						
					
					
						commit
						bceb63bac6
					
				
					 2 changed files with 13 additions and 4 deletions
				
			
		
							
								
								
									
										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
 | 
					// See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-text
 | 
				
			||||||
func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) {
 | 
					func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) {
 | 
				
			||||||
	return cli.SendMessageEvent(roomID, "m.room.message",
 | 
						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
 | 
					// 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
 | 
					// See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-notice
 | 
				
			||||||
func (cli *Client) SendNotice(roomID, text string) (*RespSendEvent, error) {
 | 
					func (cli *Client) SendNotice(roomID, text string) (*RespSendEvent, error) {
 | 
				
			||||||
	return cli.SendMessageEvent(roomID, "m.room.message",
 | 
						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
 | 
					// 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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,6 +45,8 @@ func (event *Event) MessageType() (msgtype string, ok bool) {
 | 
				
			||||||
type TextMessage struct {
 | 
					type TextMessage struct {
 | 
				
			||||||
	MsgType       string `json:"msgtype"`
 | 
						MsgType       string `json:"msgtype"`
 | 
				
			||||||
	Body          string `json:"body"`
 | 
						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
 | 
					// ThumbnailInfo contains info about an thumbnail image - http://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue