2018-02-16 14:17:52 +01:00
|
|
|
/**
|
|
|
|
* 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
|
2018-02-16 14:44:47 +01:00
|
|
|
if(_.includes(this.config.exempt, event.user)) return;
|
2018-02-16 15:22:16 +01:00
|
|
|
|
|
|
|
var message;
|
2018-02-16 15:36:56 +01:00
|
|
|
var naughty = false;
|
2018-02-16 15:22:16 +01:00
|
|
|
|
|
|
|
// Check distinctive spam content match
|
2018-02-16 15:29:17 +01:00
|
|
|
if(_.any(this.config.advert_content, function(spam) { return event.message.indexOf(spam) != -1; })) {
|
2018-02-16 15:22:16 +01:00
|
|
|
message = dbot.t('spamcont_act', {
|
|
|
|
'user': event.user,
|
|
|
|
'channel': event.channel,
|
|
|
|
'action': this.config.action
|
|
|
|
});
|
2018-02-16 15:29:17 +01:00
|
|
|
naughty = true;
|
2018-02-16 15:22:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Name highlight spam
|
2018-02-16 14:37:26 +01:00
|
|
|
if(_.filter(event.message.split(' '), function(word) { return _.has(event.channel.nicks, word); }).length > this.config.sensitivity) {
|
2018-02-16 15:22:16 +01:00
|
|
|
message = dbot.t('namespam_act', {
|
2018-02-16 14:17:52 +01:00
|
|
|
'user': event.user,
|
|
|
|
'channel': event.channel,
|
|
|
|
'action': this.config.action,
|
|
|
|
'sensitivity': this.config.sensitivity
|
|
|
|
});
|
2018-02-16 15:29:17 +01:00
|
|
|
naughty = true;
|
2018-02-16 15:22:16 +01:00
|
|
|
}
|
2018-02-16 14:17:52 +01:00
|
|
|
|
2018-02-16 15:22:16 +01:00
|
|
|
if(naughty) {
|
2018-02-16 14:17:52 +01:00
|
|
|
switch(this.config.action) {
|
2018-02-16 14:30:56 +01:00
|
|
|
case 'kickban':
|
2018-02-16 14:19:12 +01:00
|
|
|
dbot.api.kick.ban(event.server, event.host, event.channel);
|
|
|
|
dbot.api.kick.kick(event.server, event.user, message);
|
2018-02-16 14:17:52 +01:00
|
|
|
break;
|
2018-02-16 14:30:56 +01:00
|
|
|
case 'kill':
|
2018-02-16 14:17:52 +01:00
|
|
|
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';
|
2018-02-16 15:36:56 +01:00
|
|
|
|
|
|
|
this.commands = {
|
|
|
|
'~add_spamkill': function(event) {
|
|
|
|
this.config.advert_content.push(event.params.slice(1).join(' '))
|
|
|
|
event.reply('Users daring to utter the above to be classified as spam.');
|
|
|
|
},
|
|
|
|
|
|
|
|
'~del_spamkill': function(event) {
|
|
|
|
this.config.advert_content = _.without(this.config.advert_content, event.params.slice(1).join(' '));
|
|
|
|
event.reply('Users will no longer be killed for this utterance.');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
_.each(this.commands, function(c) {
|
|
|
|
c.access = 'moderator';
|
|
|
|
});
|
2018-02-16 14:17:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return new kill_namespam(dbot);
|
|
|
|
};
|