3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

relay: attempt to remove persistent channels on delink as well

Also, wrap remove_persistent_channel calls with a try/except when they may fail.
This commit is contained in:
James Lu 2018-05-05 12:57:17 -07:00
parent 8994811f54
commit 92be421fad

View File

@ -539,7 +539,10 @@ def remove_channel(irc, channel):
if irc is None: if irc is None:
return 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) relay = get_relay(irc, channel)
if relay and channel in irc.channels: if relay and channel in irc.channels:
@ -554,7 +557,10 @@ def remove_channel(irc, channel):
# have the channel registered. # have the channel registered.
sbot = irc.get_service_bot(user) sbot = irc.get_service_bot(user)
if sbot: if sbot:
sbot.part(irc, channel) try:
sbot.remove_persistent_channel(irc, 'relay', channel)
except KeyError:
pass
else: else:
irc.part(user, channel, 'Channel delinked.') irc.part(user, channel, 'Channel delinked.')
if user != irc.pseudoclient.uid and not irc.users[user].channels: if user != irc.pseudoclient.uid and not irc.users[user].channels: