mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-05-07 03:53:41 -05:00
fix ctcps action, added banEvade check ( when account changes triggered ), move cycle detection under part and quit, added massJoin in doJoin
This commit is contained in:
parent
5d15682b98
commit
895c638f1a
21
config.py
21
config.py
@ -126,6 +126,9 @@ conf.registerChannelValue(ChanTracker, 'kickMessage',
|
||||
conf.registerChannelValue(ChanTracker, 'askOpAboutMode',
|
||||
registry.Boolean(False,"""Ask the op who added a mode changes in pm about duration and comment"""))
|
||||
|
||||
conf.registerChannelValue(ChanTracker, 'checkEvade',
|
||||
registry.Boolean(True,"""bot will apply same duration and mode than the ban evaded, currently only work when someone identify to an account, and has ip computed"""))
|
||||
|
||||
# related to channle's protection
|
||||
|
||||
# flood detection settings
|
||||
@ -236,7 +239,7 @@ registry.String('ctcp detected',"""comment added on mode changes database, empty
|
||||
|
||||
# channel join/part flood
|
||||
conf.registerChannelValue(ChanTracker, 'cyclePermit',
|
||||
registry.Integer(-1,"""Number of messages allowed, -1 to disable, advice 3"""))
|
||||
registry.Integer(-1,"""Number of messages allowed, -1 to disable, count part and quit"""))
|
||||
conf.registerChannelValue(ChanTracker, 'cycleLife',
|
||||
registry.PositiveInteger(180,"""Duration in seconds before messages are removed from count, advice 180"""))
|
||||
conf.registerChannelValue(ChanTracker, 'cycleMode',
|
||||
@ -246,6 +249,18 @@ registry.PositiveInteger(1800,"""punition in seconds"""))
|
||||
conf.registerChannelValue(ChanTracker, 'cycleComment',
|
||||
registry.String('cycle detected',"""comment added on mode changes database, empty for no comment"""))
|
||||
|
||||
# channel massJoin from an host
|
||||
conf.registerChannelValue(ChanTracker, 'massJoinPermit',
|
||||
registry.Integer(-1,"""Number of messages allowed, -1 to disable, note, it could mixup a bit with cycle detection"""))
|
||||
conf.registerChannelValue(ChanTracker, 'massJoinLife',
|
||||
registry.PositiveInteger(60,"""Duration in seconds before messages are removed from count"""))
|
||||
conf.registerChannelValue(ChanTracker, 'massJoinMode',
|
||||
registry.String('b',"""mode used by the bot when ctcp is triggered"""))
|
||||
conf.registerChannelValue(ChanTracker, 'massJoinDuration',
|
||||
registry.PositiveInteger(900,"""punition in seconds"""))
|
||||
conf.registerChannelValue(ChanTracker, 'massJoinComment',
|
||||
registry.String('massJoin detected',"""comment added on mode changes database, empty for no comment"""))
|
||||
|
||||
# nick changes flood
|
||||
conf.registerChannelValue(ChanTracker, 'nickPermit',
|
||||
registry.Integer(-1,"""Number of messages allowed, -1 to disable, advice 2"""))
|
||||
@ -282,7 +297,3 @@ registry.String('+rq-z $~a',"""mode used by the bot when attack is triggered""")
|
||||
conf.registerChannelValue(ChanTracker, 'attackUnMode',
|
||||
registry.String('-rq+z $~a',"""mode used by the bot when attackDuration is finished"""))
|
||||
|
||||
# TODO : banevade, massjoin, clones
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
78
plugin.py
78
plugin.py
@ -1730,14 +1730,14 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
chan = self.getChan(irc,channel)
|
||||
n.addLog(channel,'has joined')
|
||||
if best and not self._isVip(irc,channel,n):
|
||||
isCycle = self._isSomething(irc,channel,best,'cycle')
|
||||
isMassJoin = self._isSomething(irc,channel,best,'massJoin')
|
||||
if isCycle:
|
||||
isBad = self._isSomething(irc,channel,best,'bad')
|
||||
kind = None
|
||||
if isBad:
|
||||
kind = 'bad'
|
||||
else:
|
||||
kind = 'cycle'
|
||||
kind = 'massJoin'
|
||||
mode = self.registryValue('%sMode' % kind,channel=channel)
|
||||
if len(mode) > 1:
|
||||
mode = mode[0]
|
||||
@ -1756,7 +1756,11 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
n = None
|
||||
if msg.nick in i.nicks:
|
||||
n = self.getNick(irc,msg.nick)
|
||||
n.setPrefix(msg.prefix)
|
||||
reason = ''
|
||||
best = None
|
||||
if n:
|
||||
best = getBestPattern(n)[0]
|
||||
if len(msg.args) == 2:
|
||||
reason = msg.args[1].lstrip().rstrip()
|
||||
canRemove = True
|
||||
@ -1774,6 +1778,22 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
if not isBot:
|
||||
if msg.nick in irc.state.channels[channel].users:
|
||||
canRemove = False
|
||||
if best and not self._isVip(irc,channel,n):
|
||||
isCycle = self._isSomething(irc,channel,best,'cycle')
|
||||
if isCycle:
|
||||
isBad = self._isSomething(irc,channel,best,'bad')
|
||||
kind = None
|
||||
if isBad:
|
||||
kind = 'bad'
|
||||
else:
|
||||
kind = 'cycle'
|
||||
mode = self.registryValue('%sMode' % kind,channel=channel)
|
||||
if len(mode) > 1:
|
||||
mode = mode[0]
|
||||
duration = self.registryValue('%sDuration' % kind,channel=channel)
|
||||
comment = self.registryValue('%sComment' % kind,channel=channel)
|
||||
self._act(irc,channel,mode,best,duration,comment)
|
||||
self.forceTickle = True
|
||||
if canRemove:
|
||||
self._rmNick(irc,n)
|
||||
self._tickle(irc)
|
||||
@ -1842,6 +1862,23 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
if nick == msg.nick:
|
||||
self._logChan(irc,channel,'[%s] %s has quit (%s)' % (channel,msg.prefix,reason))
|
||||
break
|
||||
best = getBestPattern(n)[0]
|
||||
if best and not self._isVip(irc,channel,n):
|
||||
isCycle = self._isSomething(irc,channel,best,'cycle')
|
||||
if isCycle:
|
||||
isBad = self._isSomething(irc,channel,best,'bad')
|
||||
kind = None
|
||||
if isBad:
|
||||
kind = 'bad'
|
||||
else:
|
||||
kind = 'cycle'
|
||||
mode = self.registryValue('%sMode' % kind,channel=channel)
|
||||
if len(mode) > 1:
|
||||
mode = mode[0]
|
||||
duration = self.registryValue('%sDuration' % kind,channel=channel)
|
||||
comment = self.registryValue('%sComment' % kind,channel=channel)
|
||||
self._act(irc,channel,mode,best,duration,comment)
|
||||
self.forceTickle = True
|
||||
if removeNick:
|
||||
i = self.getIrc(irc)
|
||||
if msg.nick in i.nicks:
|
||||
@ -1922,15 +1959,46 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
|
||||
def doAccount (self,irc,msg):
|
||||
# update nick's model
|
||||
n = None
|
||||
if ircutils.isUserHostmask(msg.prefix):
|
||||
nick = ircutils.nickFromHostmask(msg.prefix)
|
||||
n = self.getNick(irc,nick)
|
||||
old = n.account;
|
||||
acc = msg.args[0]
|
||||
if acc == '*':
|
||||
acc = None
|
||||
n.setAccount(acc)
|
||||
n.addLog('ALL','%s is now identified as %s' % (old,acc))
|
||||
else:
|
||||
return
|
||||
if n and n.account and n.ip:
|
||||
i = self.getIrc(irc)
|
||||
for channel in irc.state.channels:
|
||||
if self.registryValue('checkEvade',channel=channel):
|
||||
if nick in irc.state.channels[channel].users:
|
||||
modes = self.registryValue('modesToAsk')
|
||||
found = False
|
||||
chan = self.getChan(irc,channel)
|
||||
for mode in modes:
|
||||
items = chan.getItemsFor(mode)
|
||||
for item in items:
|
||||
f = match(items[item].value,n)
|
||||
if f:
|
||||
found = items[item]
|
||||
if found:
|
||||
break
|
||||
if found:
|
||||
break
|
||||
if found:
|
||||
duration = -1
|
||||
if found.expire and found.expire != found.when:
|
||||
duration = int(found.expire-found.when)
|
||||
self._act (irc,channel,found.mode,getBestPattern(n)[0],duration,'evade of [#%s +%s %s]' % (found.uid,found.mode,found.value))
|
||||
f = None
|
||||
if self.registryValue('announceBotMark',channel=found.channel):
|
||||
f = self._logChan
|
||||
i.mark(irc,found.uid,'evade with %s --> %s' % (msg.prefix,getBestPattern(n)[0]),irc.prefix,self.getDb(irc.network),f)
|
||||
self.forceTickle = True
|
||||
|
||||
self._tickle(irc)
|
||||
|
||||
def doNotice (self,irc,msg):
|
||||
@ -2082,7 +2150,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
continue
|
||||
|
||||
isCtcp = False
|
||||
if isCtcpMsg:
|
||||
if isCtcpMsg and not isAction:
|
||||
isCtcp = self._isSomething(irc,channel,best,'ctcp')
|
||||
isFlood = self._isFlood(irc,channel,best)
|
||||
isLowFlood = self._isLowFlood(irc,channel,best)
|
||||
@ -2149,7 +2217,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
self._act(irc,channel,mode,best,duration,comment)
|
||||
self.forceTickle = True
|
||||
if not chan.isWrong(best):
|
||||
if self.registryValue('announceCtcp',channel=channel) and isCtcpMsg:
|
||||
if self.registryValue('announceCtcp',channel=channel) and isCtcpMsg and not isAction:
|
||||
self._logChan(irc,channel,'[%s] %s ctcps "%s"' % (channel,msg.prefix,text))
|
||||
self.forceTickle = True
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user