1 /* cmd_neonspam_set.c - NeonServ v5.1
2 * Copyright (C) 2011 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "cmd_neonspam.h"
20 typedef char* neonspam_cmd_set_function(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
21 static void neonspam_cmd_set_setting(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int setting, char *argument);
22 static char* neonspam_cmd_set_trigger(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
23 static char* neonspam_cmd_set_spamlimit(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
24 static char* neonspam_cmd_set_spamreaction(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
25 static char* neonspam_cmd_set_floodreaction(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
26 static char* neonspam_cmd_setjoinfloodreaction(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
27 static char* neonspam_cmd_setspamscan(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
28 static char* neonspam_cmd_setfloodscan(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
29 static char* neonspam_cmd_setjoinfloodscan(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
30 static char* neonspam_cmd_setbotnetscan(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
31 static char* neonspam_cmd_setscanchanops(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
32 static char* neonspam_cmd_setscanvoiced(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
33 static char* neonspam_cmd_setexceptlevel(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
34 static char* neonspam_cmd_setfloodsensibility(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
35 static char* neonspam_cmd_setjoinsensibility(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument);
37 #define NS_VALID_FUNCTION 0x01
38 #define NS_VALID_STRING 0x02
39 #define NS_VALID_ACCESS 0x04
40 #define NS_VALID_NO501 0x08
41 #define NS_VALID_OPTIONS 0x10
42 #define NS_VALID_NUMERIC 0x20
43 #define NS_VALID_BOOLEAN 0x40
45 #define NS_HAS_OPT 0x100 /* options (SET_OPTION_{NAME}_{VALUE}) */
46 #define NS_HAS_HELP 0x200 /* help (SET_HELP_{NAME}) - only shown if help is requested */
48 static MYSQL_ROW neonspam_settings_row, neonspam_settings_defaults;
49 #define SPAMSERV_SETTINGS_QUERY "`channel_scanstate`, `channel_scanexcept`, `channel_maxrepeat`, `channel_repeatreaction`, `channel_maxflood`, `channel_floodtime`, `channel_floodreaction`, `channel_maxjoin`, `channel_jointime`, `channel_joinreaction`"
50 #define SPAMSERV_SETTINGS_RESET "`channel_scanstate` = NULL, `channel_scanexcept` = NULL, `channel_maxrepeat` = NULL, `channel_repeatreaction` = NULL, `channel_maxflood` = NULL, `channel_floodtime` = NULL, `channel_floodreaction` = NULL, `channel_maxjoin` = NULL, `channel_jointime` = NULL, `channel_joinreaction` = NULL"
54 const char *chanfield;
58 } neonspam_settings[] = {
59 {"Trigger", NULL, NS_VALID_FUNCTION, NULL, neonspam_cmd_set_trigger},
60 {"SpamLimit", NULL, NS_VALID_OPTIONS | NS_VALID_FUNCTION | NS_HAS_OPT, "5", neonspam_cmd_set_spamlimit},
61 {"SpamReaction", NULL, NS_VALID_OPTIONS | NS_VALID_FUNCTION | NS_HAS_OPT, "3", neonspam_cmd_set_spamreaction},
62 {"FloodReaction", NULL, NS_VALID_OPTIONS | NS_VALID_FUNCTION | NS_HAS_OPT, "3", neonspam_cmd_set_floodreaction},
63 {"JoinFloodReaction", NULL, NS_VALID_OPTIONS | NS_VALID_FUNCTION | NS_HAS_OPT, "3", neonspam_cmd_setjoinfloodreaction},
64 {"SpamScan", NULL, NS_VALID_BOOLEAN | NS_VALID_FUNCTION, NULL, neonspam_cmd_setspamscan},
65 {"FloodScan", NULL, NS_VALID_BOOLEAN | NS_VALID_FUNCTION, NULL, neonspam_cmd_setfloodscan},
66 {"JoinFloodScan", NULL, NS_VALID_BOOLEAN | NS_VALID_FUNCTION, NULL, neonspam_cmd_setjoinfloodscan},
67 {"BotNetScan", NULL, NS_VALID_BOOLEAN | NS_VALID_FUNCTION, NULL, neonspam_cmd_setbotnetscan},
68 {"ScanChanOps", NULL, NS_VALID_BOOLEAN | NS_VALID_FUNCTION, NULL, neonspam_cmd_setscanchanops},
69 {"ScanVoiced", NULL, NS_VALID_BOOLEAN | NS_VALID_FUNCTION, NULL, neonspam_cmd_setscanvoiced},
70 {"ExceptLevel", NULL, NS_VALID_ACCESS | NS_VALID_FUNCTION, NULL, neonspam_cmd_setexceptlevel},
71 {"FloodSensibility", NULL, NS_VALID_FUNCTION, NULL, neonspam_cmd_setfloodsensibility},
72 {"JoinSensibility", NULL, NS_VALID_FUNCTION, NULL, neonspam_cmd_setjoinsensibility},
76 #define MAX_QUERY_LEN 1024
77 CMD_BIND(neonspam_cmd_set) {
79 if(argc && !strcmp(argv[0], "defaults")) {
80 //reset channel settings
81 int uaccess = getChannelAccess(user, chan, 0);
84 event->flags |= CMDFLAG_OPLOG;
86 reply(getTextBot(), user, "NS_SET_DEFAULTS_OWNER", chan->name);
92 static char defaultskey[16];
93 for(tmp = user->auth; *tmp; tmp++)
94 seed = (seed * 0xEECE66DL ^ ((*tmp << 24) | (*tmp << 16) | (*tmp << 8) | *tmp));
95 for(tmp = chan->name; *tmp; tmp++)
96 seed = (seed * 0xEECE66DL ^ ((*tmp << 24) | (*tmp << 16) | (*tmp << 8) | *tmp));
97 sprintf(defaultskey, "%08x", seed);
98 if(argc > 1 && !strcmp(argv[1], defaultskey)) {
99 printf_mysql_query("UPDATE `channels` SET " SPAMSERV_SETTINGS_RESET " WHERE `channel_id` = '%d'", chan->channel_id);
100 reply(getTextBot(), user, "NS_SET_DEFAULTS_DONE", chan->name);
103 reply(getTextBot(), user, "NS_SET_DEFAULTS_CODE", chan->name, defaultskey);
105 } else if(argc && strcmp(argv[0], "help")) {
106 //find the correct command
109 char *args = (argc > 1 ? merge_argv(argv, 1, argc) : NULL);
110 while(neonspam_settings[i].setting) {
111 if(!stricmp(neonspam_settings[i].setting, argv[0])) {
113 neonspam_cmd_set_setting(client, user, chan, event, i, args);
121 reply(getTextBot(), user, "NS_SET_UNKNOWN_SETTING", argv[0]);
124 char *value, *org_value, *tmp, nameBuf[64];
125 MYSQL_RES *res, *defaults_res;
131 while(neonspam_settings[i].setting)
133 table = table_init(2, i, 0);
134 table_set_bold(table, 0, 1);
135 printf_mysql_query("SELECT " SPAMSERV_SETTINGS_QUERY " FROM `channels` WHERE `channel_name` = 'defaults'");
136 defaults_res = mysql_use();
137 neonspam_settings_defaults = mysql_fetch_row(defaults_res);
138 printf_mysql_query("SELECT " SPAMSERV_SETTINGS_QUERY " FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
140 neonspam_settings_row = mysql_fetch_row(res);
143 reply(getTextBot(), user, "NS_SET_HEADER", chan->name);
144 while(neonspam_settings[i].setting) {
145 char valueBuf[MAXLEN];
146 if(neonspam_settings[i].valid & NS_VALID_FUNCTION) {
147 neonspam_cmd_set_function *func = neonspam_settings[i].function;
148 org_value = func(client, user, chan, event, NULL, NULL, valueBuf);
152 if(neonspam_settings[i].valid & NS_VALID_BOOLEAN) {
153 if(!strcmp(value, "0"))
154 value = get_language_string(user, "NS_SET_OFF");
156 value = get_language_string(user, "NS_SET_ON");
158 strcpy(query, value);
159 querypos = strlen(query);
160 if(neonspam_settings[i].valid & NS_HAS_OPT) {
161 sprintf(nameBuf, "NS_SET_OPTION_%s_%s", neonspam_settings[i].setting, org_value);
162 tmp = get_language_string(user, nameBuf);
164 querypos += sprintf(query+querypos, " - %s", tmp);
167 if(argc && neonspam_settings[i].valid & NS_HAS_HELP) {
168 sprintf(nameBuf, "NS_SET_HELP_%s", neonspam_settings[i].setting);
169 tmp = get_language_string(user, nameBuf);
171 querypos += sprintf(query+querypos, " - %s", tmp);
174 content[0] = (char*)neonspam_settings[i].setting;
176 table_add(table, content);
179 char **table_lines = table_end(table);
180 for(i = 0; i < table->entrys; i++) {
181 reply(getTextBot(), user, table_lines[i]);
187 static void neonspam_cmd_set_setting(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, int setting, char *args) {
189 char valueBuf[MAXLEN];
193 printf_mysql_query("SELECT " SPAMSERV_SETTINGS_QUERY " FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
195 neonspam_settings_row = mysql_fetch_row(res);
196 printf_mysql_query("SELECT " SPAMSERV_SETTINGS_QUERY " FROM `channels` WHERE `channel_name` = 'defaults'");
198 neonspam_settings_defaults = mysql_fetch_row(res);
199 if(neonspam_settings[setting].valid & NS_VALID_FUNCTION) {
200 neonspam_cmd_set_function *func = neonspam_settings[setting].function;
201 if(!(value = func(client, user, chan, event, NULL, NULL, valueBuf)))
206 //change the channel setting
207 //check the new argument
208 int valid = neonspam_settings[setting].valid;
209 if(valid & NS_VALID_STRING) {
210 if(!strcmp(args, "*")) {
214 if(valid & NS_VALID_ACCESS) {
215 int caccess = atoi(args);
216 int max = ((valid & NS_VALID_NO501) ? 500 : 501);
217 if(caccess < 0 || caccess > max) {
218 reply(getTextBot(), user, "NS_INVALID_ACCESS", caccess);
221 int uaccess = getChannelAccess(user, chan, 0);
222 if(uaccess == 500) uaccess++;
223 if(atoi(value) > uaccess) {
224 if(isGodMode(user)) {
225 event->flags |= CMDFLAG_OPLOG;
227 reply(getTextBot(), user, "NS_SET_CANNOT_SET");
231 if(caccess > uaccess) {
232 if(isGodMode(user)) {
233 event->flags |= CMDFLAG_OPLOG;
235 reply(getTextBot(), user, "NS_SET_BADLEVEL");
239 sprintf(nameBuf, "%d", caccess);
242 if(valid & NS_VALID_OPTIONS) {
243 int options = atoi((char *) neonspam_settings[setting].parameter);
244 int coption = atoi(args);
245 if(coption < 0 || coption >= options) {
246 reply(getTextBot(), user, "NS_SET_INVALID_OPTION", coption);
249 if(valid & NS_HAS_OPT) {
250 for(i = 0; i < options; i++) {
251 sprintf(nameBuf, "NS_SET_OPTION_%s_%d", neonspam_settings[setting].setting, i);
252 reply(getTextBot(), user, "\002%d\002 - %s", i, get_language_string(user, nameBuf));
255 for(i = 0; i < options; i++) {
256 nameBufPos += sprintf(nameBuf + nameBufPos, "\002%d\002, ", i);
259 nameBuf[nameBufPos-2] = '\0';
260 reply(getTextBot(), user, nameBuf);
266 if(valid & NS_VALID_NUMERIC) {
267 sprintf(nameBuf, "%d", atoi(args));
270 if(valid & NS_VALID_BOOLEAN) {
271 if(!strcmp(args, "0") || !stricmp(args, "off") || !stricmp(args, get_language_string(user, "NS_SET_OFF"))) {
273 } else if(!strcmp(args, "1") || !stricmp(args, "on") || !stricmp(args, get_language_string(user, "NS_SET_ON"))) {
276 reply(getTextBot(), user, "NS_SET_INVALID_BOOLEAN", args);
281 if(valid & NS_VALID_FUNCTION) {
282 neonspam_cmd_set_function *func = neonspam_settings[setting].function;
283 strcpy(valueBuf, value);
284 if(!(value = func(client, user, chan, event, neonspam_settings[setting].setting, valueBuf, args)))
288 reply(getTextBot(), user, "\002%s\002 %s", neonspam_settings[setting].setting, value);
289 if(neonspam_settings[setting].valid & NS_HAS_HELP) {
290 sprintf(nameBuf, "NS_SET_HELP_%s", neonspam_settings[setting].setting);
291 reply(getTextBot(), user, " %s", get_language_string(user, nameBuf));
295 static char* neonspam_cmd_set_trigger(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
297 //get current trigger
300 printf_mysql_query("SELECT `trigger` FROM `bot_channels` WHERE `chanid` = '%d' AND `botid` = '%d'", chan->channel_id, client->clientid);
302 row = mysql_fetch_row(res);
304 if(cvalue && argument) {
305 int uaccess = getChannelAccess(user, chan, 0);
307 if(isGodMode(user)) {
308 event->flags |= CMDFLAG_OPLOG;
310 reply(getTextBot(), user, "NS_SET_TRIGGER_OWNER", chan->name);
314 if(strlen(argument) > 15)
316 printf_mysql_query("UPDATE `bot_channels` SET `trigger` = '%s' WHERE `chanid` = '%d' AND `botid` = '%d'", escape_string(argument), chan->channel_id, client->clientid);
318 changeChannelTrigger(client->botid, chan, trigger);
324 static char* neonspam_cmd_set_spamlimit(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
327 cvalue = (neonspam_settings_row[2] ? neonspam_settings_row[2] : neonspam_settings_defaults[2]);
331 printf_mysql_query("UPDATE `channels` SET `channel_maxrepeat` = '%d' WHERE `channel_id` = '%d' ", atoi(argument), chan->channel_id);
332 sprintf(cvalue, "%d", atoi(argument));
333 if(chan->spam_settings)
334 chan->spam_settings->spam_amount = atoi(argument);
339 static char* neonspam_cmd_set_spamreaction(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
342 cvalue = (neonspam_settings_row[3] ? neonspam_settings_row[3] : neonspam_settings_defaults[3]);
346 printf_mysql_query("UPDATE `channels` SET `channel_repeatreaction` = '%d' WHERE `channel_id` = '%d' ", atoi(argument), chan->channel_id);
347 sprintf(cvalue, "%d", atoi(argument));
352 static char* neonspam_cmd_set_floodreaction(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
355 cvalue = (neonspam_settings_row[6] ? neonspam_settings_row[6] : neonspam_settings_defaults[6]);
359 printf_mysql_query("UPDATE `channels` SET `channel_floodreaction` = '%d' WHERE `channel_id` = '%d' ", atoi(argument), chan->channel_id);
360 sprintf(cvalue, "%d", atoi(argument));
365 static char* neonspam_cmd_setjoinfloodreaction(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
368 cvalue = (neonspam_settings_row[9] ? neonspam_settings_row[9] : neonspam_settings_defaults[9]);
372 printf_mysql_query("UPDATE `channels` SET `channel_joinreaction` = '%d' WHERE `channel_id` = '%d' ", atoi(argument), chan->channel_id);
373 sprintf(cvalue, "%d", atoi(argument));
378 static char* neonspam_cmd_setspamscan(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
381 cvalue = ((atoi(neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]) & SPAMSETTINGS_SPAMSCAN) ? "1" : "0");
385 int cflags = atoi((neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]));
386 if(!strcmp(argument, "0"))
387 cflags &= ~SPAMSETTINGS_SPAMSCAN;
389 cflags |= SPAMSETTINGS_SPAMSCAN;
390 printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id);
392 if(chan->spam_settings)
393 chan->spam_settings->flags = cflags;
398 static char* neonspam_cmd_setfloodscan(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
401 cvalue = ((atoi(neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]) & SPAMSETTINGS_FLOODSCAN) ? "1" : "0");
405 int cflags = atoi((neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]));
406 if(!strcmp(argument, "0"))
407 cflags &= ~SPAMSETTINGS_FLOODSCAN;
409 cflags |= SPAMSETTINGS_FLOODSCAN;
410 printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id);
412 if(chan->spam_settings)
413 chan->spam_settings->flags = cflags;
418 static char* neonspam_cmd_setjoinfloodscan(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
421 cvalue = ((atoi(neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]) & SPAMSETTINGS_JOINSCAN) ? "1" : "0");
425 int cflags = atoi((neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]));
426 if(!strcmp(argument, "0"))
427 cflags &= ~SPAMSETTINGS_JOINSCAN;
429 cflags |= SPAMSETTINGS_JOINSCAN;
430 printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id);
432 if(chan->spam_settings)
433 chan->spam_settings->flags = cflags;
438 static char* neonspam_cmd_setbotnetscan(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
441 cvalue = ((atoi(neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]) & SPAMSETTINGS_BOTNETSCAN) ? "1" : "0");
445 int cflags = atoi((neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]));
446 if(!strcmp(argument, "0"))
447 cflags &= ~SPAMSETTINGS_BOTNETSCAN;
449 cflags |= SPAMSETTINGS_BOTNETSCAN;
450 printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id);
452 if(chan->spam_settings)
453 chan->spam_settings->flags = cflags;
458 static char* neonspam_cmd_setscanchanops(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
461 cvalue = ((atoi(neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]) & SPAMSETTINGS_SCANOPS) ? "1" : "0");
465 int cflags = atoi((neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]));
466 if(!strcmp(argument, "0"))
467 cflags &= ~SPAMSETTINGS_SCANOPS;
469 cflags |= SPAMSETTINGS_SCANOPS;
470 printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id);
472 if(chan->spam_settings)
473 chan->spam_settings->flags = cflags;
478 static char* neonspam_cmd_setscanvoiced(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
481 cvalue = ((atoi(neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]) & SPAMSETTINGS_SCANVOICE) ? "1" : "0");
485 int cflags = atoi((neonspam_settings_row[0] ? neonspam_settings_row[0] : neonspam_settings_defaults[0]));
486 if(!strcmp(argument, "0"))
487 cflags &= ~SPAMSETTINGS_SCANVOICE;
489 cflags |= SPAMSETTINGS_SCANVOICE;
490 printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id);
492 if(chan->spam_settings)
493 chan->spam_settings->flags = cflags;
498 static char* neonspam_cmd_setexceptlevel(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
501 cvalue = (neonspam_settings_row[1] ? neonspam_settings_row[1] : neonspam_settings_defaults[1]);
505 printf_mysql_query("UPDATE `channels` SET `channel_scanexcept` = '%d' WHERE `channel_id` = '%d' ", atoi(argument), chan->channel_id);
506 sprintf(cvalue, "%d", atoi(argument));
507 if(chan->spam_settings)
508 chan->spam_settings->exceptlevel = atoi(argument);
513 static char* neonspam_cmd_setfloodsensibility(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
516 sprintf(argument, "%s:%s", (neonspam_settings_row[4] ? neonspam_settings_row[4] : neonspam_settings_defaults[4]), (neonspam_settings_row[5] ? neonspam_settings_row[5] : neonspam_settings_defaults[5]));
521 char *delimiter = strstr(argument, ":");
528 int amount = atoi(argument);
529 int timep = atoi(delimiter);
530 if(amount > MAX_FLOOD_AMOUNT || amount < MIN_FLOOD_AMOUNT) {
534 if(timep > MAX_FLOOD_TIME || timep < 0) {
535 //invalid time period
538 printf_mysql_query("UPDATE `channels` SET `channel_maxflood` = '%d', `channel_floodtime` = '%d' WHERE `channel_id` = '%d' ", amount, timep, chan->channel_id);
539 sprintf(cvalue, "%d:%d", amount, timep);
540 if(chan->spam_settings) {
541 chan->spam_settings->flood_amount = amount;
542 chan->spam_settings->flood_time = timep;
548 static char* neonspam_cmd_setjoinsensibility(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct Event *event, const char *setting, char *cvalue, char *argument) {
551 sprintf(argument, "%s:%s", (neonspam_settings_row[7] ? neonspam_settings_row[7] : neonspam_settings_defaults[7]), (neonspam_settings_row[8] ? neonspam_settings_row[8] : neonspam_settings_defaults[8]));
556 char *delimiter = strstr(argument, ":");
563 int amount = atoi(argument);
564 int timep = atoi(delimiter);
565 if(amount > MAX_JOIN_AMOUNT || amount < MIN_JOIN_AMOUNT) {
569 if(timep > MAX_JOIN_TIME || timep < 0) {
570 //invalid time period
573 printf_mysql_query("UPDATE `channels` SET `channel_maxjoin` = '%d', `channel_jointime` = '%d' WHERE `channel_id` = '%d' ", amount, timep, chan->channel_id);
574 sprintf(cvalue, "%d:%d", amount, timep);
575 if(chan->spam_settings) {
576 chan->spam_settings->join_amount = amount;
577 chan->spam_settings->join_time = timep;