From b1b2394836813a89bd5f605d132dd928a5b14ee9 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 7 Aug 2017 00:05:44 -0700 Subject: [PATCH] ircs2s_common: ignore PART for channels that the user wasn't on These extra parts caused issues with relay when receiving P10 KICK acknowledgements as they are treated as if the user was already in the channel. --- protocols/ircs2s_common.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index ee6ec75..5f3244d 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -609,7 +609,11 @@ class IRCS2SProtocol(IRCCommonProtocol): """Handles incoming PART commands.""" channels = self.to_lower(args[0]).split(',') - for channel in channels: + for channel in channels.copy(): + if source not in channel: + # Ignore channels the user isn't on, and remove them from any hook payloads. + channels.remove(channel) + self.channels[channel].remove_user(source) try: self.users[source].channels.discard(channel) @@ -625,7 +629,8 @@ class IRCS2SProtocol(IRCCommonProtocol): if not (self.channels[channel].users or ((self.cmodes.get('permanent'), None) in self.channels[channel].modes)): del self.channels[channel] - return {'channels': channels, 'text': reason} + if channels: + return {'channels': channels, 'text': reason} def handle_privmsg(self, source, command, args): """Handles incoming PRIVMSG/NOTICE."""