From: NurPech Date: Sat, 6 Apr 2013 16:00:53 +0000 (+0200) Subject: added punishment for badword detection X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=c6a3b018f197412620d9c587cecd02d90043581d added punishment for badword detection --- diff --git a/src/spamserv.c b/src/spamserv.c index 27cabfb..fadcfa4 100644 --- a/src/spamserv.c +++ b/src/spamserv.c @@ -152,6 +152,7 @@ static const struct message_entry msgtab[] = { #define SSMSG_WARNING_2 "You are violating the network rules" #define SSMSG_WARNING_RULES "%s is against the network rules. Read the network rules at %s" #define SSMSG_WARNING_RULES_2 "You are violating the network rules. Read the network rules at %s" +#define SSMSG_BADWORD_DETECTED "Your message contained a forbidden word." static struct { @@ -1877,6 +1878,45 @@ spamserv_punish(struct chanNode *channel, struct userNode *user, time_t expires, KickChannelUser(user, channel, spamserv, reason); } +static void +spamserv_detected_badword(struct userNode *user, struct chanNode *chan, struct badword *badword) +{ + char *hostmask; + char *reason = SSMSG_BADWORD_DETECTED; + char mask[IRC_NTOP_MAX_SIZE+3] = { '*', '@', '\0' }; + switch(badword->action) { + case BADACTION_BAN: + hostmask = generate_hostmask(user, GENMASK_STRICT_HOST | GENMASK_ANY_IDENT); + sanitize_ircmask(hostmask); + if(chan->channel_info) { + //registered channel + add_channel_ban(chan->channel_info, hostmask, spamserv->nick, now, now, now + spamserv_conf.long_ban_duration, reason); + } + struct mod_chanmode change; + mod_chanmode_init(&change); + change.argc = 1; + change.args[0].mode = MODE_BAN; + change.args[0].u.hostmask = hostmask; + mod_chanmode_announce(spamserv, chan, &change); + free(hostmask); + + case BADACTION_KICK: + if(GetUserMode(chan, user)) + KickChannelUser(user, chan, spamserv, reason); + break; + case BADACTION_KILL: + DelUser(user, spamserv, 1, reason); + break; + case BADACTION_GLINE: + irc_ntop(mask + 2, sizeof(mask) - 2, &user->ip); + gline_add(spamserv->nick, mask, spamserv_conf.gline_duration, reason, now, now, 0, 1); + break; + default: + //error? + break; + } +} + void spamserv_channel_message(struct chanNode *channel, struct userNode *user, char *text) { @@ -2035,6 +2075,15 @@ spamserv_channel_message(struct chanNode *channel, struct userNode *user, char * } } + dict_iterator_t it; + + for (it = dict_first(cInfo->badwords); it; it = iter_next(it)) { + struct badword *badword = iter_data(it); + if(match_ircglob(text, badword->badword_mask)) { + spamserv_detected_badword(user, channel, badword); + } + } + if(CHECK_ADV(cInfo) && check_advertising(cInfo, text)) { if(CHECK_ADV_WARNED(uInfo))