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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
/* BotServ core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*
*/
/*************************************************************************/
#include "module.h"
int do_kickcmd(User * u);
void myBotServHelp(User * u);
/**
* Create the command, and tell anope about it.
* @param argc Argument count
* @param argv Argument list
* @return MOD_CONT to allow the module, MOD_STOP to stop it
**/
int AnopeInit(int argc, char **argv)
{
Command *c;
moduleAddAuthor("Anope");
moduleAddVersion(VERSION_STRING);
moduleSetType(CORE);
c = createCommand("KICK", do_kickcmd, NULL, BOT_HELP_KICK, -1, -1, -1,
-1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
c = createCommand("KICK BADWORDS", NULL, NULL, BOT_HELP_KICK_BADWORDS,
-1, -1, -1, -1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
c = createCommand("KICK BOLDS", NULL, NULL, BOT_HELP_KICK_BOLDS, -1,
-1, -1, -1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
c = createCommand("KICK CAPS", NULL, NULL, BOT_HELP_KICK_CAPS, -1, -1,
-1, -1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
c = createCommand("KICK COLORS", NULL, NULL, BOT_HELP_KICK_COLORS, -1,
-1, -1, -1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
c = createCommand("KICK FLOOD", NULL, NULL, BOT_HELP_KICK_FLOOD, -1,
-1, -1, -1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
c = createCommand("KICK REPEAT", NULL, NULL, BOT_HELP_KICK_REPEAT, -1,
-1, -1, -1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
c = createCommand("KICK REVERSES", NULL, NULL, BOT_HELP_KICK_REVERSES,
-1, -1, -1, -1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
c = createCommand("KICK UNDERLINES", NULL, NULL,
BOT_HELP_KICK_UNDERLINES, -1, -1, -1, -1);
moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
moduleSetBotHelp(myBotServHelp);
return MOD_CONT;
}
/**
* Unload the module
**/
void AnopeFini(void)
{
}
/**
* Add the help response to Anopes /bs help output.
* @param u The user who is requesting help
**/
void myBotServHelp(User * u)
{
notice_lang(s_BotServ, u, BOT_HELP_CMD_KICK);
}
/**
* The /bs kick command.
* @param u The user who issued the command
* @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
**/
int do_kickcmd(User * u)
{
char *chan = strtok(NULL, " ");
char *option = strtok(NULL, " ");
char *value = strtok(NULL, " ");
char *ttb = strtok(NULL, " ");
ChannelInfo *ci;
if (readonly)
notice_lang(s_BotServ, u, BOT_KICK_DISABLED);
else if (!chan || !option || !value)
syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
else if (stricmp(value, "ON") && stricmp(value, "OFF"))
syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX);
else if (!(ci = cs_findchan(chan)))
notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
else if (ci->flags & CI_VERBOTEN)
notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
else if (!is_services_admin(u) && !check_access(u, ci, CA_SET))
notice_lang(s_BotServ, u, ACCESS_DENIED);
else if (!ci->bi)
notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
else {
if (!stricmp(option, "BADWORDS")) {
if (!stricmp(value, "ON")) {
if (ttb) {
errno = 0;
ci->ttb[TTB_BADWORDS] =
strtol(ttb, (char **) NULL, 10);
/* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */
if (errno == ERANGE || errno == EINVAL
|| ci->ttb[TTB_BADWORDS] < 0) {
/* leaving the debug behind since we might want to know what these are */
if (debug) {
alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BADWORDS]);
}
/* reset the value back to 0 - TSL */
ci->ttb[TTB_BADWORDS] = 0;
notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
return MOD_CONT;
}
} else {
ci->ttb[TTB_BADWORDS] = 0;
}
ci->botflags |= BS_KICK_BADWORDS;
if (ci->ttb[TTB_BADWORDS]) {
alog("%s: %s!%s@%s enabled kicking for badwords on %s with time to ban of %d",
s_BotServ, u->nick, u->username, u->host, ci->name, ci->ttb[TTB_BADWORDS]);
notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN,
ci->ttb[TTB_BADWORDS]);
} else {
alog("%s: %s!%s@%s enabled kicking for badwords on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON);
}
} else {
ci->botflags &= ~BS_KICK_BADWORDS;
alog("%s: %s!%s@%s disabled kicking for badwords on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_OFF);
}
} else if (!stricmp(option, "BOLDS")) {
if (!stricmp(value, "ON")) {
if (ttb) {
errno = 0;
ci->ttb[TTB_BOLDS] = strtol(ttb, (char **) NULL, 10);
if (errno == ERANGE || errno == EINVAL
|| ci->ttb[TTB_BOLDS] < 0) {
if (debug) {
alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BOLDS]);
}
ci->ttb[TTB_BOLDS] = 0;
notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
return MOD_CONT;
}
} else
ci->ttb[TTB_BOLDS] = 0;
ci->botflags |= BS_KICK_BOLDS;
if (ci->ttb[TTB_BOLDS]) {
alog("%s: %s!%s@%s enabled kicking for bolds on %s with time to ban of %d",
s_BotServ, u->nick, u->username, u->host, ci->name, ci->ttb[TTB_BOLDS]);
notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON_BAN,
ci->ttb[TTB_BOLDS]);
} else {
alog("%s: %s!%s@%s enabled kicking for bolds on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON);
}
} else {
ci->botflags &= ~BS_KICK_BOLDS;
alog("%s: %s!%s@%s disabled kicking for bolds on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_BOLDS_OFF);
}
} else if (!stricmp(option, "CAPS")) {
if (!stricmp(value, "ON")) {
char *min = strtok(NULL, " ");
char *percent = strtok(NULL, " ");
if (ttb) {
errno = 0;
ci->ttb[TTB_CAPS] = strtol(ttb, (char **) NULL, 10);
if (errno == ERANGE || errno == EINVAL
|| ci->ttb[TTB_CAPS] < 0) {
if (debug) {
alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_CAPS]);
}
ci->ttb[TTB_CAPS] = 0;
notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
return MOD_CONT;
}
} else
ci->ttb[TTB_CAPS] = 0;
if (!min)
ci->capsmin = 10;
else
ci->capsmin = atol(min);
if (ci->capsmin < 1)
ci->capsmin = 10;
if (!percent)
ci->capspercent = 25;
else
ci->capspercent = atol(percent);
if (ci->capspercent < 1 || ci->capspercent > 100)
ci->capspercent = 25;
ci->botflags |= BS_KICK_CAPS;
if (ci->ttb[TTB_CAPS]) {
alog("%s: %s!%s@%s enabled kicking for caps on %s with time to ban of %d",
s_BotServ, u->nick, u->username, u->host, ci->name, ci->ttb[TTB_CAPS]);
notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON_BAN,
ci->capsmin, ci->capspercent,
ci->ttb[TTB_CAPS]);
} else {
alog("%s: %s!%s@%s enabled kicking for caps on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON,
ci->capsmin, ci->capspercent);
}
} else {
alog("%s: %s!%s@%s disabled kicking for caps on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
ci->botflags &= ~BS_KICK_CAPS;
notice_lang(s_BotServ, u, BOT_KICK_CAPS_OFF);
}
} else if (!stricmp(option, "COLORS")) {
if (!stricmp(value, "ON")) {
if (ttb) {
errno = 0;
ci->ttb[TTB_COLORS] = strtol(ttb, (char **) NULL, 10);
if (errno == ERANGE || errno == EINVAL
|| ci->ttb[TTB_COLORS] < 0) {
if (debug) {
alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_COLORS]);
}
ci->ttb[TTB_COLORS] = 0;
notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
return MOD_CONT;
}
} else
ci->ttb[TTB_COLORS] = 0;
ci->botflags |= BS_KICK_COLORS;
if (ci->ttb[TTB_COLORS]) {
alog("%s: %s!%s@%s enabled kicking for colors on %s with time to ban of %d",
s_BotServ, u->nick, u->username, u->host, ci->name, ci->ttb[TTB_COLORS]);
notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON_BAN,
ci->ttb[TTB_COLORS]);
} else {
alog("%s: %s!%s@%s enabled kicking for colors on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON);
}
} else {
alog("%s: %s!%s@%s disabled kicking for colors on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
ci->botflags &= ~BS_KICK_COLORS;
notice_lang(s_BotServ, u, BOT_KICK_COLORS_OFF);
}
} else if (!stricmp(option, "FLOOD")) {
if (!stricmp(value, "ON")) {
char *lines = strtok(NULL, " ");
char *secs = strtok(NULL, " ");
if (ttb) {
errno = 0;
ci->ttb[TTB_FLOOD] = strtol(ttb, (char **) NULL, 10);
if (errno == ERANGE || errno == EINVAL
|| ci->ttb[TTB_FLOOD] < 0) {
if (debug) {
alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_FLOOD]);
}
ci->ttb[TTB_FLOOD] = 0;
notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
return MOD_CONT;
}
} else
ci->ttb[TTB_FLOOD] = 0;
if (!lines)
ci->floodlines = 6;
else
ci->floodlines = atol(lines);
if (ci->floodlines < 2)
ci->floodlines = 6;
if (!secs)
ci->floodsecs = 10;
else
ci->floodsecs = atol(secs);
if (ci->floodsecs < 1 || ci->floodsecs > BSKeepData)
ci->floodsecs = 10;
ci->botflags |= BS_KICK_FLOOD;
if (ci->ttb[TTB_FLOOD]) {
alog("%s: %s!%s@%s enabled kicking for flood on %s with time to ban of %d",
s_BotServ, u->nick, u->username, u->host, ci->name, ci->ttb[TTB_FLOOD]);
notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON_BAN,
ci->floodlines, ci->floodsecs,
ci->ttb[TTB_FLOOD]);
} else {
alog("%s: %s!%s@%s enabled kicking for flood on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON,
ci->floodlines, ci->floodsecs);
}
} else {
ci->botflags &= ~BS_KICK_FLOOD;
alog("%s: %s!%s@%s disabled kicking for flood on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_FLOOD_OFF);
}
} else if (!stricmp(option, "REPEAT")) {
if (!stricmp(value, "ON")) {
char *times = strtok(NULL, " ");
if (ttb) {
errno = 0;
ci->ttb[TTB_REPEAT] = strtol(ttb, (char **) NULL, 10);
if (errno == ERANGE || errno == EINVAL
|| ci->ttb[TTB_REPEAT] < 0) {
if (debug) {
alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REPEAT]);
}
ci->ttb[TTB_REPEAT] = 0;
notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
return MOD_CONT;
}
} else
ci->ttb[TTB_REPEAT] = 0;
if (!times)
ci->repeattimes = 3;
else
ci->repeattimes = atol(times);
if (ci->repeattimes < 2)
ci->repeattimes = 3;
ci->botflags |= BS_KICK_REPEAT;
if (ci->ttb[TTB_REPEAT]) {
alog("%s: %s!%s@%s enabled kicking for repeating on %s with time to ban of %d",
s_BotServ, u->nick, u->username, u->host, ci->name, ci->ttb[TTB_REPEAT]);
notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON_BAN,
ci->repeattimes, ci->ttb[TTB_REPEAT]);
} else {
alog("%s: %s!%s@%s enabled kicking for repeating on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON,
ci->repeattimes);
}
} else {
ci->botflags &= ~BS_KICK_REPEAT;
alog("%s: %s!%s@%s disabled kicking for repeating on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_REPEAT_OFF);
}
} else if (!stricmp(option, "REVERSES")) {
if (!stricmp(value, "ON")) {
if (ttb) {
errno = 0;
ci->ttb[TTB_REVERSES] =
strtol(ttb, (char **) NULL, 10);
if (errno == ERANGE || errno == EINVAL
|| ci->ttb[TTB_REVERSES] < 0) {
if (debug) {
alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REVERSES]);
}
ci->ttb[TTB_REVERSES] = 0;
notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
return MOD_CONT;
}
} else
ci->ttb[TTB_REVERSES] = 0;
ci->botflags |= BS_KICK_REVERSES;
if (ci->ttb[TTB_REVERSES]) {
alog("%s: %s!%s@%s enabled kicking for reversess on %s with time to ban of %d",
s_BotServ, u->nick, u->username, u->host, ci->name, ci->ttb[TTB_REVERSES]);
notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON_BAN,
ci->ttb[TTB_REVERSES]);
} else {
alog("%s: %s!%s@%s enabled kicking for reverses on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON);
}
} else {
ci->botflags &= ~BS_KICK_REVERSES;
alog("%s: %s!%s@%s disabled kicking for reverses on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_REVERSES_OFF);
}
} else if (!stricmp(option, "UNDERLINES")) {
if (!stricmp(value, "ON")) {
if (ttb) {
errno = 0;
ci->ttb[TTB_UNDERLINES] =
strtol(ttb, (char **) NULL, 10);
if (errno == ERANGE || errno == EINVAL
|| ci->ttb[TTB_UNDERLINES] < 0) {
if (debug) {
alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_UNDERLINES]);
}
ci->ttb[TTB_UNDERLINES] = 0;
notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb);
return MOD_CONT;
}
} else
ci->ttb[TTB_UNDERLINES] = 0;
ci->botflags |= BS_KICK_UNDERLINES;
if (ci->ttb[TTB_UNDERLINES]) {
alog("%s: %s!%s@%s enabled kicking for underlines on %s with time to ban of %d",
s_BotServ, u->nick, u->username, u->host, ci->name, ci->ttb[TTB_UNDERLINES]);
notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN,
ci->ttb[TTB_UNDERLINES]);
} else {
alog("%s: %s!%s@%s enabled kicking for underlines on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON);
}
} else {
ci->botflags &= ~BS_KICK_UNDERLINES;
alog("%s: %s!%s@%s disabled kicking for underlines on %s",
s_BotServ, u->nick, u->username, u->host, ci->name);
notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_OFF);
}
} else
notice_help(s_BotServ, u, BOT_KICK_UNKNOWN, option);
}
return MOD_CONT;
}
|