kills are deferred until user joins a non-exempt channel

This commit is contained in:
Scritches 2018-05-15 20:09:43 -04:00
parent f3dcc0e693
commit e11abe5af4
2 changed files with 40 additions and 16 deletions

View File

@ -6,5 +6,6 @@
"________ ______" "________ ______"
], ],
"cliconn_channel": "#dnsbl", "cliconn_channel": "#dnsbl",
"cliconn_patterns": [] "cliconn_patterns": [],
"exempt_channels": []
} }

View File

@ -12,7 +12,10 @@ var kill_namespam = function(dbot) {
dbot.modules.admin.internalAPI.saveConfig(); dbot.modules.admin.internalAPI.saveConfig();
}.bind(this); }.bind(this);
this.matchedKill = {};
this.listener = function(event) { this.listener = function(event) {
if(event.action == 'PRIVMSG') {
// Here we listen for atropos // Here we listen for atropos
if(event.channel == this.config.cliconn_channel) { if(event.channel == this.config.cliconn_channel) {
if(event.message.match('▶')) { if(event.message.match('▶')) {
@ -27,18 +30,15 @@ var kill_namespam = function(dbot) {
'pattern': matchedPattern 'pattern': matchedPattern
})); }));
} else { } else {
var ip = event.message.split(' ')[1] if(!this.matchedKill[host]) {
// Defer killing this connection until after they join a non-exempted channel
// Alternatively you can just do dbot.api.kick.kill(event.server, event.user, message); this.matchedKill[host] = {
dbot.say(event.server, 'operserv', 'akill add *@'+ ip +' !P Naughty Nelly Auto-kill v6.2. Matched pattern: /'+ matchedPattern +'/'); ip: event.message.split(' ')[1],
server: event.server,
var msg = dbot.t('clikill_act', { matchedPattern: matchedPattern,
'ip': ip, rUser: event.rUser
'pattern': matchedPattern };
}); }
event.reply(msg);
dbot.api.report.notify('autokill', event.server, event.rUser,
dbot.config.servers[event.server].admin_channel, msg, ip, ip);
} }
}, true); }, true);
} }
@ -86,8 +86,31 @@ var kill_namespam = function(dbot) {
dbot.api.report.notify('spam', event.server, event.user, event.channel, message, event.host, event.user); dbot.api.report.notify('spam', event.server, event.user, event.channel, message, event.host, event.user);
} }
} else if (event.action == 'JOIN') {
if(this.matchedKill[event.host]) {
if(this.config.exempt_channels.indexOf(event.channel) == -1) {
var kill = this.matchedKill[event.host];
delete this.matchedKill[event.host];
// Alternatively you can just do dbot.api.kick.kill(event.server, event.user, message);
dbot.say(event.server, 'operserv', 'akill add *@'+ kill.ip +' !P Naughty Nelly Auto-kill v6.2. Matched pattern: /'+ kill.matchedPattern +'/');
var msg = dbot.t('clikill_act', {
'ip': kill.ip,
'pattern': kill.matchedPattern
});
dbot.api.report.notify('autokill', kill.server, kill.rUser,
dbot.config.servers[kill.server].admin_channel, msg, kill.ip, kill.ip);
}
}
} else if (event.action == 'QUIT') {
if(this.matchedKill[event.host]) {
delete this.matchedKill[event.host];
}
}
}.bind(this); }.bind(this);
this.on = 'PRIVMSG'; this.on = ['PRIVMSG', 'JOIN', 'QUIT'];
this.commands = { this.commands = {
'~add_spamkill': function(event) { '~add_spamkill': function(event) {