mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-17 23:52:49 +01:00
unreal: use Protocol.updateTS() for TS checks
This commit is contained in:
parent
619b004bdf
commit
119aa8939b
@ -76,11 +76,10 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
self.irc.channels[channel].users.add(client)
|
self.irc.channels[channel].users.add(client)
|
||||||
self.irc.users[client].channels.add(channel)
|
self.irc.users[client].channels.add(channel)
|
||||||
|
|
||||||
|
|
||||||
def sjoinServer(self, server, channel, users, ts=None):
|
def sjoinServer(self, server, channel, users, ts=None):
|
||||||
"""Sends an SJOIN for a group of users to a channel.
|
"""Sends an SJOIN for a group of users to a channel.
|
||||||
|
|
||||||
The sender should always be a Server ID (SID). TS is optional, and defaults
|
The sender should always be a server (SID). TS is optional, and defaults
|
||||||
to the one we've stored in the channel state if not given.
|
to the one we've stored in the channel state if not given.
|
||||||
<users> is a list of (prefix mode, UID) pairs:
|
<users> is a list of (prefix mode, UID) pairs:
|
||||||
|
|
||||||
@ -100,17 +99,11 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
assert users, "sjoinServer: No users sent?"
|
assert users, "sjoinServer: No users sent?"
|
||||||
if not server:
|
if not server:
|
||||||
raise LookupError('No such PyLink server exists.')
|
raise LookupError('No such PyLink server exists.')
|
||||||
|
|
||||||
orig_ts = self.irc.channels[channel].ts
|
orig_ts = self.irc.channels[channel].ts
|
||||||
ts = ts or orig_ts
|
ts = ts or orig_ts
|
||||||
if ts < orig_ts:
|
self.updateTS(channel, 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)',
|
|
||||||
self.irc.name, channel, orig_ts, ts)
|
|
||||||
self.irc.channels[channel].ts = ts
|
|
||||||
self.irc.channels[channel].modes.clear()
|
|
||||||
for p in self.irc.channels[channel].prefixmodes.values():
|
|
||||||
p.clear()
|
|
||||||
changedmodes = []
|
changedmodes = []
|
||||||
uids = []
|
uids = []
|
||||||
namelist = []
|
namelist = []
|
||||||
@ -383,16 +376,10 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
# Interestingly, no modes are ever sent in this command as far as I've seen.
|
# Interestingly, no modes are ever sent in this command as far as I've seen.
|
||||||
channel = utils.toLower(self.irc, args[1])
|
channel = utils.toLower(self.irc, args[1])
|
||||||
userlist = args[-1].split()
|
userlist = args[-1].split()
|
||||||
|
|
||||||
our_ts = self.irc.channels[channel].ts
|
our_ts = self.irc.channels[channel].ts
|
||||||
their_ts = int(args[0])
|
their_ts = int(args[0])
|
||||||
if their_ts < our_ts and their_ts > 0:
|
self.updateTS(self, channel, their_ts)
|
||||||
# Channel timestamp was reset on burst
|
|
||||||
log.debug('(%s) Setting channel TS of %s to %s from %s',
|
|
||||||
self.irc.name, channel, their_ts, our_ts)
|
|
||||||
self.irc.channels[channel].ts = their_ts
|
|
||||||
self.irc.channels[channel].modes.clear()
|
|
||||||
for p in self.irc.channels[channel].prefixmodes.values():
|
|
||||||
p.clear()
|
|
||||||
|
|
||||||
namelist = []
|
namelist = []
|
||||||
log.debug('(%s) handle_sjoin: got userlist %r for %r', self.irc.name, userlist, channel)
|
log.debug('(%s) handle_sjoin: got userlist %r for %r', self.irc.name, userlist, channel)
|
||||||
@ -446,16 +433,8 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
utils.applyModes(self.irc, channel, parsedmodes)
|
utils.applyModes(self.irc, channel, parsedmodes)
|
||||||
if numeric in self.irc.servers and args[-1].isdigit():
|
if numeric in self.irc.servers and args[-1].isdigit():
|
||||||
# Sender is a server AND last arg is number. Perform TS updates.
|
# Sender is a server AND last arg is number. Perform TS updates.
|
||||||
our_ts = self.irc.channels[channel].ts
|
|
||||||
their_ts = int(args[-1])
|
their_ts = int(args[-1])
|
||||||
if their_ts < our_ts and their_ts > 0:
|
self.updateTS(channel, their_ts)
|
||||||
# Channel timestamp was reset on burst
|
|
||||||
log.debug('(%s) Setting channel TS of %s to %s from %s',
|
|
||||||
self.irc.name, channel, their_ts, our_ts)
|
|
||||||
self.irc.channels[channel].ts = their_ts
|
|
||||||
self.irc.channels[channel].modes.clear()
|
|
||||||
for p in self.irc.channels[channel].prefixmodes.values():
|
|
||||||
p.clear()
|
|
||||||
return {'target': channel, 'modes': parsedmodes, 'oldchan': oldobj}
|
return {'target': channel, 'modes': parsedmodes, 'oldchan': oldobj}
|
||||||
else:
|
else:
|
||||||
log.warning("(%s) received MODE for non-channel target: %r",
|
log.warning("(%s) received MODE for non-channel target: %r",
|
||||||
|
Loading…
Reference in New Issue
Block a user