From 298913200c832db8ff51d17ce0567dc5e2570b61 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 25 Aug 2018 00:52:34 -0400 Subject: [PATCH] clientbot: properly handle cases when the bot is told to kick itself - Treat kicks to the PyLink client as a real user kick instead of a virtual one - Forward on kick hooks if the PyLink client is kick target - this allows things like autorejoin to work Closes #377. --- protocols/clientbot.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index c9922d1..04dbbe9 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -182,7 +182,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): log.debug('(%s) kick: checking if target %s (nick: %s) is an internal client? %s', self.name, target, self.get_friendly_name(target), self.is_internal_client(target)) - if self.is_internal_client(target): + if self.is_internal_client(target) and (self.pseudoclient and source != self.pseudoclient.uid): # Target was one of our virtual clients. Just remove them from the state. self.handle_part(target, 'KICK', [channel, reason]) @@ -938,9 +938,11 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): except KeyError: pass - if (not self.is_internal_client(source)) and not self.is_internal_server(source): - # Don't repeat hooks if we're the kicker. - return {'channel': channel, 'target': target, 'text': reason} + # Don't repeat hooks if we're the kicker, unless we're also the target. + if self.is_internal_client(source) or self.is_internal_server(source): + if self.pseudoclient and target != self.pseudoclient.uid: + return + return {'channel': channel, 'target': target, 'text': reason} def handle_mode(self, source, command, args): """Handles MODE changes."""