clikill spares SASL-authenticated users from match kills

This commit is contained in:
Scritches 2018-05-01 16:47:25 -04:00
parent bbfc4c18a6
commit d544dcf017
3 changed files with 35 additions and 17 deletions

View File

@ -18,18 +18,29 @@ var kill_namespam = function(dbot) {
if(event.message.match('▶')) { if(event.message.match('▶')) {
var matchedPattern = _.find(this.config.cliconn_patterns, function(p) { return event.message.match(p); }) var matchedPattern = _.find(this.config.cliconn_patterns, function(p) { return event.message.match(p); })
if(matchedPattern) { if(matchedPattern) {
var ip = event.message.split(' ')[1] var nick = event.message.split(' ')[2];
dbot.api.nickserv.getUserHost(event.server, nick, function(host) {
var userIsAuthenticated = host && host.startsWith('tripsit/');
if (userIsAuthenticated) {
event.reply(dbot.t('clikill_spared', {
'user': nick,
'pattern': matchedPattern
}));
} else {
var ip = event.message.split(' ')[1]
// Alternatively you can just do dbot.api.kick.kill(event.server, event.user, message); // Alternatively you can just do dbot.api.kick.kill(event.server, event.user, message);
dbot.say(event.server, 'operserv', 'akill add *@'+ ip +' !P Naughty Nelly Auto-kill v6.2. Matched pattern: /'+ matchedPattern +'/'); dbot.say(event.server, 'operserv', 'akill add *@'+ ip +' !P Naughty Nelly Auto-kill v6.2. Matched pattern: /'+ matchedPattern +'/');
var msg = dbot.t('clikill_act', { var msg = dbot.t('clikill_act', {
'ip': ip, 'ip': ip,
'pattern': matchedPattern 'pattern': matchedPattern
}); });
event.reply(msg); event.reply(msg);
dbot.api.report.notify('autokill', event.server, event.rUser, dbot.api.report.notify('autokill', event.server, event.rUser,
dbot.config.servers[event.server].admin_channel, msg, ip, ip); dbot.config.servers[event.server].admin_channel, msg, ip, ip);
}
}, true);
} }
} }
} }

View File

@ -7,5 +7,8 @@
}, },
"clikill_act": { "clikill_act": {
"en": "Added K-Line for {ip}, due to matching pattern: /{pattern}/" "en": "Added K-Line for {ip}, due to matching pattern: /{pattern}/"
},
"clikill_spared": {
"en": "{user} spared from clikill matched pattern: /{pattern}/"
} }
} }

View File

@ -26,18 +26,22 @@ var nickserv = function(dbot) {
}.bind(this), 6000); }.bind(this), 6000);
}, },
'getUserHost': function(server, nick, callback) { 'getUserHost': function(server, nick, callback, skipFallback) {
if(!_.has(this.userStack, server)) this.userStack[server] = {}; if(!_.has(this.userStack, server)) this.userStack[server] = {};
this.userStack[server][nick] = callback; this.userStack[server][nick] = callback;
dbot.instance.connections[server].send('USERHOST ' + nick); dbot.instance.connections[server].send('USERHOST ' + nick);
setTimeout(function() { setTimeout(function() {
if(_.has(this.userStack[server], nick)) { if(_.has(this.userStack[server], nick)) {
dbot.instance.connections[server].send('WHOWAS ' + nick + ' 1'); if (skipFallback) {
setTimeout(function() { callback(false);
if(_.has(this.userStack[server], nick)) { } else {
callback(false); dbot.instance.connections[server].send('WHOWAS ' + nick + ' 1');
} setTimeout(function() {
}.bind(this), 2000); if(_.has(this.userStack[server], nick)) {
callback(false);
}
}.bind(this), 2000);
}
} }
}.bind(this), 4000); }.bind(this), 4000);
} }