diff --git a/client.go b/client.go index 14bef79..80a6a52 100644 --- a/client.go +++ b/client.go @@ -225,18 +225,6 @@ func (c *UtopiaClient) SendInstantMessage(to string, message string) (int64, err return c.queryResultToInt("sendInstantMessage", params) } -// ContactData - user contact data -type ContactData struct { - AuthStatus int `json:"authorizationStatus"` - AvatarHash string `json:"avatarMd5"` - Group string `json:"group"` - PubkeyHash string `json:"hashedPk"` - IsFriend bool `json:"isFriend"` - Nick string `json:"nick"` - Pubkey string `json:"pk"` - Status int `json:"status"` -} - // GetContacts - get account contacts func (c *UtopiaClient) GetContacts(filter string) ([]ContactData, error) { // send request @@ -268,3 +256,28 @@ func (c *UtopiaClient) GetContacts(filter string) ([]ContactData, error) { return contacts, nil } + +// IsOnline - is contact online? +func (d *ContactData) IsOnline() bool { + return d.Status == 4096 +} + +// IsOffline - is contact offline? +func (d *ContactData) IsOffline() bool { + return d.Status == 65536 +} + +// IsAway - is contact away? +func (d *ContactData) IsAway() bool { + return d.Status == 4097 +} + +// IsDoNotDisturb - is contact marked to do not disturb mode? +func (d *ContactData) IsDoNotDisturb() bool { + return d.Status == 4099 +} + +// IsInvisible - is contact invisible? +func (d *ContactData) IsInvisible() bool { + return d.Status == 32768 +} diff --git a/structs.go b/structs.go index 88d3f85..09c4fb1 100644 --- a/structs.go +++ b/structs.go @@ -43,3 +43,15 @@ type WsSubscribeTask struct { // optional DisablePing bool } + +// ContactData - user contact data +type ContactData struct { + AuthStatus int `json:"authorizationStatus"` + AvatarHash string `json:"avatarMd5"` + Group string `json:"group"` + PubkeyHash string `json:"hashedPk"` + IsFriend bool `json:"isFriend"` + Nick string `json:"nick"` + Pubkey string `json:"pk"` + Status int `json:"status"` // 65536 - offline, 4096 - online, 4097 - away, 4099 - do not disturb, 32768 - invisible +}