experimental feature, do not use yet

This commit is contained in:
Nicolas Coevoet 2015-03-13 22:09:06 +01:00
parent 883bee94a8
commit 9ade56fa75
2 changed files with 41 additions and 11 deletions

View File

@ -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""")) registry.PositiveInteger(60, """number of messages to keep in logs. Note, this is per nick - not per nick per channel"""))
conf.registerGlobalValue(ChanTracker, 'quietCommand', 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', 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', 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', conf.registerChannelValue(ChanTracker, 'useIpForGateway',
registry.Boolean(False, """use *!*@*ip bans instead of *!ident@gateway/* when gateways cloak is found and ends with ip.*""")) 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 #now per channel
conf.registerChannelValue(ChanTracker, 'opCommand', 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', 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""")) 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', conf.registerChannelValue(ChanTracker, 'useChanServForQuiets',
registry.Boolean(False,"""if bot is not opped, use services for quiet / unquiets""")) 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 # related to channel's protection
# flood detection settings # flood detection settings

View File

@ -3333,13 +3333,40 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
if self._isSomething(irc,channel,channel,'attack') and not chan.attacked: 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 # 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 # todo retreive all wrong users and find the best pattern to use against them
# L = [] if self.registryValue('skynet',channel=channel):
# for n in chan.nicks: L = []
# n = self.getNick(irc,n) for n in chan.nicks:
# patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway'),channel=channel) n = self.getNick(irc,n)
# if chan.isWrong(patterns[0]): pattern = getBestPattern(n,irc,self.registryValue('useIpForGateway'),channel=channel)[0]
# L.append(n) if chan.isWrong(pattern):
# self.log.debug('founds bads %s' % ' '.join(L)) 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.attacked = True
chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackMode',channel=channel)))) chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackMode',channel=channel))))
def unAttack(): def unAttack():