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

protocols: delete empty non-permanent channels

This commit is contained in:
James Lu 2015-08-15 23:29:40 -07:00
parent 3b83c3d567
commit 61d95c19cc
2 changed files with 10 additions and 2 deletions

View File

@ -122,8 +122,12 @@ def removeClient(irc, numeric):
Removes a client from our internal databases, regardless
of whether it's one of our pseudoclients or not."""
for v in irc.channels.values():
for c, v in irc.channels.copy().items():
v.removeuser(numeric)
# Clear empty non-permanent channels.
if not (irc.channels[c].users or ((irc.cmodes.get('permanent'), None) in irc.channels[c].modes)):
del irc.channels[c]
sid = numeric[:3]
log.debug('Removing client %s from irc.users', numeric)
del irc.users[numeric]
@ -366,6 +370,9 @@ def handle_part(irc, source, command, args):
reason = args[1]
except IndexError:
reason = ''
# Clear empty non-permanent channels.
if not (irc.channels[channel].users or ((irc.cmodes.get('permanent'), None) in irc.channels[channel].modes)):
del irc.channels[channel]
return {'channels': channels, 'text': reason}
def handle_error(irc, numeric, command, args):

View File

@ -378,9 +378,10 @@ def handle_part(irc, source, command, args):
reason = args[1]
except IndexError:
reason = ''
if not (irc.channels[channel].users or ((irc.cmodes.get('permanent'), None) in irc.channels[channel].modes)):
del irc.channels[channel]
return {'channels': channels, 'text': reason}
def handle_sjoin(irc, servernumeric, command, args):
# parameters: channelTS, channel, simple modes, opt. mode parameters..., nicklist
channel = args[1].lower()