From 0c105a03ba35f3e203c8171dc68f3f2431fdbb77 Mon Sep 17 00:00:00 2001 From: Nicolas Coevoet Date: Fri, 30 Mar 2018 11:49:57 +0200 Subject: [PATCH] resolve #22 this new feature is only available for b,q,e,I and note commands, not automated actions --- config.py | 3 +++ plugin.py | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 989f5ed..68ace08 100644 --- a/config.py +++ b/config.py @@ -62,6 +62,9 @@ conf.registerGlobalValue(ChanTracker, 'resolveIp', # per channel settings +conf.registerChannelValue(ChanTracker, 'useAccountBanIfPossible', + registry.Boolean(False, """bot will choose account bans when user is identified, only works for b,q,e,I,note commands not automated bans""")) + conf.registerChannelValue(ChanTracker, 'avoidOverlap', registry.Boolean(False, """avoid overlap between items, bot will try to use existing items against users, some limitations with extended bans""")) diff --git a/plugin.py b/plugin.py index c7e1a7b..5eb4bed 100644 --- a/plugin.py +++ b/plugin.py @@ -1891,7 +1891,13 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): n = self.getNick(irc,item) patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway',channel=channel),self.registryValue('resolveIp')) if len(patterns): - targets.append(patterns[0]) + pattern = patterns[0] + if self.registryValue('useAccountBanIfPossible',channel=channel): + for p in patterns: + if p.startswith('$a:'): + pattern = p + break + targets.append(pattern) elif ircutils.isUserHostmask(item) or self.getIrcdExtbansPrefix(irc) in item: targets.append(item) for target in targets: @@ -2015,7 +2021,13 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): if not found: patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway',channel=channel),self.registryValue('resolveIp')) if len(patterns): - targets.append(patterns[0]) + pattern = patterns[0] + if self.registryValue('useAccountBanIfPossible',channel=channel): + for p in patterns: + if p.startswith('$a:'): + pattern = p + break + targets.append(pattern) elif ircutils.isUserHostmask(item) or self.getIrcdExtbansPrefix(irc) in item: found = False if self.registryValue('avoidOverlap',channel=channel):