mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-06 11:33:41 -05:00
RelayNext: split antiflood into config.plugins.antiflood.messages.[nonprivmsgs]
This commit is contained in:
parent
1775cf3b18
commit
9f837aa060
@ -71,6 +71,9 @@ conf.registerChannelValue(RelayNext.antiflood, 'seconds',
|
|||||||
conf.registerChannelValue(RelayNext.antiflood, 'maximum',
|
conf.registerChannelValue(RelayNext.antiflood, 'maximum',
|
||||||
registry.PositiveInteger(15, _("""Determines the maximum amount of incoming messages
|
registry.PositiveInteger(15, _("""Determines the maximum amount of incoming messages
|
||||||
the bot will allow from a relay channel before flood protection is triggered.""")))
|
the bot will allow from a relay channel before flood protection is triggered.""")))
|
||||||
|
conf.registerChannelValue(RelayNext.antiflood.maximum, 'nonPrivmsgs',
|
||||||
|
registry.PositiveInteger(10, _("""Determines the maximum amount of incoming non-PRIVMSG events
|
||||||
|
the bot will allow from a relay channel before flood protection is triggered.""")))
|
||||||
conf.registerChannelValue(RelayNext.antiflood, 'timeout',
|
conf.registerChannelValue(RelayNext.antiflood, 'timeout',
|
||||||
registry.PositiveInteger(60, _("""Determines the amount of time in seconds the bot should
|
registry.PositiveInteger(60, _("""Determines the amount of time in seconds the bot should
|
||||||
block messages if flood protection is triggered.""")))
|
block messages if flood protection is triggered.""")))
|
||||||
|
@ -199,10 +199,6 @@ class RelayNext(callbacks.Plugin):
|
|||||||
s = s.replace("- -", "-", 1)
|
s = s.replace("- -", "-", 1)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def checkFlood(self, channel, source, command):
|
|
||||||
maximum = self.registryValue("antiflood.maximum", channel)
|
|
||||||
return len(self.msgcounters[(source, command)]) > maximum
|
|
||||||
|
|
||||||
def keepstate(self):
|
def keepstate(self):
|
||||||
for irc in world.ircs:
|
for irc in world.ircs:
|
||||||
self.ircstates[irc.network] = deepcopy(irc.state.channels)
|
self.ircstates[irc.network] = deepcopy(irc.state.channels)
|
||||||
@ -233,7 +229,11 @@ class RelayNext(callbacks.Plugin):
|
|||||||
self.msgcounters[(source, msg.command)].enqueue(msg.prefix)
|
self.msgcounters[(source, msg.command)].enqueue(msg.prefix)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.msgcounters[(source, msg.command)] = TimeoutQueue(seconds)
|
self.msgcounters[(source, msg.command)] = TimeoutQueue(seconds)
|
||||||
if self.checkFlood(channel, source, msg.command):
|
if msg.command == "PRIVMSG":
|
||||||
|
maximum = self.registryValue("antiflood.maximum", channel)
|
||||||
|
else:
|
||||||
|
maximum = self.registryValue("antiflood.maximum.nonPrivmsgs", channel)
|
||||||
|
if len(self.msgcounters[(source, msg.command)]) > maximum:
|
||||||
self.log.debug("RelayNext (%s): message from %s blocked by "
|
self.log.debug("RelayNext (%s): message from %s blocked by "
|
||||||
"flood protection.", irc.network, channel)
|
"flood protection.", irc.network, channel)
|
||||||
if self.floodTriggered:
|
if self.floodTriggered:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user