From d544dcf017c9b19d45fd546f85b6effabbf24d91 Mon Sep 17 00:00:00 2001 From: Scritches Date: Tue, 1 May 2018 16:47:25 -0400 Subject: [PATCH] clikill spares SASL-authenticated users from match kills --- modules/kill_namespam/kill_namespam.js | 31 +++++++++++++++++--------- modules/kill_namespam/strings.json | 3 +++ modules/nickserv/nickserv.js | 18 +++++++++------ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/modules/kill_namespam/kill_namespam.js b/modules/kill_namespam/kill_namespam.js index 635c39b..04da04c 100644 --- a/modules/kill_namespam/kill_namespam.js +++ b/modules/kill_namespam/kill_namespam.js @@ -18,18 +18,29 @@ var kill_namespam = function(dbot) { if(event.message.match('▶')) { var matchedPattern = _.find(this.config.cliconn_patterns, function(p) { return event.message.match(p); }) 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); - dbot.say(event.server, 'operserv', 'akill add *@'+ ip +' !P Naughty Nelly Auto-kill v6.2. Matched pattern: /'+ matchedPattern +'/'); + // 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 +'/'); - var msg = dbot.t('clikill_act', { - 'ip': ip, - 'pattern': matchedPattern - }); - event.reply(msg); - dbot.api.report.notify('autokill', event.server, event.rUser, - dbot.config.servers[event.server].admin_channel, msg, ip, ip); + var msg = dbot.t('clikill_act', { + 'ip': ip, + '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); } } } diff --git a/modules/kill_namespam/strings.json b/modules/kill_namespam/strings.json index 8717fbf..c432f25 100644 --- a/modules/kill_namespam/strings.json +++ b/modules/kill_namespam/strings.json @@ -7,5 +7,8 @@ }, "clikill_act": { "en": "Added K-Line for {ip}, due to matching pattern: /{pattern}/" + }, + "clikill_spared": { + "en": "{user} spared from clikill matched pattern: /{pattern}/" } } diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 88b50b5..e4903bf 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -26,18 +26,22 @@ var nickserv = function(dbot) { }.bind(this), 6000); }, - 'getUserHost': function(server, nick, callback) { + 'getUserHost': function(server, nick, callback, skipFallback) { if(!_.has(this.userStack, server)) this.userStack[server] = {}; this.userStack[server][nick] = callback; dbot.instance.connections[server].send('USERHOST ' + nick); setTimeout(function() { if(_.has(this.userStack[server], nick)) { - dbot.instance.connections[server].send('WHOWAS ' + nick + ' 1'); - setTimeout(function() { - if(_.has(this.userStack[server], nick)) { - callback(false); - } - }.bind(this), 2000); + if (skipFallback) { + callback(false); + } else { + dbot.instance.connections[server].send('WHOWAS ' + nick + ' 1'); + setTimeout(function() { + if(_.has(this.userStack[server], nick)) { + callback(false); + } + }.bind(this), 2000); + } } }.bind(this), 4000); }