3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

protoocols.sjoinServer: only add prefix modes to channel state if our TS < theirs

This commit is contained in:
James Lu 2015-08-20 01:32:30 -07:00
parent 3fc5896f82
commit 1d245bf001
2 changed files with 10 additions and 2 deletions

View File

@ -74,6 +74,8 @@ def sjoinServer(irc, server, channel, users, ts=None):
orig_ts = irc.channels[channel].ts
ts = ts or orig_ts
if ts < orig_ts:
# If the TS we're sending is lower than the one that existing, clear the
# mode lists from our channel state and reset the timestamp.
log.debug('(%s) sjoinServer: resetting TS of %r from %s to %s (clearing modes)',
irc.name, channel, orig_ts, ts)
irc.channels[channel].ts = ts
@ -99,7 +101,9 @@ def sjoinServer(irc, server, channel, users, ts=None):
irc.users[user].channels.add(channel)
except KeyError: # Not initialized yet?
log.debug("(%s) sjoinServer: KeyError trying to add %r to %r's channel list?", irc.name, channel, user)
utils.applyModes(irc, channel, changedmodes)
if ts < orig_ts:
# Only save our prefix modes in the channel state if our TS is lower than theirs.
utils.applyModes(irc, channel, changedmodes)
namelist = ' '.join(namelist)
_send(irc, server, "FJOIN {channel} {ts} {modes} :{users}".format(
ts=ts, users=namelist, channel=channel,

View File

@ -80,6 +80,8 @@ def sjoinServer(irc, server, channel, users, ts=None):
orig_ts = irc.channels[channel].ts
ts = ts or orig_ts
if ts < orig_ts:
# If the TS we're sending is lower than the one that existing, clear the
# mode lists from our channel state and reset the timestamp.
log.debug('(%s) sjoinServer: resetting TS of %r from %s to %s (clearing modes)',
irc.name, channel, orig_ts, ts)
irc.channels[channel].ts = ts
@ -115,7 +117,9 @@ def sjoinServer(irc, server, channel, users, ts=None):
ts=ts, users=namelist, channel=channel,
modes=utils.joinModes(modes)))
irc.channels[channel].users.update(uids)
utils.applyModes(irc, channel, changedmodes)
if ts < orig_ts:
# Only save our prefix modes in the channel state if our TS is lower than theirs.
utils.applyModes(irc, channel, changedmodes)
def _sendModes(irc, numeric, target, modes, ts=None):
utils.applyModes(irc, target, modes)