diff --git a/client.go b/client.go index 05ebcda..c8758b6 100644 --- a/client.go +++ b/client.go @@ -393,6 +393,14 @@ func (cli *Client) SendMessageEvent(roomID string, eventType string, contentJSON return } +// SendStateEvent sends a state event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey +// contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal. +func (cli *Client) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error) { + urlPath := cli.BuildURL("rooms", roomID, "state", eventType, stateKey) + _, err = cli.MakeRequest("PUT", urlPath, contentJSON, &resp) + return +} + // SendText sends an m.room.message event into the given room with a msgtype of 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) {