diff --git a/src/irclib.py b/src/irclib.py index 010d6a482..3941354d7 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -498,7 +498,11 @@ class IrcState(IrcCommandDispatcher): (channel, users) = msg.args[:2] chan = self.channels[channel] for user in users.split(','): - chan.removeUser(user) + if ircutils.strEqual(user, irc.nick): + del self.channels[channel] + return + else: + chan.removeUser(user) def doQuit(self, irc, msg): for channel in self.channels.itervalues(): diff --git a/test/test_irclib.py b/test/test_irclib.py index ca0e4e57d..2fba1484c 100644 --- a/test/test_irclib.py +++ b/test/test_irclib.py @@ -210,6 +210,13 @@ class IrcStateTestCase(SupyTestCase): nick = 'nick' prefix = 'nick!user@host' irc = FakeIrc() + def testKickRemovesChannel(self): + st = irclib.IrcState() + st.channels['#foo'] = irclib.ChannelState() + m = ircmsgs.kick('#foo', self.irc.nick, prefix=self.irc.prefix) + st.addMsg(self.irc, m) + self.failIf('#foo' in st.channels) + def testAddMsgRemovesOpsProperly(self): st = irclib.IrcState() st.channels['#foo'] = irclib.ChannelState()