From 56d12bd649761c9c40dc56617fd4971c1f4fef33 Mon Sep 17 00:00:00 2001 From: reality Date: Fri, 16 Feb 2018 14:22:16 +0000 Subject: [PATCH] also add check for distinctive spam content --- modules/kill_namespam/config.json | 5 ++++- modules/kill_namespam/kill_namespam.js | 17 ++++++++++++++++- modules/kill_namespam/strings.json | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/modules/kill_namespam/config.json b/modules/kill_namespam/config.json index d73efe8..dc9d0f9 100644 --- a/modules/kill_namespam/config.json +++ b/modules/kill_namespam/config.json @@ -1,5 +1,8 @@ { "action": "kill", "sensitivity": 10, - "exempt": [] + "exempt": [], + "advert_content": [ + "________ ______" + ] } diff --git a/modules/kill_namespam/kill_namespam.js b/modules/kill_namespam/kill_namespam.js index 21fd9f2..dd7cbb0 100644 --- a/modules/kill_namespam/kill_namespam.js +++ b/modules/kill_namespam/kill_namespam.js @@ -10,14 +10,29 @@ var kill_namespam = function(dbot) { this.listener = function(event) { if(event.channel == event.user) return; // return if pm if(_.includes(this.config.exempt, event.user)) return; + + var message; + + // Check distinctive spam content match + if(_.any(this.config.advert_content, function(spam) { return event.message.match(spam); })) { + message = dbot.t('spamcont_act', { + 'user': event.user, + 'channel': event.channel, + 'action': this.config.action + }); + } + + // Name highlight spam if(_.filter(event.message.split(' '), function(word) { return _.has(event.channel.nicks, word); }).length > this.config.sensitivity) { - var message = dbot.t('namespam_act', { + message = dbot.t('namespam_act', { 'user': event.user, 'channel': event.channel, 'action': this.config.action, 'sensitivity': this.config.sensitivity }); + } + if(naughty) { switch(this.config.action) { case 'kickban': dbot.api.kick.ban(event.server, event.host, event.channel); diff --git a/modules/kill_namespam/strings.json b/modules/kill_namespam/strings.json index 5965bbd..99b3624 100644 --- a/modules/kill_namespam/strings.json +++ b/modules/kill_namespam/strings.json @@ -1,5 +1,8 @@ { "namespam_act": { "en": "{user} triggered nickname hilight anti-spam (greater than {sensitivity}). Action: {action}." + }, + "spamcont_act": { + "en": "{user} triggered advertising anti-spam (content). Action: {action}" } }