diff --git a/client.go b/client.go index 30f5fde..f916174 100644 --- a/client.go +++ b/client.go @@ -518,6 +518,14 @@ func (cli *Client) UnbanUser(roomID string, req *ReqUnbanUser) (resp *RespUnbanU return } +// UserTyping sets the typing status of the user. See https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid +func (cli *Client) UserTyping(roomID string, typing bool, timeout int64) (resp *RespTyping, err error) { + req := ReqTyping{Typing: typing, Timeout: timeout} + u := cli.BuildURL("rooms", roomID, "typing", cli.UserID) + _, err = cli.MakeRequest("PUT", u, req, &resp) + return +} + // StateEvent gets a single state event in a room. It will attempt to JSON unmarshal into the given "outContent" struct with // the HTTP response body, or return an error. // See http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-statekey diff --git a/requests.go b/requests.go index c1ba27b..af99a22 100644 --- a/requests.go +++ b/requests.go @@ -70,3 +70,9 @@ type ReqBanUser struct { type ReqUnbanUser struct { UserID string `json:"user_id"` } + +// ReqTyping is the JSON request for https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid +type ReqTyping struct { + Typing bool `json:"typing"` + Timeout int64 `json:"timeout"` +} diff --git a/responses.go b/responses.go index 1ae27e3..8a18c02 100644 --- a/responses.go +++ b/responses.go @@ -45,6 +45,9 @@ type RespBanUser struct{} // RespUnbanUser is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-unban type RespUnbanUser struct{} +// RespTyping is the JSON response for https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid +type RespTyping struct{} + // RespJoinedRooms is the JSON response for TODO-SPEC https://github.com/matrix-org/synapse/pull/1680 type RespJoinedRooms struct { JoinedRooms []string `json:"joined_rooms"`