-/* event_neonspam_chanmsg.c - NeonServ v5.1
+/* event_neonspam_chanmsg.c - NeonServ v5.2
* Copyright (C) 2011 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define SPAMSERV_CHECK_IGNORE 0
-#define SPAMSERV_CHECK_WARN 1
-#define SPAMSERV_CHECK_PUNISH 2
-
-#define SPAMSERV_MSG_SPAM "Spamming"
-#define SPAMSERV_MSG_FLOOD "Flooding the channel/network"
-#define SPAMSERV_MSG_ADV "Advertising"
-#define SPAMSERV_MSG_JOINFLOOD "Join flooding the channel"
-#define SPAMSERV_MSG_WARNING "%s is against the network rules"
-
static int neonspam_spamscan(struct NeonSpamSettings *settings, struct ChanUser *chanuser, char *message);
static int neonspam_floodscan(struct NeonSpamSettings *settings, struct ChanUser *chanuser);
+static int neonspam_botnetscan(struct ClientSocket *client, struct NeonSpamSettings *settings, struct ChanUser *chanuser, char *message);
+static int neonspam_capsscan(struct NeonSpamSettings *settings, struct ChanUser *chanuser, char *message);
+static int neonspam_digitscan(struct NeonSpamSettings *settings, struct ChanUser *chanuser, char *message);
static USERAUTH_CALLBACK(neonspam_event_chanmsg_nick_lookup);
-static void neonspam_event_chanmsg_punish(struct ClientSocket *client, struct ChanUser *chanuser, struct NeonSpamSettings *settings, int action, char *reason, char *reaction);
+static void neonspam_event_chanmsg_punish(struct ClientSocket *client, struct ChanUser *chanuser, struct NeonSpamSettings *settings, unsigned int warn, unsigned int punish);
struct neonspam_event_chanmsg_cache {
struct ClientSocket *client;
struct ChanUser *chanuser;
struct NeonSpamSettings *settings;
- int action;
- char *reason;
- char *reaction;
+ unsigned int warn;
+ unsigned int punish;
};
+
+
static void neonspam_event_chanmsg(struct UserNode *user, struct ChanNode *chan, char *message) {
struct ClientSocket *client = getChannelBot(chan, BOTID);
if(!client) return; //we can't "see" this event
struct NeonSpamSettings *settings = chan->spam_settings;
struct ChanUser *chanuser = getChanUser(user, chan);
if(!settings || !chanuser) return;
-
- //ignore messages from ops/voices if we ignore them
- if(!(settings->flags & SPAMSETTINGS_SCANOPS) && (chanuser->flags & CHANUSERFLAG_OPPED)) return;
- if(!(settings->flags & SPAMSETTINGS_SCANVOICE) && (chanuser->flags & CHANUSERFLAG_VOICED)) return;
- if(settings->exceptlevel == 0) return;
+ #define NEONSPAM_CHANMSG_DO_SCANOPS(FLAG) ((settings->flags & FLAG) || !(chanuser->flags & CHANUSERFLAG_OPPED))
+ #define NEONSPAM_CHANMSG_DO_SCANVOICE(FLAG) ((settings->flags & FLAG) || !(chanuser->flags & CHANUSERFLAG_VOICED))
+ #define NEONSPAM_CHANMSG_DO_EXCEPT(INDEX) (settings->exceptlevel[INDEX] != 0)
+ #define NEONSPAM_CHANMSG_NEED_WHO(INDEX) (settings->exceptlevel[INDEX] != 501)
//scan the message
int result = 0;
- int action = SPAMSERV_CHECK_IGNORE;
- char reason[MAXLEN];
- char *reaction = NULL;
- if(action != SPAMSERV_CHECK_PUNISH && (settings->flags & SPAMSETTINGS_SPAMSCAN)) {
+ unsigned int warn = 0;
+ unsigned int punish = 0;
+ int needwho = 0;
+ if((settings->flags & SPAMSETTINGS_SPAMSCAN) && NEONSPAM_CHANMSG_DO_SCANOPS(SPAMSETTINGS_SPAMSCAN_OPS) && NEONSPAM_CHANMSG_DO_SCANVOICE(SPAMSETTINGS_SPAMSCAN_VOICE) && NEONSPAM_CHANMSG_DO_EXCEPT(SPAMSETTINGS_SPAMEXCINDEX)) {
result = neonspam_spamscan(settings, chanuser, message);
switch(result) {
case SPAMSERV_CHECK_IGNORE:
break;
case SPAMSERV_CHECK_WARN:
- if(action == SPAMSERV_CHECK_IGNORE) {
- action = result;
- sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_SPAM);
- }
+ warn |= SPAMSETTINGS_SPAMSCAN;
+ if(NEONSPAM_CHANMSG_NEED_WHO(SPAMSETTINGS_SPAMEXCINDEX))
+ needwho = 1;
break;
case SPAMSERV_CHECK_PUNISH:
- if(action != SPAMSERV_CHECK_PUNISH) {
- action = result;
- sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_SPAM);
- reaction = "channel_repeatreaction";
- }
+ punish |= SPAMSETTINGS_SPAMSCAN;
+ if(NEONSPAM_CHANMSG_NEED_WHO(SPAMSETTINGS_SPAMEXCINDEX))
+ needwho = 1;
break;
}
}
- if(action != SPAMSERV_CHECK_PUNISH && (settings->flags & SPAMSETTINGS_FLOODSCAN)) {
+ if((settings->flags & SPAMSETTINGS_FLOODSCAN) && NEONSPAM_CHANMSG_DO_SCANOPS(SPAMSETTINGS_FLOODSCAN_OPS) && NEONSPAM_CHANMSG_DO_SCANVOICE(SPAMSETTINGS_FLOODSCAN_VOICE) && NEONSPAM_CHANMSG_DO_EXCEPT(SPAMSETTINGS_FLOODEXCINDEX)) {
result = neonspam_floodscan(settings, chanuser);
switch(result) {
case SPAMSERV_CHECK_IGNORE:
break;
case SPAMSERV_CHECK_WARN:
- if(action == SPAMSERV_CHECK_IGNORE) {
- action = result;
- sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_SPAM);
- }
+ warn |= SPAMSETTINGS_FLOODSCAN;
+ if(NEONSPAM_CHANMSG_NEED_WHO(SPAMSETTINGS_FLOODEXCINDEX))
+ needwho = 1;
break;
case SPAMSERV_CHECK_PUNISH:
- if(action != SPAMSERV_CHECK_PUNISH) {
- action = result;
- sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_SPAM);
- reaction = "channel_floodreaction";
- }
+ punish |= SPAMSETTINGS_FLOODSCAN;
+ if(NEONSPAM_CHANMSG_NEED_WHO(SPAMSETTINGS_FLOODEXCINDEX))
+ needwho = 1;
+ break;
+ }
+ }
+ if((settings->flags & SPAMSETTINGS_BOTNETSCAN) && NEONSPAM_CHANMSG_DO_SCANOPS(SPAMSETTINGS_BOTNETSCAN_OPS) && NEONSPAM_CHANMSG_DO_SCANVOICE(SPAMSETTINGS_BOTNETSCAN_VOICE)) {
+ result = neonspam_botnetscan(client, settings, chanuser, message);
+ switch(result) {
+ case SPAMSERV_CHECK_DEAD:
+ return;
+ case SPAMSERV_CHECK_IGNORE:
+ break;
+ }
+ }
+ if((settings->flags & SPAMSETTINGS_CAPSSCAN) && NEONSPAM_CHANMSG_DO_SCANOPS(SPAMSETTINGS_CAPSSCAN_OPS) && NEONSPAM_CHANMSG_DO_SCANVOICE(SPAMSETTINGS_CAPSSCAN_VOICE) && NEONSPAM_CHANMSG_DO_EXCEPT(SPAMSETTINGS_CAPSEXCINDEX)) {
+ result = neonspam_capsscan(settings, chanuser, message);
+ switch(result) {
+ case SPAMSERV_CHECK_IGNORE:
+ break;
+ case SPAMSERV_CHECK_WARN:
+ warn |= SPAMSETTINGS_CAPSSCAN;
+ if(NEONSPAM_CHANMSG_NEED_WHO(SPAMSETTINGS_CAPSEXCINDEX))
+ needwho = 1;
+ break;
+ case SPAMSERV_CHECK_PUNISH:
+ punish |= SPAMSETTINGS_CAPSSCAN;
+ if(NEONSPAM_CHANMSG_NEED_WHO(SPAMSETTINGS_CAPSEXCINDEX))
+ needwho = 1;
+ break;
+ }
+ }
+ if((settings->flags & SPAMSETTINGS_DIGITSCAN) && NEONSPAM_CHANMSG_DO_SCANOPS(SPAMSETTINGS_DIGITSCAN_OPS) && NEONSPAM_CHANMSG_DO_SCANVOICE(SPAMSETTINGS_DIGITSCAN_VOICE) && NEONSPAM_CHANMSG_DO_EXCEPT(SPAMSETTINGS_DIGITEXCINDEX)) {
+ result = neonspam_digitscan(settings, chanuser, message);
+ switch(result) {
+ case SPAMSERV_CHECK_IGNORE:
+ break;
+ case SPAMSERV_CHECK_WARN:
+ warn |= SPAMSETTINGS_DIGITSCAN;
+ if(NEONSPAM_CHANMSG_NEED_WHO(SPAMSETTINGS_DIGITEXCINDEX))
+ needwho = 1;
+ break;
+ case SPAMSERV_CHECK_PUNISH:
+ punish |= SPAMSETTINGS_DIGITSCAN;
+ if(NEONSPAM_CHANMSG_NEED_WHO(SPAMSETTINGS_DIGITEXCINDEX))
+ needwho = 1;
break;
}
}
//some other checks?
- if(action != SPAMSERV_CHECK_IGNORE) {
+ if(warn || punish) {
//whois the user to check against exceptlevel
- if((user->flags & USERFLAG_ISAUTHED) || settings->exceptlevel == 501) {
- neonspam_event_chanmsg_punish(client, chanuser, settings, action, reason, reaction);
+ if(!needwho || (user->flags & USERFLAG_ISAUTHED)) {
+ neonspam_event_chanmsg_punish(client, chanuser, settings, warn, punish);
} else {
struct neonspam_event_chanmsg_cache *cache = malloc(sizeof(*cache));
if (!cache) {
cache->client = client;
cache->chanuser = chanuser;
cache->settings = settings;
- cache->action = action;
- cache->reason = strdup(reason);
- cache->reaction = reaction;
+ cache->warn = warn;
+ cache->punish = punish;
get_userauth(user, neonspam_event_chanmsg_nick_lookup, cache);
}
}
+ #undef NEONSPAM_CHANMSG_DO_SCANOPS
+ #undef NEONSPAM_CHANMSG_DO_SCANVOICE
+ #undef NEONSPAM_CHANMSG_DO_EXCEPT
+ #undef NEONSPAM_CHANMSG_NEED_WHO
}
static USERAUTH_CALLBACK(neonspam_event_chanmsg_nick_lookup) {
struct neonspam_event_chanmsg_cache *cache = data;
- neonspam_event_chanmsg_punish(cache->client, cache->chanuser, cache->settings, cache->action, cache->reason, cache->reaction);
- free(cache->reason);
+ neonspam_event_chanmsg_punish(cache->client, cache->chanuser, cache->settings, cache->warn, cache->punish);
free(cache);
}
-static void neonspam_event_chanmsg_punish(struct ClientSocket *client, struct ChanUser *chanuser, struct NeonSpamSettings *settings, int action, char *reason, char *reaction) {
+static void neonspam_event_chanmsg_punish(struct ClientSocket *client, struct ChanUser *chanuser, struct NeonSpamSettings *settings, unsigned int warn, unsigned int punish) {
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ loadChannelSettings(chanuser->chan);
int uaccess = 0;
if(chanuser->user->flags & USERFLAG_ISAUTHED)
uaccess = getChannelAccess(chanuser->user, chanuser->chan, 0);
- if(uaccess >= settings->exceptlevel) return;
- if(action == SPAMSERV_CHECK_WARN) {
- reply(client, chanuser->user, "%s", reason);
- } else if(action == SPAMSERV_CHECK_PUNISH) {
- MYSQL_RES *res;
- MYSQL_ROW row;
- loadChannelSettings(chanuser->chan);
- printf_mysql_query("SELECT `%s` FROM `channels` WHERE `channel_id` = '%d'", reaction, chanuser->chan->channel_id);
+ char reason[MAXLEN];
+ reason[0] = '\0';
+ int punishment = 0;
+ int punish_time = 0;
+ if(!punishment && (punish & SPAMSETTINGS_SPAMSCAN) && settings->exceptlevel[SPAMSETTINGS_SPAMEXCINDEX] > uaccess) {
+ printf_mysql_query("SELECT `channel_spam_reaction`, `channel_spam_reaction_duration` FROM `channels` WHERE `channel_id` = '%d'", chanuser->chan->channel_id);
+ res = mysql_use();
+ row = mysql_fetch_row(res);
+ if(!row[0]) {
+ printf_mysql_query("SELECT `channel_spam_reaction`, `channel_spam_reaction_duration` FROM `channels` WHERE `channel_name` = 'defaults'");
+ res = mysql_use();
+ row = mysql_fetch_row(res);
+ }
+ sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_SPAM);
+ punishment = atoi(row[0]) + 1;
+ punish_time = atoi(row[1]);
+ }
+ if(!punishment && (punish & SPAMSETTINGS_FLOODSCAN) && settings->exceptlevel[SPAMSETTINGS_FLOODEXCINDEX] > uaccess) {
+ printf_mysql_query("SELECT `channel_flood_reaction`, `channel_flood_reaction_duration` FROM `channels` WHERE `channel_id` = '%d'", chanuser->chan->channel_id);
res = mysql_use();
row = mysql_fetch_row(res);
- int duration = 0;
+ if(!row[0]) {
+ printf_mysql_query("SELECT `channel_flood_reaction`, `channel_flood_reaction_duration` FROM `channels` WHERE `channel_name` = 'defaults'");
+ res = mysql_use();
+ row = mysql_fetch_row(res);
+ }
+ sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_FLOOD);
+ punishment = atoi(row[0]) + 1;
+ punish_time = atoi(row[1]);
+ }
+ if(!punishment && (punish & SPAMSETTINGS_CAPSSCAN) && settings->exceptlevel[SPAMSETTINGS_CAPSEXCINDEX] > uaccess) {
+ printf_mysql_query("SELECT `channel_caps_reaction`, `channel_caps_reaction_duration` FROM `channels` WHERE `channel_id` = '%d'", chanuser->chan->channel_id);
+ res = mysql_use();
+ row = mysql_fetch_row(res);
+ if(!row[0]) {
+ printf_mysql_query("SELECT `channel_caps_reaction`, `channel_caps_reaction_duration` FROM `channels` WHERE `channel_name` = 'defaults'");
+ res = mysql_use();
+ row = mysql_fetch_row(res);
+ }
+ sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_CAPS);
+ punishment = atoi(row[0]) + 1;
+ punish_time = atoi(row[1]);
+ }
+ if(!punishment && (punish & SPAMSETTINGS_DIGITSCAN) && settings->exceptlevel[SPAMSETTINGS_DIGITEXCINDEX] > uaccess) {
+ printf_mysql_query("SELECT `channel_digit_reaction`, `channel_digit_reaction_duration` FROM `channels` WHERE `channel_id` = '%d'", chanuser->chan->channel_id);
+ res = mysql_use();
+ row = mysql_fetch_row(res);
+ if(!row[0]) {
+ printf_mysql_query("SELECT `channel_digit_reaction`, `channel_digit_reaction_duration` FROM `channels` WHERE `channel_name` = 'defaults'");
+ res = mysql_use();
+ row = mysql_fetch_row(res);
+ }
+ sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_DIGIT);
+ punishment = atoi(row[0]) + 1;
+ punish_time = atoi(row[1]);
+ }
+ if(!punishment && (warn & SPAMSETTINGS_SPAMSCAN) && settings->exceptlevel[SPAMSETTINGS_SPAMEXCINDEX] > uaccess) {
+ sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_SPAM);
+ }
+ if(!punishment && (warn & SPAMSETTINGS_FLOODSCAN) && settings->exceptlevel[SPAMSETTINGS_FLOODEXCINDEX] > uaccess) {
+ sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_FLOOD);
+ }
+ if(!punishment && (warn & SPAMSETTINGS_CAPSSCAN) && settings->exceptlevel[SPAMSETTINGS_CAPSEXCINDEX] > uaccess) {
+ sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_CAPS);
+ }
+ if(!punishment && (warn & SPAMSETTINGS_DIGITSCAN) && settings->exceptlevel[SPAMSETTINGS_DIGITEXCINDEX] > uaccess) {
+ sprintf(reason, SPAMSERV_MSG_WARNING, SPAMSERV_MSG_DIGIT);
+ }
+ if(punishment) {
char banmaskBuf[NICKLEN+USERLEN+HOSTLEN+3];
char *banmask = NULL;
- switch (atoi(row[0])) {
- case 2: //TIMEBAN: 3min
- duration = 180;
+ switch (punishment) {
case 3: //TIMEBAN: 1h
- if(!duration)
- duration = 3600;
banmask = generate_banmask(chanuser->user, banmaskBuf);
- printf_mysql_query("INSERT INTO `bans` (`ban_channel`, `ban_mask`, `ban_triggered`, `ban_timeout`, `ban_owner`, `ban_reason`) VALUES ('%d', '%s', UNIX_TIMESTAMP(), '%lu', '%d', '%s')", chanuser->chan->channel_id, escape_string(banmask), (unsigned long) (time(0) + duration), 0, escape_string(reason));
- int banid = (int) mysql_insert_id(mysql_conn);
- char nameBuf[MAXLEN];
- char banidBuf[20];
- sprintf(nameBuf, "ban_%d", banid);
- sprintf(banidBuf, "%d", banid);
- timeq_add_name(nameBuf, duration, channel_ban_timeout, strdup(banidBuf));
- case 1: //KICKBAN
+ printf_mysql_query("INSERT INTO `bans` (`ban_channel`, `ban_mask`, `ban_triggered`, `ban_timeout`, `ban_owner`, `ban_reason`) VALUES ('%d', '%s', UNIX_TIMESTAMP(), '%lu', '%d', '%s')", chanuser->chan->channel_id, escape_string(banmask), (unsigned long) (punish_time ? (time(0) + punish_time) : 0), 0, escape_string(reason));
+ if(punish_time) {
+ int banid = (int) mysql_insert_id(mysql_conn);
+ char nameBuf[MAXLEN];
+ char banidBuf[20];
+ sprintf(nameBuf, "ban_%d", banid);
+ sprintf(banidBuf, "%d", banid);
+ timeq_add_name(nameBuf, punish_time, channel_ban_timeout, strdup(banidBuf));
+ }
+ case 2: //KICKBAN
if(!banmask)
banmask = generate_banmask(chanuser->user, banmaskBuf);
putsock(client, "MODE %s +b %s", chanuser->chan->name, banmask);
- case 0: //KICK
+ case 1: //KICK
putsock(client, "KICK %s %s :%s", chanuser->chan->name, chanuser->user->nick, reason);
break;
}
- }
+ } else if(*reason)
+ reply(client, chanuser->user, "%s", reason);
}
static int neonspam_spamscan(struct NeonSpamSettings *settings, struct ChanUser *chanuser, char *message) {
int last_update = time(0) - chanuser->spamnode->last_penalty_update;
if(last_update) {
if(last_update < MAX_FLOOD_TIME && chanuser->spamnode->floodpenalty) {
- chanuser->spamnode->floodpenalty -= last_update * (MAX_FLOOD_TIME / settings->flood_time);
+ chanuser->spamnode->floodpenalty -= last_update * (MAX_FLOOD_TIME / settings->sensibility_time[SPAMSETTINGS_FLOODSENINDEX]);
if(chanuser->spamnode->floodpenalty < 0)
chanuser->spamnode->floodpenalty = 0;
} else
if(!chanuser->spamnode)
createSpamNode(chanuser);
int messages_pending = neonspam_update_penalty(settings, chanuser, 1);
- if(messages_pending == settings->flood_amount)
+ if(messages_pending == settings->sensibility_amount[SPAMSETTINGS_FLOODSENINDEX])
return SPAMSERV_CHECK_WARN;
- else if(messages_pending > settings->flood_amount)
+ else if(messages_pending > settings->sensibility_amount[SPAMSETTINGS_FLOODSENINDEX])
return SPAMSERV_CHECK_PUNISH;
else
return SPAMSERV_CHECK_IGNORE;
}
+static int neonspam_botnetscan(struct ClientSocket *client, struct NeonSpamSettings *settings, struct ChanUser *chanuser, char *message) {
+ //crc32 hash of the message
+ unsigned long msghash = crc32(message);
+ if((time(0) - settings->lastmsg_time) > BOTNETSCAN_TIME || settings->lastmsg != msghash) {
+ int i;
+ for(i = 0; i < BOTNETSCAN_USERS; i++) {
+ if(settings->botnicks[i]) {
+ free(settings->botnicks[i]);
+ settings->botnicks[i] = NULL;
+ }
+ }
+ settings->flags &= ~SPAMSETTINGS_KICKEDBOTQUEUE;
+ settings->lastmsg = msghash;
+ } else if(settings->lastmsg == msghash) {
+ int i;
+ for(i = 0; i < BOTNETSCAN_USERS; i++) {
+ if(!settings->botnicks[i]) {
+ settings->botnicks[i] = strdup(chanuser->user->nick);
+ break;
+ } else if(!stricmp(chanuser->user->nick, settings->botnicks[i])) {
+ return SPAMSERV_CHECK_IGNORE;
+ }
+ }
+ if(i == BOTNETSCAN_USERS) {
+ //BOTNETSCAN_USERS exceeded
+ if(!(settings->flags & SPAMSETTINGS_KICKEDBOTQUEUE)) {
+ for(i = 0; i < BOTNETSCAN_USERS; i++) {
+ putsock(client, "KICK %s %s :%s", chanuser->chan->name, settings->botnicks[i], SPAMSERV_MSG_BOTNET);
+ }
+ settings->flags |= SPAMSETTINGS_KICKEDBOTQUEUE;
+ }
+ putsock(client, "KICK %s %s :%s", chanuser->chan->name, chanuser->user->nick, SPAMSERV_MSG_BOTNET);
+ return SPAMSERV_CHECK_DEAD;
+ }
+ }
+ settings->lastmsg_time = time(0);
+ return SPAMSERV_CHECK_IGNORE;
+}
+
+static int neonspam_capsscan(struct NeonSpamSettings *settings, struct ChanUser *chanuser, char *message) {
+ int caps = 0, msglen = strlen(message);
+ int i;
+ if(msglen <= 4) return SPAMSERV_CHECK_IGNORE;
+ for(i = 0; i < msglen; i++) {
+ if(isupper(message[i])) caps++;
+ }
+ caps = 100*caps/msglen;
+ if(caps >= settings->percent[SPAMSETTINGS_CAPSPERCENTINDEX]) {
+ if(!chanuser->spamnode)
+ createSpamNode(chanuser);
+ if(chanuser->spamnode->flags & NEONSPAMNODE_FLAG_CAPSSCAN_WARNED)
+ return SPAMSERV_CHECK_PUNISH;
+ else {
+ chanuser->spamnode->flags |= NEONSPAMNODE_FLAG_CAPSSCAN_WARNED;
+ return SPAMSERV_CHECK_WARN;
+ }
+ }
+ return SPAMSERV_CHECK_IGNORE;
+}
+
+static int neonspam_digitscan(struct NeonSpamSettings *settings, struct ChanUser *chanuser, char *message) {
+ int digit = 0, msglen = strlen(message);
+ int i;
+ if(msglen <= 4) return SPAMSERV_CHECK_IGNORE;
+ for(i = 0; i < msglen; i++) {
+ if(isdigit(message[i])) digit++;
+ }
+ digit = 100*digit/msglen;
+ if(digit >= settings->percent[SPAMSETTINGS_DIGITPERCENTINDEX]) {
+ if(!chanuser->spamnode)
+ createSpamNode(chanuser);
+ if(chanuser->spamnode->flags & NEONSPAMNODE_FLAG_DIGITSCAN_WARNED)
+ return SPAMSERV_CHECK_PUNISH;
+ else {
+ chanuser->spamnode->flags |= NEONSPAMNODE_FLAG_DIGITSCAN_WARNED;
+ return SPAMSERV_CHECK_WARN;
+ }
+ }
+ return SPAMSERV_CHECK_IGNORE;
+}