3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-23 19:19:31 +01:00

core: move clearing channels on kick/part to coremods/handlers

This is for consistency with the rest of the state cleanup code.
This commit is contained in:
James Lu 2018-04-07 22:44:00 -07:00
parent 16faac83eb
commit c7159b9cad
2 changed files with 6 additions and 4 deletions

View File

@ -181,6 +181,12 @@ def _state_cleanup_core(irc, source, channel):
irc.name, source, irc.users[source].nick) irc.name, source, irc.users[source].nick)
irc._remove_client(source) irc._remove_client(source)
# Clear empty non-permanent channels.
if channel in irc.channels and not (irc._channels[channel].users or ((irc.cmodes.get('permanent'), None) \
in irc._channels[channel].modes)):
log.debug('(%s) state_cleanup: removing empty channel %s', irc.name, channel)
del irc._channels[channel]
def _state_cleanup_part(irc, source, command, args): def _state_cleanup_part(irc, source, command, args):
for channel in args['channels']: for channel in args['channels']:
_state_cleanup_core(irc, source, channel) _state_cleanup_core(irc, source, channel)

View File

@ -653,10 +653,6 @@ class IRCS2SProtocol(IRCCommonProtocol):
except IndexError: except IndexError:
reason = '' reason = ''
# Clear empty non-permanent channels.
if not (self._channels[channel].users or ((self.cmodes.get('permanent'), None) in self._channels[channel].modes)):
del self._channels[channel]
if channels: if channels:
return {'channels': channels, 'text': reason} return {'channels': channels, 'text': reason}