diff --git a/classes.py b/classes.py index 3b95142..2aabfae 100644 --- a/classes.py +++ b/classes.py @@ -1,4 +1,5 @@ from collections import defaultdict +import time class IrcUser(): def __init__(self, nick, ts, uid, ident='null', host='null', @@ -40,6 +41,7 @@ class IrcChannel(): self.users = set() self.modes = set() self.topic = '' + self.ts = int(time.time()) self.prefixmodes = {'ops': set(), 'halfops': set(), 'voices': set(), 'owners': set(), 'admins': set()} diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 58faf90..ebff9cb 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -55,7 +55,7 @@ def joinClient(irc, client, channel): raise ValueError('Invalid channel name %r.' % channel) # One channel per line here! _sendFromServer(irc, server, "FJOIN {channel} {ts} {modes} :,{uid}".format( - ts=int(time.time()), uid=client, channel=channel, + ts=irc.channels[channel].ts, uid=client, channel=channel, modes=utils.joinModes(irc.channels[channel].modes))) irc.channels[channel].users.add(client) @@ -151,10 +151,7 @@ def handle_privmsg(irc, source, command, args): if args[0] == irc.pseudoclient.uid: cmd_args = args[1].split(' ') cmd = cmd_args[0].lower() - try: - cmd_args = cmd_args[1:] - except IndexError: - cmd_args = [] + cmd_args = cmd_args[1:] try: func = utils.bot_commands[cmd] except KeyError: @@ -205,7 +202,13 @@ def handle_fjoin(irc, servernumeric, command, args): channel = args[0].lower() # InspIRCd sends each user's channel data in the form of 'modeprefix(es),UID' userlist = args[-1].split() - ts = args[1] + our_ts = irc.channels[channel].ts + their_ts = int(args[1]) + if their_ts < our_ts: + # Channel timestamp was reset on burst + log.debug('(%s) Setting channel TS of %s to %s from %s', + irc.name, channel, their_ts, our_ts) + irc.channels[channel].ts = their_ts modestring = args[2:-1] or args[2] utils.applyModes(irc, channel, utils.parseModes(irc, channel, modestring)) namelist = []