/
setOnline.go
55 lines (43 loc) Β· 1.11 KB
/
setOnline.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package api
import (
"fmt"
"net/url"
"github.com/botscommunity/vkgo/internal/pkg/conv"
"github.com/botscommunity/vkgo/internal/pkg/responses"
"github.com/botscommunity/vkgo/types"
)
func (bot *Bot) SetOnline(properties ...any) (ok bool, err *responses.Error) {
query := make(url.Values)
for _, property := range properties {
switch property := property.(type) {
case types.SetOnline:
if property.Calls {
query.Set("voip", fmt.Sprint(conv.BooleanToInteger(property.Calls)))
}
case int:
query.Set("voip", fmt.Sprint(property))
case bool:
query.Set("voip", fmt.Sprint(conv.BooleanToInteger(property)))
}
}
reply := responses.OnlineStatus{}
err = responses.NewInternalError(bot.Call("account.setOnline", query.Encode(), &reply))
if reply.Error != nil {
err = reply.Error
}
if reply.Code == 1 {
ok = true
}
return
}
func (bot *Bot) SetOffline() (ok bool, err *responses.Error) {
reply := responses.OnlineStatus{}
err = responses.NewInternalError(bot.Call("account.setOffline", "", &reply))
if reply.Error != nil {
err = reply.Error
}
if reply.Code == 1 {
ok = true
}
return
}