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:
msgOk = False
if target in irc.state.channels:
channel = irc.state.channels[target]
modes = config.channelModesRequired.getSpecific(
network=network)()
for modeChar in modes:
if modeChar not in channel.modes:
msgOk = False
if irc.isChannel(target):
if target in irc.state.channels:
channel = irc.state.channels[target]
modes = config.channelModesRequired.getSpecific(
network=network)()
for modeChar in modes:
if modeChar not in channel.modes:
msgOk = False
else:
msgOk = False
else:
capability = config.userCapabilityRequired.getSpecific()
if capability: