From 92be421fad13409758724f08f907fdbb31f91d44 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 5 May 2018 12:57:17 -0700 Subject: [PATCH] relay: attempt to remove persistent channels on delink as well Also, wrap remove_persistent_channel calls with a try/except when they may fail. --- plugins/relay.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/relay.py b/plugins/relay.py index 8c55632..95579c5 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -539,7 +539,10 @@ def remove_channel(irc, channel): if irc is None: return - world.services['pylink'].remove_persistent_channel(irc, 'relay', channel, try_part=False) + try: + world.services['pylink'].remove_persistent_channel(irc, 'relay', channel, try_part=False) + except KeyError: + log.warning('(%s) relay: failed to remove persistent channel %r on delink', irc.name, channel, exc_info=True) relay = get_relay(irc, channel) if relay and channel in irc.channels: @@ -554,7 +557,10 @@ def remove_channel(irc, channel): # have the channel registered. sbot = irc.get_service_bot(user) if sbot: - sbot.part(irc, channel) + try: + sbot.remove_persistent_channel(irc, 'relay', channel) + except KeyError: + pass else: irc.part(user, channel, 'Channel delinked.') if user != irc.pseudoclient.uid and not irc.users[user].channels: