From 9ade56fa75b5da33c638f4830938b5b244876550 Mon Sep 17 00:00:00 2001 From: Nicolas Coevoet Date: Fri, 13 Mar 2015 22:09:06 +0100 Subject: [PATCH] experimental feature, do not use yet --- config.py | 11 +++++++---- plugin.py | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/config.py b/config.py index d0298af..4d408b5 100644 --- a/config.py +++ b/config.py @@ -52,13 +52,13 @@ conf.registerGlobalValue(ChanTracker, 'logsSize', registry.PositiveInteger(60, """number of messages to keep in logs. Note, this is per nick - not per nick per channel""")) conf.registerGlobalValue(ChanTracker, 'quietCommand', - registry.String("CS QUIET $channel $hostmask","""command issued to quiet a user; $channel and $hostmask will be replaced at runtime""")) + registry.String("PRIVMSG ChanServ :QUIET $channel $hostmask","""command issued to quiet a user; $channel and $hostmask will be replaced at runtime""")) conf.registerGlobalValue(ChanTracker, 'unquietCommand', - registry.String("CS UNQUIET $channel $hostmask","""command issued to unquiet a user $channel and $hostmask will be replaced at runtime""")) + registry.String("PRIVMSG ChanServ :UNQUIET $channel $hostmask","""command issued to unquiet a user $channel and $hostmask will be replaced at runtime""")) conf.registerGlobalValue(ChanTracker, 'announceNagInterval', - registry.Integer(300,"""interval between two check about announceNagMode, this setting is global.""")) + registry.Integer(-1,"""interval between two check about announceNagMode, this setting is global.""")) conf.registerChannelValue(ChanTracker, 'useIpForGateway', registry.Boolean(False, """use *!*@*ip bans instead of *!ident@gateway/* when gateways cloak is found and ends with ip.*""")) @@ -66,7 +66,7 @@ conf.registerChannelValue(ChanTracker, 'useIpForGateway', #now per channel conf.registerChannelValue(ChanTracker, 'opCommand', - registry.String("CS OP $channel $nick", """command used to obtain channel operator mode""")) + registry.String("PRIVMSG ChanServ :OP $channel $nick", """command used to obtain channel operator mode""")) conf.registerChannelValue(ChanTracker, 'modesToAsk', registry.CommaSeparatedListOfStrings(['b','q'], """list of channel modes to sync into the bot's tracking database when it joins the channel""")) @@ -182,6 +182,9 @@ conf.registerChannelValue(ChanTracker, 'checkEvade', conf.registerChannelValue(ChanTracker, 'useChanServForQuiets', registry.Boolean(False,"""if bot is not opped, use services for quiet / unquiets""")) +conf.registerChannelValue(ChanTracker, 'skynet', + registry.Boolean(False,"""when True, bot could use some experimental features against spam / channel's attacks, ie : trying to find better patterns to use against""")) + # related to channel's protection # flood detection settings diff --git a/plugin.py b/plugin.py index fe06973..d5347a0 100644 --- a/plugin.py +++ b/plugin.py @@ -3333,13 +3333,40 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): if self._isSomething(irc,channel,channel,'attack') and not chan.attacked: # if number of bad users raise the allowed limit, bot has to set channel attackmode # todo retreive all wrong users and find the best pattern to use against them -# L = [] -# for n in chan.nicks: -# n = self.getNick(irc,n) -# patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway'),channel=channel) -# if chan.isWrong(patterns[0]): -# L.append(n) -# self.log.debug('founds bads %s' % ' '.join(L)) + if self.registryValue('skynet',channel=channel): + L = [] + for n in chan.nicks: + n = self.getNick(irc,n) + pattern = getBestPattern(n,irc,self.registryValue('useIpForGateway'),channel=channel)[0] + if chan.isWrong(pattern): + L.append(n) + self.log.debug('founds bads %s' % ' '.join(L)) + idents = {} + users = {} + for n in L: + (nick,ident,host) = ircutils.splitHostmask(n.prefix) + if not ident in idents: + idents[ident] = [] + idents[ident].append(n) + if n.realname and not n.realname in users: + users[n.realname] + if n.realname: + users[n.realname].append(n) + fident = None + for ident in idents: + if not fident: + fident = ident + if len(idents[fident]) < len(idents[ident]): + fident = ident + user = None + for u in users: + if not user: + user = u + if len(users[user]) < len(users[u]): + user = u + self.log.debug('computed $r:%s and *!%s@*' % (user,fident)) + if fident and user: + self._act (irc,channel,'b','$x:*!%s@*#%s' % (fident,user.replace(' ','?')),self.registryValue('attackDuration',channel=channel),'skynet powered') chan.attacked = True chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackMode',channel=channel)))) def unAttack():