mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-05-01 07:51:07 -05:00
Fix regression from repeat protection rework.
This commit is contained in:
parent
dc0615a29a
commit
8d0d64e843
114
plugin.py
114
plugin.py
@ -1607,8 +1607,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
f = self._logChan
|
f = self._logChan
|
||||||
if be:
|
if be:
|
||||||
if reason and len(reason):
|
if reason and len(reason):
|
||||||
bm = i.mark(irc, uid, reason, msg.prefix,
|
bm = i.mark(irc, uid, reason, msg.prefix, self.getDb(irc.network), f, self)
|
||||||
self.getDb(irc.network), f, self)
|
|
||||||
else:
|
else:
|
||||||
bm = True
|
bm = True
|
||||||
b = b and be and bm
|
b = b and be and bm
|
||||||
@ -3986,11 +3985,11 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
flag = ircdb.makeChannelCapability(channel, 'flood')
|
flag = ircdb.makeChannelCapability(channel, 'flood')
|
||||||
isFlood = False
|
isFlood = False
|
||||||
if ircdb.checkCapability(msg.prefix, flag):
|
if ircdb.checkCapability(msg.prefix, flag):
|
||||||
isFlood = self._isFlood(irc, channel, best)
|
isFlood = self._isSomething(irc, channel, best, 'flood')
|
||||||
flag = ircdb.makeChannelCapability(channel, 'lowFlood')
|
flag = ircdb.makeChannelCapability(channel, 'lowFlood')
|
||||||
isLowFlood = False
|
isLowFlood = False
|
||||||
if ircdb.checkCapability(msg.prefix, flag):
|
if ircdb.checkCapability(msg.prefix, flag):
|
||||||
isLowFlood = self._isLowFlood(irc, channel, best)
|
isLowFlood = self._isSomething(irc, channel, best, 'lowFlood')
|
||||||
flag = ircdb.makeChannelCapability(channel, 'repeat')
|
flag = ircdb.makeChannelCapability(channel, 'repeat')
|
||||||
isRepeat = False
|
isRepeat = False
|
||||||
if ircdb.checkCapability(msg.prefix, flag):
|
if ircdb.checkCapability(msg.prefix, flag):
|
||||||
@ -4005,6 +4004,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
isCap = self._isCap(irc, channel, best, text)
|
isCap = self._isCap(irc, channel, best, text)
|
||||||
flag = ircdb.makeChannelCapability(channel, 'pattern')
|
flag = ircdb.makeChannelCapability(channel, 'pattern')
|
||||||
isPattern = False
|
isPattern = False
|
||||||
|
isTemporaryPattern = False
|
||||||
if ircdb.checkCapability(msg.prefix, flag):
|
if ircdb.checkCapability(msg.prefix, flag):
|
||||||
for p in chan.patterns:
|
for p in chan.patterns:
|
||||||
pattern = chan.patterns[p]
|
pattern = chan.patterns[p]
|
||||||
@ -4032,9 +4032,6 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
isBad = self._isBad(irc, channel, best)
|
isBad = self._isBad(irc, channel, best)
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
chan.countpattern(isPattern.uid, self.getDb(irc.network))
|
chan.countpattern(isPattern.uid, self.getDb(irc.network))
|
||||||
isTemporaryPattern = False
|
|
||||||
if isPattern:
|
|
||||||
pass
|
|
||||||
elif not isRepeat:
|
elif not isRepeat:
|
||||||
key = 'pattern%s' % channel
|
key = 'pattern%s' % channel
|
||||||
if key in chan.repeatLogs:
|
if key in chan.repeatLogs:
|
||||||
@ -4052,52 +4049,52 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
'repeatDuration', channel=channel, network=irc.network), 'temporary pattern', msg.nick)
|
'repeatDuration', channel=channel, network=irc.network), 'temporary pattern', msg.nick)
|
||||||
isBad = self._isBad(irc, channel, best)
|
isBad = self._isBad(irc, channel, best)
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
elif not isTemporaryPattern:
|
if not (isPattern or isTemporaryPattern) \
|
||||||
if isFlood or isHilight or isRepeat or isCap or isCtcp or isLowFlood:
|
and (isFlood or isLowFlood or isRepeat or isHilight or isCap or isCtcp):
|
||||||
isBad = self._isBad(irc, channel, best)
|
isBad = self._isBad(irc, channel, best)
|
||||||
kind = None
|
kind = None
|
||||||
duration = 0
|
duration = 0
|
||||||
if isBad:
|
if isBad:
|
||||||
kind = 'bad'
|
kind = 'bad'
|
||||||
duration = self.registryValue('badDuration', channel=channel, network=irc.network)
|
duration = self.registryValue('badDuration', channel=channel, network=irc.network)
|
||||||
else:
|
else:
|
||||||
if isFlood:
|
if isFlood:
|
||||||
d = self.registryValue('floodDuration', channel=channel, network=irc.network)
|
d = self.registryValue('floodDuration', channel=channel, network=irc.network)
|
||||||
if d > duration:
|
if d > duration:
|
||||||
kind = 'flood'
|
kind = 'flood'
|
||||||
duration = d
|
duration = d
|
||||||
if isLowFlood:
|
if isLowFlood:
|
||||||
d = self.registryValue('lowFloodDuration', channel=channel, network=irc.network)
|
d = self.registryValue('lowFloodDuration', channel=channel, network=irc.network)
|
||||||
if d > duration:
|
if d > duration:
|
||||||
kind = 'lowFlood'
|
kind = 'lowFlood'
|
||||||
duration = d
|
duration = d
|
||||||
if isRepeat:
|
if isRepeat:
|
||||||
d = self.registryValue('repeatDuration', channel=channel, network=irc.network)
|
d = self.registryValue('repeatDuration', channel=channel, network=irc.network)
|
||||||
if d > duration:
|
if d > duration:
|
||||||
kind = 'repeat'
|
kind = 'repeat'
|
||||||
duration = d
|
duration = d
|
||||||
if isHilight:
|
if isHilight:
|
||||||
d = self.registryValue('hilightDuration', channel=channel, network=irc.network)
|
d = self.registryValue('hilightDuration', channel=channel, network=irc.network)
|
||||||
if d > duration:
|
if d > duration:
|
||||||
kind = 'hilight'
|
kind = 'hilight'
|
||||||
duration = d
|
duration = d
|
||||||
if isCap:
|
if isCap:
|
||||||
d = self.registryValue('capDuration', channel=channel, network=irc.network)
|
d = self.registryValue('capDuration', channel=channel, network=irc.network)
|
||||||
if d > duration:
|
if d > duration:
|
||||||
kind = 'cap'
|
kind = 'cap'
|
||||||
duration = d
|
duration = d
|
||||||
if isCtcp:
|
if isCtcp:
|
||||||
d = self.registryValue('ctcpDuration', channel=channel, network=irc.network)
|
d = self.registryValue('ctcpDuration', channel=channel, network=irc.network)
|
||||||
if d > duration:
|
if d > duration:
|
||||||
kind = 'ctcp'
|
kind = 'ctcp'
|
||||||
duration = d
|
duration = d
|
||||||
mode = self.registryValue('%sMode' % kind, channel=channel, network=irc.network)
|
mode = self.registryValue('%sMode' % kind, channel=channel, network=irc.network)
|
||||||
comment = self.registryValue('%sComment' % kind, channel=channel, network=irc.network)
|
comment = self.registryValue('%sComment' % kind, channel=channel, network=irc.network)
|
||||||
if len(mode) > 1:
|
if len(mode) > 1:
|
||||||
mode = mode[0]
|
mode = mode[0]
|
||||||
r = self.getIrcdMode(irc, mode, best)
|
r = self.getIrcdMode(irc, mode, best)
|
||||||
self._act(irc, channel, r[0], r[1], duration, comment, msg.nick)
|
self._act(irc, channel, r[0], r[1], duration, comment, msg.nick)
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
if not chan.isWrong(best):
|
if not chan.isWrong(best):
|
||||||
# prevent the bot to flood logChannel with bad user craps
|
# prevent the bot to flood logChannel with bad user craps
|
||||||
if self.registryValue('announceCtcp', channel=channel, network=irc.network) and isCtcpMsg and not isAction:
|
if self.registryValue('announceCtcp', channel=channel, network=irc.network) and isCtcpMsg and not isAction:
|
||||||
@ -4744,15 +4741,9 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
+ self.registryValue('attackDuration', channel=channel, network=irc.network)))
|
+ self.registryValue('attackDuration', channel=channel, network=irc.network)))
|
||||||
return b
|
return b
|
||||||
|
|
||||||
def _isFlood(self, irc, channel, key):
|
|
||||||
return self._isSomething(irc, channel, key, 'flood')
|
|
||||||
|
|
||||||
def _isLowFlood(self, irc, channel, key):
|
|
||||||
return self._isSomething(irc, channel, key, 'lowFlood')
|
|
||||||
|
|
||||||
def _isHilight(self, irc, channel, key, message):
|
def _isHilight(self, irc, channel, key, message):
|
||||||
limit = self.registryValue('hilightPermit', channel=channel, network=irc.network)
|
limit = self.registryValue('hilightPermit', channel=channel, network=irc.network)
|
||||||
if limit == -1:
|
if limit < 0:
|
||||||
return False
|
return False
|
||||||
count = 0
|
count = 0
|
||||||
users = []
|
users = []
|
||||||
@ -4852,8 +4843,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def _isCap(self, irc, channel, key, message):
|
def _isCap(self, irc, channel, key, message):
|
||||||
limit = self.registryValue('capPermit', channel=channel, network=irc.network)
|
if self.registryValue('capPermit', channel=channel, network=irc.network) < 0:
|
||||||
if limit == -1:
|
|
||||||
return False
|
return False
|
||||||
trigger = self.registryValue('capPercent', channel=channel, network=irc.network)
|
trigger = self.registryValue('capPercent', channel=channel, network=irc.network)
|
||||||
match = self.recaps.findall(message)
|
match = self.recaps.findall(message)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user