matrix-org / gomatrix

A Golang Matrix client
Apache License 2.0
285 stars 53 forks source link

Status functions for interacting with the r0.6.0 presence/status API #80

Closed TheDiscordian closed 4 years ago

TheDiscordian commented 4 years ago

Adds:


// GetStatus returns the status of the user from the specified MXID. See https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-presence-userid-status
func (cli *Client) GetStatus(mxid string) (resp *RespUserStatus, err error) 

// GetOwnStatus returns the user's status. See https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-presence-userid-status
func (cli *Client) GetOwnStatus() (resp *RespUserStatus, err error) 

// SetStatus sets the user's status. See https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-presence-userid-status
func (cli *Client) SetStatus(presence, status string) (err error) 

// RespUserStatus is the JSON response for https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-presence-userid-status
type RespUserStatus struct {
    Presence        string `json:"presence"`
    StatusMsg       string `json:"status_msg"`
    lastActiveAgo   int    `json:"last_active_ago"`
    currentlyActive bool   `json:"currently_active"`
}
TheDiscordian commented 4 years ago

I know these aren't extremely useful, but I heard FluffyChat actually uses this API, so some users might find this useful. Also, I believe it is to the specification.