]> jfr.im git - erebus.git/commitdiff
fix exception when parting a channel
authorJohn Runyon <redacted>
Wed, 8 May 2024 09:35:46 +0000 (03:35 -0600)
committerJohn Runyon <redacted>
Wed, 8 May 2024 09:40:14 +0000 (03:40 -0600)
bot.py
erebus.py
modules/admin_channel.py

diff --git a/bot.py b/bot.py
index fbb399991ddba703dc4ff821926de7bc2659d101..fd9292295aa3d2051d729d8e8e6a6e1b5b73b8a2 100644 (file)
--- 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)
                        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)
                else:
                        user = self.parent.user(nick)
                        gone = user.part(chan)
index 12be844b4388acf1fd77980abb4731cb80eed7b5..9c9f46fee900ce31943abd6a5c22482ad42d91db 100644 (file)
--- a/erebus.py
+++ b/erebus.py
@@ -124,6 +124,8 @@ class Erebus(object): #singleton to pass around
                        self.voices = []
                        self.ops = []
 
                        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()
                        c = main.query("SELECT user, level FROM chusers WHERE chan = %s", (self.name,))
                        if c:
                                row = c.fetchone()
index 68e15e53732e911a6ce642f2b63113d0cf3d03a6..88a6c5af6efc8e59da8303f35f2606d015f14772 100644 (file)
@@ -62,8 +62,7 @@ def join(bot, user, chan, realtarget, *args):
 
 
 def _part(user, chan):
 
 
 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)
        lib.parent.query("DELETE FROM chusers WHERE chan = %s", (chan,))
        lib.parent.query("DELETE FROM chans WHERE chname = %s", (chan,))
        chan.bot.part(chan)