Channel: Fix error in @part when channel is configured but not joined

This typically happens when banned from the channel, and returning an error
gives bot admins the impression @part did not remove the channel from
the auto-join list
This commit is contained in:
Valentin Lorentz 2024-04-12 19:14:57 +02:00
parent 03a3777129
commit 03c638705f
1 changed files with 8 additions and 3 deletions

View File

@ -991,9 +991,14 @@ class Channel(callbacks.Plugin):
network = conf.supybot.networks.get(irc.network)
network.channels().remove(channel)
except KeyError:
pass
if channel not in irc.state.channels:
irc.error(_('I\'m not in %s.') % channel, Raise=True)
if channel not in irc.state.channels:
# Not configured AND not in the channel
irc.error(_('I\'m not in %s.') % channel, Raise=True)
else:
if channel not in irc.state.channels:
# Configured, but not in the channel
irc.reply(_('%s removed from configured join list.') % channel)
return
reason = (reason or self.registryValue("partMsg", channel, irc.network))
reason = ircutils.standardSubstitute(irc, msg, reason)
irc.queueMsg(ircmsgs.part(channel, reason))