3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

clientbot: don't update state on join()

Wait for NAMES instead to make sure that the join attempt actually succeeded. #299
This commit is contained in:
James Lu 2016-08-11 11:23:41 -07:00
parent 7a0a013c43
commit 3a0a2c7f1c

View File

@ -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}])