diff --git a/modules/kick/kick.js b/modules/kick/kick.js index a8620d1..f65ba9f 100644 --- a/modules/kick/kick.js +++ b/modules/kick/kick.js @@ -31,6 +31,10 @@ var kick = function(dbot) { dbot.instance.connections[server].send('KICK ' + channel + ' ' + user + ' :' + msg); }, + 'kill': function(server, user, reason) { + dbot.instance.connections[server].send('kill ' + user + ' :' + reason); + }, + 'unban': function(server, host, channel) { // TODO: Wrest control from chanserv //dbot.say(server, this.config.chanserv, 'unban ' + channel + ' *!*@' + host); diff --git a/modules/kill_namespam/config.json b/modules/kill_namespam/config.json new file mode 100644 index 0000000..63cf774 --- /dev/null +++ b/modules/kill_namespam/config.json @@ -0,0 +1,4 @@ +{ + "action": "kill", + "sensitivity": 10 +} diff --git a/modules/kill_namespam/kill_namespam.js b/modules/kill_namespam/kill_namespam.js new file mode 100644 index 0000000..b2ca105 --- /dev/null +++ b/modules/kill_namespam/kill_namespam.js @@ -0,0 +1,38 @@ +/** + * Module name: kill_namespam + * Description: destroy those wot hilight too many nicks at once . usually + * advertising their rubbish irc server (do not) + */ + +var _ = require('underscore')._; + +var kill_namespam = function(dbot) { + this.listener = function(event) { + if(event.channel == event.user) return; // return if pm + if(_.filter(event.message.split(' '), function(word) { return _.has(event.channel.nicks, word); }.length > this.config.sensitivity) { + var message = dbot.t('namespam_act', { + 'user': event.user, + 'channel': event.channel, + 'action': this.config.action, + 'sensitivity': this.config.sensitivity + }); + + switch(this.config.action) { + case kickban: + dbot.api.kick.ban(event.server, event.host, event.channel) + dbot.api.kick.kick(event.server, event.user, 'Nick highlight spam.' + break; + case kill: + dbot.api.kick.kill(event.server, event.user, message); + default: break; + } + + dbot.api.report.notify('spam', event.server, event.user, event.channel, message, event.host, event.user); + } + }.bind(this); + this.on = 'PRIVMSG'; +}; + +exports.fetch = function(dbot) { + return new kill_namespam(dbot); +};