From c7159b9cad99b1bbc2513acb61422e8579e1ffae Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 7 Apr 2018 22:44:00 -0700 Subject: [PATCH] core: move clearing channels on kick/part to coremods/handlers This is for consistency with the rest of the state cleanup code. --- coremods/handlers.py | 6 ++++++ protocols/ircs2s_common.py | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/coremods/handlers.py b/coremods/handlers.py index 76c0825..3b09273 100644 --- a/coremods/handlers.py +++ b/coremods/handlers.py @@ -181,6 +181,12 @@ def _state_cleanup_core(irc, source, channel): irc.name, source, irc.users[source].nick) 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): for channel in args['channels']: _state_cleanup_core(irc, source, channel) diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index d0704d0..2e46fe9 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -653,10 +653,6 @@ class IRCS2SProtocol(IRCCommonProtocol): except IndexError: 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: return {'channels': channels, 'text': reason}