From 3a0a2c7f1cfea919996d2724ef2f7017c070d796 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 11 Aug 2016 11:23:41 -0700 Subject: [PATCH] clientbot: don't update state on join() Wait for NAMES instead to make sure that the join attempt actually succeeded. #299 --- protocols/clientbot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index a3ed2bf..41483c3 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -122,15 +122,17 @@ class ClientbotWrapperProtocol(Protocol): """STUB: Joins a user to a channel.""" channel = self.irc.toLower(channel) - self.irc.channels[channel].users.add(client) - self.irc.users[client].channels.add(channel) - # Only joins for the main PyLink client are actually forwarded. Others are ignored. + # Note: we do not automatically add our main client to the channel state, as we + # rely on the /NAMES reply to sync it up properly. if self.irc.pseudoclient and client == self.irc.pseudoclient.uid: self.irc.send('JOIN %s' % channel) # Send a /who request right after self.irc.send('WHO %s' % channel) else: + self.irc.channels[channel].users.add(client) + self.irc.users[client].channels.add(channel) + log.debug('(%s) join: faking JOIN of client %s/%s to %s', self.irc.name, client, self.irc.getFriendlyName(client), channel) self.irc.callHooks([client, 'CLIENTBOT_JOIN', {'channel': channel}])