-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhelper.go
84 lines (67 loc) · 1.33 KB
/
helper.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package ts3
import (
"strconv"
)
func Login(user, pass string) (c Command) {
return Command{
Command: "login",
Params: map[string][]string{
"client_login_name": []string{user},
"client_login_password": []string{pass}},
}
}
func Version() (c Command) {
return Command{
Command: "version",
}
}
func Use(index int) Command {
return Command{
Command: "use",
Params: map[string][]string{
"sid": []string{strconv.Itoa(index)}},
}
}
func Kick(clients []string, reasonmsg string) Command {
return Command{
Command: "clientkick",
Params: map[string][]string{
"clid": clients,
"reasonid": []string{"5"},
"reasonmsg": []string{reasonmsg},
},
}
}
func ClientList() Command {
return Command{
Command: "clientlist",
}
}
func ChannelList() Command {
return Command{
Command: "channellist",
Flags: []string{"flags"},
}
}
func (client *Client) WalkClients(step func(int, map[string]string)) (err error) {
var res Response
res, err = client.Exec(ClientList())
if err != nil {
return
}
for i := range res.Params {
step(i, res.Params[i])
}
return
}
func (client *Client) WalkChannels(step func(int, map[string]string)) (err error) {
var res Response
res, err = client.Exec(ChannelList())
if err != nil {
return
}
for i := range res.Params {
step(i, res.Params[i])
}
return
}