3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-26 12:42:51 +01:00
dbot/modules/kill_namespam/kill_namespam.js

124 lines
4.5 KiB
JavaScript
Raw Normal View History

/**
* 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) {
2018-03-01 15:15:35 +01:00
this.saveConfig = function() { // eugh
2018-03-01 15:21:09 +01:00
dbot.customConfig.modules.kill_namespam = this.config;
2018-03-01 15:15:35 +01:00
dbot.modules.admin.internalAPI.saveConfig();
}.bind(this);
this.listener = function(event) {
2018-03-01 14:41:59 +01:00
// Here we listen for atropos
if(event.channel == this.config.cliconn_channel) {
if(event.message.match('▶')) {
var matchedPattern = _.find(this.config.cliconn_patterns, function(p) { return event.message.match(p); })
if(matchedPattern) {
2018-03-01 14:53:02 +01:00
var ip = event.message.split(' ')[1]
2018-03-01 14:41:59 +01:00
// Alternatively you can just do dbot.api.kick.kill(event.server, event.user, message);
2018-03-01 14:57:45 +01:00
dbot.say(event.server, 'operserv', 'akill add *@'+ ip +' !P Naughty Nelly Auto-kill v6.2. Matched pattern: /'+ matchedPattern +'/');
2018-03-01 14:41:59 +01:00
var msg = dbot.t('clikill_act', {
'ip': ip,
'pattern': matchedPattern
});
event.reply(msg);
2018-03-01 14:57:45 +01:00
dbot.api.report.notify('autokill', event.server, event.rUser,
2018-03-01 14:41:59 +01:00
dbot.config.servers[event.server].admin_channel, msg, ip, ip);
}
}
}
// This is the namespam
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;
var message;
2018-02-16 15:36:56 +01:00
var naughty = false;
// 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; })) {
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;
}
// Name highlight spam
if(_.filter(event.message.split(' '), function(word) { return _.has(event.channel.nicks, word); }).length > this.config.sensitivity) {
message = dbot.t('namespam_act', {
'user': event.user,
'channel': event.channel,
'action': this.config.action,
'sensitivity': this.config.sensitivity
});
2018-02-16 15:29:17 +01:00
naughty = true;
}
if(naughty) {
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);
break;
2018-02-16 14:30:56 +01:00
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';
2018-02-16 15:36:56 +01:00
this.commands = {
'~add_spamkill': function(event) {
this.config.advert_content.push(event.params.slice(1).join(' '))
2018-03-01 15:15:35 +01:00
this.saveConfig();
2018-02-16 15:36:56 +01:00
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(' '));
2018-03-01 15:15:35 +01:00
this.saveConfig();
2018-02-16 15:36:56 +01:00
event.reply('Users will no longer be killed for this utterance.');
2018-03-01 14:41:59 +01:00
},
'~add_clikill': function(event) {
var pattern = event.params.slice(1).join(' ');
this.config.cliconn_patterns.push(pattern);
2018-03-01 15:15:35 +01:00
this.saveConfig();
2018-03-01 14:41:59 +01:00
event.reply('Client connection notices matching pattern /'+ pattern +'/ shall henceforth get rekt.');
},
'~del_clikill': function(event) {
var pattern = event.params.slice(1).join(' ');
this.config.cliconn_patterns = _.without(this.config.cliconn_patterns, pattern);
2018-03-01 15:15:35 +01:00
this.saveConfig();
2018-03-01 14:41:59 +01:00
event.reply('Client connection notices matching pattern /'+ pattern +'/ will no longer get rekt.');
},
'~list_clikill': function(event) {
2018-03-01 15:01:00 +01:00
event.reply('Currently active "cliconn" kills (to use add/del, provide the pattern, not the index, and do not include the surrounding //');
2018-03-01 14:41:59 +01:00
_.each(this.config.cliconn_patterns, function(pattern, i) {
event.reply('['+i+'] /' + pattern + '/');
});
2018-02-16 15:36:56 +01:00
}
};
_.each(this.commands, function(c) {
c.access = 'moderator';
});
};
exports.fetch = function(dbot) {
return new kill_namespam(dbot);
};