From: pk910 Date: Wed, 19 Oct 2011 22:55:47 +0000 (+0200) Subject: use channel settings for spam/flood scanner X-Git-Tag: v5.3~277 X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=commitdiff_plain;h=e06b26ecbdfc7f44a4cf459c6bdab9050fa4b83d use channel settings for spam/flood scanner --- diff --git a/src/bot_NeonSpam.c b/src/bot_NeonSpam.c index 73755b7..bbb0bd5 100644 --- a/src/bot_NeonSpam.c +++ b/src/bot_NeonSpam.c @@ -123,10 +123,22 @@ static int loadNeonSpamSettings(struct ChanNode *chan) { perror("malloc() failed"); return 0; } - settings->flags = SPAMSETTINGS_SCANVOICE | SPAMSETTINGS_FLOODSCAN | SPAMSETTINGS_SPAMSCAN; - settings->spam_amount = 3; - settings->flood_amount = 4; - settings->flood_time = 5; + MYSQL_RES *res; + MYSQL_ROW row, defaults = NULL; + printf_mysql_query("SELECT `channel_scanstate`, `channel_maxrepeat`, `channel_maxflood`, `channel_floodtime`, `channel_maxjoin`, `channel_jointime` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id); + res = mysql_use(); + row = mysql_fetch_row(res); + if(!row[0] || !row[1] || !row[2] || !row[3] || !row[4] || !row[5]) { + printf_mysql_query("SELECT `channel_scanstate`, `channel_maxrepeat`, `channel_maxflood`, `channel_floodtime`, `channel_maxjoin`, `channel_jointime` FROM `channels` WHERE `channel_name` = 'defaults'"); + res = mysql_use(); + defaults = mysql_fetch_row(res); + } + settings->flags = atoi(row[0] ? row[0] : defaults[0]); + settings->spam_amount = atoi(row[1] ? row[1] : defaults[1]); + settings->flood_amount = atoi(row[2] ? row[2] : defaults[2]); + settings->flood_time = atoi(row[3] ? row[3] : defaults[3]); + settings->join_amount = atoi(row[4] ? row[4] : defaults[4]); + settings->join_time = atoi(row[5] ? row[5] : defaults[5]); chan->spam_settings = settings; return 1; } diff --git a/src/bot_NeonSpam.h b/src/bot_NeonSpam.h index 4cf64a9..0fb2af4 100644 --- a/src/bot_NeonSpam.h +++ b/src/bot_NeonSpam.h @@ -39,6 +39,8 @@ struct NeonSpamSettings { unsigned char spam_amount; unsigned char flood_amount; unsigned char flood_time; + unsigned char join_amount; + unsigned char join_time; }; /* PENALTY SYSTEM diff --git a/src/cmd_neonspam_set.c b/src/cmd_neonspam_set.c index 9a9c238..228867a 100644 --- a/src/cmd_neonspam_set.c +++ b/src/cmd_neonspam_set.c @@ -328,6 +328,8 @@ static char* neonspam_cmd_set_spamlimit(struct ClientSocket *client, struct User //change value printf_mysql_query("UPDATE `channels` SET `channel_maxrepeat` = '%d' WHERE `channel_id` = '%d' ", atoi(argument), chan->channel_id); sprintf(cvalue, "%d", atoi(argument)); + if(chan->spam_settings) + chan->spam_settings->spam_amount = atoi(argument); } return cvalue; } @@ -385,6 +387,8 @@ static char* neonspam_cmd_setspamscan(struct ClientSocket *client, struct UserNo cflags |= SPAMSETTINGS_SPAMSCAN; printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id); cvalue = argument; + if(chan->spam_settings) + chan->spam_settings->flags = cflags; } return cvalue; } @@ -403,6 +407,8 @@ static char* neonspam_cmd_setfloodscan(struct ClientSocket *client, struct UserN cflags |= SPAMSETTINGS_FLOODSCAN; printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id); cvalue = argument; + if(chan->spam_settings) + chan->spam_settings->flags = cflags; } return cvalue; } @@ -421,6 +427,8 @@ static char* neonspam_cmd_setjoinfloodscan(struct ClientSocket *client, struct U cflags |= SPAMSETTINGS_JOINSCAN; printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id); cvalue = argument; + if(chan->spam_settings) + chan->spam_settings->flags = cflags; } return cvalue; } @@ -439,6 +447,8 @@ static char* neonspam_cmd_setscanchanops(struct ClientSocket *client, struct Use cflags |= SPAMSETTINGS_SCANOPS; printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id); cvalue = argument; + if(chan->spam_settings) + chan->spam_settings->flags = cflags; } return cvalue; } @@ -457,6 +467,8 @@ static char* neonspam_cmd_setscanvoiced(struct ClientSocket *client, struct User cflags |= SPAMSETTINGS_SCANVOICE; printf_mysql_query("UPDATE `channels` SET `channel_scanstate` = '%d' WHERE `channel_id` = '%d' ", cflags, chan->channel_id); cvalue = argument; + if(chan->spam_settings) + chan->spam_settings->flags = cflags; } return cvalue; } @@ -501,6 +513,10 @@ static char* neonspam_cmd_setfloodsensibility(struct ClientSocket *client, struc } printf_mysql_query("UPDATE `channels` SET `channel_maxflood` = '%d', `channel_floodtime` = '%d' WHERE `channel_id` = '%d' ", amount, timep, chan->channel_id); sprintf(cvalue, "%d:%d", amount, timep); + if(chan->spam_settings) { + chan->spam_settings->flood_amount = amount; + chan->spam_settings->flood_time = timep; + } } return cvalue; } @@ -532,6 +548,10 @@ static char* neonspam_cmd_setjoinsensibility(struct ClientSocket *client, struct } printf_mysql_query("UPDATE `channels` SET `channel_maxjoin` = '%d', `channel_jointime` = '%d' WHERE `channel_id` = '%d' ", amount, timep, chan->channel_id); sprintf(cvalue, "%d:%d", amount, timep); + if(chan->spam_settings) { + chan->spam_settings->join_amount = amount; + chan->spam_settings->join_time = timep; + } } return cvalue; }