From: John Runyon Date: Wed, 8 May 2024 09:35:46 +0000 (-0600) Subject: fix exception when parting a channel X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/79519d5abd251267436256b6cc41f36872f39dbe?ds=sidebyside fix exception when parting a channel --- diff --git a/bot.py b/bot.py index fbb3999..fd92922 100644 --- a/bot.py +++ b/bot.py @@ -247,6 +247,10 @@ class Bot(object): for u in chan.users: if u.nick != self.nick: self._clientLeft(u.nick, chan) + if chan.deleting: + chan.bot.chans.remove(chan) + del self.parent.chans[chan.name.lower()] + del chan else: user = self.parent.user(nick) gone = user.part(chan) diff --git a/erebus.py b/erebus.py index 12be844..9c9f46f 100644 --- a/erebus.py +++ b/erebus.py @@ -124,6 +124,8 @@ class Erebus(object): #singleton to pass around self.voices = [] self.ops = [] + self.deleting = False # if true, the bot will remove cached records of this channel when the bot sees that it has left the channel + c = main.query("SELECT user, level FROM chusers WHERE chan = %s", (self.name,)) if c: row = c.fetchone() diff --git a/modules/admin_channel.py b/modules/admin_channel.py index 68e15e5..88a6c5a 100644 --- a/modules/admin_channel.py +++ b/modules/admin_channel.py @@ -62,8 +62,7 @@ def join(bot, user, chan, realtarget, *args): def _part(user, chan): - chan.bot.chans.remove(chan) - del lib.parent.chans[chan.name.lower()] + chan.deleting = True lib.parent.query("DELETE FROM chusers WHERE chan = %s", (chan,)) lib.parent.query("DELETE FROM chans WHERE chname = %s", (chan,)) chan.bot.part(chan)