LogToIrc: Prevent loop when sending to non-existing channels

When the target is a channel it is not in, it would treat it as a user;
which, if userCapabilityRequired is empty, would unconditionally send it
to a channel.
This would usually result in an error, that would be logged,
hence the loop.
This commit is contained in:
Valentin Lorentz 2021-09-13 19:07:34 +02:00
parent 070090ffc5
commit 5b9ec4f716
1 changed files with 10 additions and 7 deletions

View File

@ -79,13 +79,16 @@ class IrcHandler(logging.Handler):
if level > record.levelno: if level > record.levelno:
msgOk = False msgOk = False
if target in irc.state.channels: if irc.isChannel(target):
channel = irc.state.channels[target] if target in irc.state.channels:
modes = config.channelModesRequired.getSpecific( channel = irc.state.channels[target]
network=network)() modes = config.channelModesRequired.getSpecific(
for modeChar in modes: network=network)()
if modeChar not in channel.modes: for modeChar in modes:
msgOk = False if modeChar not in channel.modes:
msgOk = False
else:
msgOk = False
else: else:
capability = config.userCapabilityRequired.getSpecific() capability = config.userCapabilityRequired.getSpecific()
if capability: if capability: