Remove channel information after being kicked or parting.

Also fixed _destroy_channel() to remove any users not in common anymore as a result of leaving the channel.
This commit is contained in:
Shiz 2014-02-05 11:15:24 +01:00
parent 2d337a935c
commit 62298e7a44
1 changed files with 10 additions and 5 deletions

View File

@ -200,6 +200,8 @@ class BasicClient:
} }
def _destroy_channel(self, channel): def _destroy_channel(self, channel):
for user in self.channels[channel]['users']:
self._destroy_user(user, channel)
del self.channels[channel] del self.channels[channel]
@ -635,10 +637,13 @@ class BasicClient:
for channel, target in zip(channels, targets): for channel, target in zip(channels, targets):
target, targetuser, targethost = protocol.parse_user(target) target, targetuser, targethost = protocol.parse_user(target)
self._sync_user(target, targetuser, targethost) self._sync_user(target, targetuser, targethost)
# Update nick list on channel. if self.is_same_nick(target, self.nickname):
if self.in_channel(channel): self._destroy_channel(channel)
self._destroy_user(target, channel) else:
# Update nick list on channel.
if self.in_channel(channel):
self._destroy_user(target, channel)
self.on_kick(channel, target, kicker, reason) self.on_kick(channel, target, kicker, reason)
@ -727,7 +732,7 @@ class BasicClient:
# We left the channel. Remove from channel list. :( # We left the channel. Remove from channel list. :(
for channel in channels: for channel in channels:
if self.in_channel(channel): if self.in_channel(channel):
del self.channels[channel] self._destroy_channel(channel)
else: else:
# Someone else left. Remove them. # Someone else left. Remove them.
for ch in channels: for ch in channels: