RelayNext: only run flood checking on channels in relays

This prevents useless "Flood detected" messages from appearing in other, unrelated channels.
This commit is contained in:
James Lu 2015-04-20 16:29:31 -07:00
parent cbece29293
commit 47f59f406d

View File

@ -220,7 +220,11 @@ class RelayNext(callbacks.Plugin):
source = source.lower() source = source.lower()
out_s = self._format(irc, msg, channel) out_s = self._format(irc, msg, channel)
if out_s: if out_s:
### Begin Flood checking clause for relay in self.db.values():
if source in relay: # If our channel is in a relay
# Remove ourselves so we don't get duplicated messages
targets = list(relay)
targets.remove(source)
if self.registryValue("antiflood.enable", channel): if self.registryValue("antiflood.enable", channel):
timeout = self.registryValue("antiflood.timeout", channel) timeout = self.registryValue("antiflood.timeout", channel)
seconds = self.registryValue("antiflood.seconds", channel) seconds = self.registryValue("antiflood.seconds", channel)
@ -239,16 +243,10 @@ class RelayNext(callbacks.Plugin):
"not relaying %ss for %s seconds!", channel, "not relaying %ss for %s seconds!", channel,
maximum, c, seconds, c, timeout) maximum, c, seconds, c, timeout)
out_s = self._format(irc, msg, channel, announcement=e) out_s = self._format(irc, msg, channel, announcement=e)
self.log.info("RelayNext (%s): %s", irc.network, e)
self.floodTriggered = True self.floodTriggered = True
self.log.info("RelayNext (%s): %s", irc.network, e)
else: else:
self.floodTriggered = False self.floodTriggered = False
### End Flood checking clause
for relay in self.db.values():
if source in relay: # If our channel is in a relay
# Remove ourselves so we don't get duplicated messages
targets = list(relay)
targets.remove(source)
for cn in targets: for cn in targets:
target, net = cn.split("@") target, net = cn.split("@")
otherIrc = world.getIrc(net) otherIrc = world.getIrc(net)