-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.go
128 lines (105 loc) · 2.14 KB
/
client.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package ts3
import "strconv"
func SendMsg(msg string, targetmode int, target int) Command {
return Command{
Command: "sendtextmessage",
Params: map[string][]string{
"targetmode": []string{strconv.Itoa(targetmode)},
"target": []string{strconv.Itoa(target)},
"msg": []string{msg},
},
}
}
func ClientList() Command {
return Command{
Command: "clientlist",
}
}
func Kick(clients []string, reasonmsg string) Command {
return Command{
Command: "clientkick",
Params: map[string][]string{
"clid": clients,
"reasonid": []string{"5"},
"reasonmsg": []string{reasonmsg},
},
}
}
func ClientGetDbIdFromUid(uid string) Command {
return Command{
Command: "´clientgetdbidfromuid",
Params: map[string][]string{
"cluid": []string{uid},
},
}
}
func ClientGetIds(uid string) Command {
return Command{
Command: "´clientgetids",
Params: map[string][]string{
"cluid": []string{uid},
},
}
}
func ClientGetNameFromUid(uid string) Command {
return Command{
Command: "´clientgetnamefromuid",
Params: map[string][]string{
"cluid": []string{uid},
},
}
}
func ClientGetNameFromDbId(dbid int) Command {
return Command{
Command: "´clientgetnamefromdbid",
Params: map[string][]string{
"cldbid": []string{dbid},
},
}
}
func BanList() Command {
return Command{
Command: "banlist",
}
}
func BanAdd(m map[string][]string) Command {
return Command{
Command: "banadd",
Params: m,
}
}
func BanRemove(banid int) Command {
return Command{
Command: "bandel",
Params: map[string][]string{
"banid": []string{strconv.Itoa(banid)},
},
}
}
fucn BansRemoveAll() Command {
return Command {
Command: "bandelall",
}
}
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
}