From 955ffbd012898ecc81c8759484d6cdab92f01a43 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 2 Jun 2015 16:39:13 -0700 Subject: [PATCH] Handle /whois replies for pseudoclient (IDLE server command) --- proto.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/proto.py b/proto.py index a3ffc56..8bf4dec 100644 --- a/proto.py +++ b/proto.py @@ -38,10 +38,6 @@ def _sendFromUser(irc, msg, user=None): user = irc.pseudoclient.uid irc.send(':%s %s' % (user, msg)) -def _join(irc, channel): - _sendFromUser(irc, "JOIN {channel} {ts} +nt :,{uid}".format(sid=irc.sid, - ts=int(time.time()), uid=irc.pseudoclient.uid, channel=channel)) - def _nicktoUid(irc, nick): for k, v in irc.users.items(): if v.nick == nick: @@ -56,7 +52,7 @@ def spawnClient(irc, nick, user, host, *args): irc.servers[irc.sid].users.append(uid) def connect(irc): - ts = int(time.time()) + irc.start_ts = ts = int(time.time()) host = irc.serverdata["hostname"] uid = next_uid(irc.sid) irc.pseudoclient = IrcUser('PyLink', ts, uid, 'pylink', host, @@ -84,7 +80,8 @@ def connect(irc): host=host, uid=uid)) f(':%s ENDBURST' % (irc.sid)) - _join(irc, irc.serverdata["channel"]) + _sendFromUser(irc, "JOIN {channel} {ts} +nt :,{uid}".format(sid=irc.sid, + ts=int(time.time()), uid=irc.pseudoclient.uid, channel=irc.serverdata['channel'])) # :7NU PING 7NU 0AL def handle_ping(irc, servernumeric, command, args): @@ -181,6 +178,15 @@ def handle_squit(irc, numeric, command, args): del irc.users[user] del irc.servers[split_server] +def handle_idle(irc, numeric, command, args): + """Handle the IDLE command, sent between servers in remote WHOIS queries.""" + # <- :70MAAAAAA IDLE 1MLAAAAIG + # -> :1MLAAAAIG IDLE 70MAAAAAA 1433036797 319 + sourceuser = numeric + targetuser = args[0] + _sendFromUser(irc, 'IDLE %s %s 0' % (sourceuser, irc.start_ts), + user=targetuser) + def handle_events(irc, data): # Each server message looks something like this: # :70M FJOIN #chat 1423790411 +AFPfjnt 6:5 7:5 9:5 :v,1SRAAESWE