3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

clientbot: stop sending duplicate JOIN hooks

Also set _clientbot_initial_who_received on 315/ENDOFWHO, instead of on the first /who response we get.

Really fixes #551.
This commit is contained in:
James Lu 2018-05-09 22:31:19 -07:00
parent 451db74f0c
commit 3120fa5396

View File

@ -768,7 +768,6 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
self.update_client(uid, 'HOST', host)
self.update_client(uid, 'GECOS', realname)
self.users[uid]._clientbot_identhost_received = True
self._channels[channel]._clientbot_initial_who_received = True
# The status given uses the following letters: <H|G>[*][@|+]
# H means here (not marked /away)
@ -822,6 +821,9 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
c = self._channels[channel]
modes = set(c.modes)
bursted_before = hasattr(c, '_clientbot_initial_who_received')
queued_users = []
for user in users.copy():
# Fill in prefix modes of everyone when doing mock SJOIN.
try:
@ -834,7 +836,14 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
log.debug("(%s) Ignoring KeyError (%s) from WHO response; it's probably someone we "
"don't share any channels with", self.name, e)
if users:
if bursted_before and user in c.users:
log.debug("(%s) Skipping join of %s/%s to %r", self.name, user,
self.get_friendly_name(user), channel)
continue
queued_users.append(user)
c._clientbot_initial_who_received = True
if queued_users:
return {'channel': channel, 'users': users, 'modes': modes,
'parse_as': "JOIN"}