-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
commands.go
264 lines (231 loc) · 6.86 KB
/
commands.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
package main
import (
"fmt"
"strings"
waProto "go.mau.fi/whatsmeow/binary/proto"
"go.mau.fi/whatsmeow/types"
)
func cmdGetGroup(args []string) (output string) {
if len(args) < 1 {
output = "\n[getgroup] Usage: getgroup <jid>"
log.Errorf("%s", output)
return
}
group, ok := parseJID(args[0])
if !ok {
output = "\n[getgroup] You need to specify a valid group JID"
log.Errorf("%s", output)
return
} else if group.Server != types.GroupServer {
output = fmt.Sprintf("\n[getgroup] Input must be a group JID (@%s)", types.GroupServer)
log.Errorf("%s", output)
return
}
resp, err := cli.GetGroupInfo(group)
if err != nil {
output = fmt.Sprintf("\n[getgroup] Failed to get group info: %v", err)
log.Errorf("%s", output)
return
} else {
output = fmt.Sprintf("\n[getgroup] Group info: %+v", resp)
log.Infof("%s", output)
return
}
}
func cmdListGroups(args []string) (output string) {
groups, err := cli.GetJoinedGroups()
if err != nil {
output = fmt.Sprintf("\n[listgroup] Failed to get group list: %v", err)
log.Errorf("%s", output)
return
} else {
for _, group := range groups {
output = fmt.Sprintf("%s%+v: %+v\n", output, group.GroupName.Name, group.JID)
log.Infof("%s", output)
}
return
}
}
func cmdSendSpoofedReply(args []string) (output string) {
if len(args) < 4 {
output = "\n[send-spoofed-reply] Usage: send-spoofed-reply <chat_jid> <msgID:!|#ID> <spoofed_jid> <spoofed_text>|<text>"
log.Errorf("%s", output)
return
}
chat_jid, ok := parseJID(args[0])
if !ok {
output = "\n[send-spoofed-reply] You need to specify a valid Chat ID (Group or User)"
log.Errorf("%s", output)
return
}
msgID := args[1]
if msgID[0] == '!' {
msgID = cli.GenerateMessageID()
}
spoofed_jid, ok2 := parseJID(args[2])
if !ok2 {
output = "\n[send-spoofed-reply] You need to specify a valid User ID to spoof"
log.Errorf("%s", output)
return
}
parameters := strings.SplitN(strings.Join(args[3:], " "), "|", 2)
spoofed_text := parameters[0]
text := parameters[1]
_, resp, err := sendSpoofedReplyMessage(chat_jid, spoofed_jid, msgID, spoofed_text, text)
if err != nil {
output = fmt.Sprintf("\n[send-spoofed-reply] Error on sending spoofed msg: %v", err)
log.Errorf("%s", output)
return
} else {
output = fmt.Sprintf("\n[send-spoofed-reply] spoofed msg sended: %+v", resp)
log.Infof("%s", output)
return
}
}
func cmdSendSpoofedImgReply(args []string) (output string) {
if len(args) < 5 {
output = "\n[send-spoofed-img-reply] Usage: send-spoofed-img-reply <chat_jid> <msgID:!|#ID> <spoofed_jid> <spoofed_file> <spoofed_text>|<text>"
log.Errorf("%s", output)
return
}
chat_jid, ok := parseJID(args[0])
if !ok {
output = "\n[send-spoofed-img-reply] You need to specify a valid Chat ID (Group or User)"
log.Errorf("%s", output)
return
}
msgID := args[1]
if msgID[0] == '!' {
msgID = cli.GenerateMessageID()
}
spoofed_jid, ok2 := parseJID(args[2])
if !ok2 {
output = "\n[send-spoofed-img-reply] You need to specify a valid User ID to spoof"
log.Errorf("%s", output)
return
}
spoofed_file := args[3]
parameters := strings.SplitN(strings.Join(args[4:], " "), "|", 2)
spoofed_text := parameters[0]
text := parameters[1]
_, resp, err := sendSpoofedReplyImg(chat_jid, spoofed_jid, msgID, spoofed_file, spoofed_text, text)
if err != nil {
output = fmt.Sprintf("\n[send-spoofed-img-reply] Error on sending spoofed msg: %v", err)
log.Errorf("%s", output)
return
} else {
output = fmt.Sprintf("\n[send-spoofed-img-reply] spoofed msg sended: %+v", resp)
log.Infof("%s", output)
return
}
}
func cmdSendSpoofedDemo(args []string) (output string) {
if len(args) < 4 {
output = "\n[send-spoofed-demo] Usage: send-spoofed-demo <toGender:boy|girl> <language:br|en> <chat_jid> <spoofed_jid>"
log.Errorf("%s", output)
return
}
var toGender string
if args[0] != "boy" && args[0] != "girl" {
output = "\n[send-spoofed-demo] Error: <boy|girl>"
log.Errorf("%s", output)
return
} else {
toGender = args[0]
}
var language string
if args[1] != "br" && args[1] != "en" {
output = "\n[send-spoofed-demo] Error: <br|en>"
log.Errorf("%s", output)
return
} else {
language = args[1]
}
chat_jid, ok := parseJID(args[2])
if !ok {
output = "\n[send-spoofed-demo] You need to specify a valid Chat ID (Group or User)"
log.Errorf("%s", output)
return
}
spoofed_jid, ok2 := parseJID(args[3])
if !ok2 {
output = "\n[send-spoofed-demo] You need to specify a valid User ID to spoof"
log.Errorf("%s", output)
return
}
sendSpoofedTalkDemo(chat_jid, spoofed_jid, toGender, language, "")
output = fmt.Sprintf("\n[send-spoofed-demo] spoofed msg sended to %s as %s", chat_jid, spoofed_jid)
return
}
func cmdSendSpoofedDemoImg(args []string) (output string) {
if len(args) < 5 {
log.Errorf("\n[send-spoofed-demo-img] Usage: send-spoofed-demo-img <toGender:boy|girl> <language:br|en> <chat_jid> <spoofed_jid> <spoofed_img>")
return
}
var toGender string
if args[0] != "boy" && args[0] != "girl" {
output = "\n[send-spoofed-demo-img] Error: <boy|girl>"
log.Errorf("%s", output)
return
} else {
toGender = args[0]
}
var language string
if args[1] != "br" && args[1] != "en" {
output = "\n[send-spoofed-demo-img] Error: <br|en>"
log.Errorf("%s", output)
return
} else {
language = args[1]
}
chat_jid, ok := parseJID(args[2])
if !ok {
output = "\n[send-spoofed-demo-img] You need to specify a valid Chat ID (Group or User)"
log.Errorf("%s", output)
return
}
spoofed_jid, ok2 := parseJID(args[3])
if !ok2 {
output = "\n[send-spoofed-demo-img] You need to specify a valid User ID to spoof"
log.Errorf("%s", output)
return
}
spoofed_img := args[4]
sendSpoofedTalkDemo(chat_jid, spoofed_jid, toGender, language, spoofed_img)
output = fmt.Sprintf("\n[send-spoofed-demo-img] send-spoofed-demo-img: spoofed msg sended to %s as %s", chat_jid, spoofed_jid)
return
}
func cmdSpoofedReplyThis(args []string, msg *waProto.Message) (output string) {
if len(args) < 4 {
output = "\n[spoofed-reply-this] Usage: spoofed-reply-this <chat_jid> <msgID:!|#ID> <spoofed_jid> <text>"
log.Errorf("%s", output)
return
}
chat_jid, ok := parseJID(args[0])
if !ok {
output = "\n[send-spoofed-reply] You need to specify a valid Chat ID (Group or User)"
log.Errorf("%s", output)
return
}
msgID := args[1]
if msgID[0] == '!' {
msgID = cli.GenerateMessageID()
}
spoofed_jid, ok2 := parseJID(args[2])
if !ok2 {
output = "\n[send-spoofed-reply] You need to specify a valid User ID to spoof"
log.Errorf("%s", output)
return
}
text := strings.Join(args[3:], " ")
_, resp, err := sendSpoofedReplyThis(chat_jid, spoofed_jid, msgID, text, msg)
if err != nil {
output = fmt.Sprintf("\n[reply-spoofed-this] Error on sending spoofed msg: %v", err)
log.Errorf("%s", output)
return
} else {
output = fmt.Sprintf("\n[reply-spoofed-this] spoofed msg sended: %+v", resp)
log.Infof("%s", output)
return
}
}