From 440a33601057b20fe0d49e5f5299b488ac19a9c5 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 22 Jun 2003 16:17:33 +0000 Subject: [PATCH] Added relaywhois command. --- plugins/Relay.py | 51 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/plugins/Relay.py b/plugins/Relay.py index 2fd565f1a..ce77d9c8b 100644 --- a/plugins/Relay.py +++ b/plugins/Relay.py @@ -36,9 +36,10 @@ Handles relaying between networks. from baseplugin import * import re -import copy +import time import conf +import utils import ircdb import irclib import drivers @@ -90,6 +91,7 @@ class Relay(callbacks.Privmsg): def __init__(self): callbacks.Privmsg.__init__(self) self.ircs = {} + self.whois = {} self.started = False self.ircstates = {} self.lastmsg = ircmsgs.ping('this is just a fake message') @@ -213,7 +215,50 @@ class Relay(callbacks.Privmsg): usersS = ', '.join([s for s in Channel.users if s.strip()!='']) users.append('\x02%s\x02: %s' % (abbreviation, usersS)) irc.reply(msg, '; '.join(users)) - + + def relaywhois(self, irc, msg, args): + """@ + + Returns the WHOIS response gives for . + """ + nickAtNetwork = privmsgs.getArgs(args) + (nick, network) = nickAtNetwork.split('@', 1) + if network not in self.ircs: + irc.error(msg, 'I\'m not on that network.') + return + otherIrc = self.ircs[network] + otherIrc.queueMsg(ircmsgs.whois(nick)) + self.whois[(otherIrc, nick)] = (irc, msg, {}) + + def do311(self, irc, msg): + if not isinstance(irc, irclib.Irc): + realIrc = irc.getRealIrc() + nick = msg.args[1] + if (realIrc, nick) not in self.whois: + return + else: + self.whois[(realIrc, nick)][-1][msg.command] = msg + + do312 = do311 + do317 = do311 + do319 = do311 + + def do318(self, irc, msg): + if not isinstance(irc, irclib.Irc): + realIrc = irc.getRealIrc() + nick = msg.args[1] + if (realIrc, nick) not in self.whois: + return + (replyIrc, replyMsg, d) = self.whois[(realIrc, nick)] + hostmask = '@'.join(d['311'].args[2:]) + channels = d['319'].args[-1].split() + channels = ', and '.join([', '.join(channels[:-1]), channels[-1]]) + idle = utils.timeElapsed(d['317'].args[2]) + signon = time.ctime(d['317'][3]) + s = '%s (%s) has been online since %s (idle for %s) and is on %s' % \ + (nick, hostmask, signon, idle, channels) + replyIrc.reply(replyMsg, s) + def _formatPrivmsg(self, nick, abbreviation, msg): if ircmsgs.isAction(msg): return '* %s@%s %s' % (nick, abbreviation, ircmsgs.unAction(msg)) @@ -293,7 +338,7 @@ class Relay(callbacks.Privmsg): if not isinstance(irc, irclib.Irc): irc = irc.getRealIrc() network = self.abbreviations[irc] - if len(msg.args) > 0: + if msg.args: s = '%s has quit %s (%s)' % (msg.nick, network, msg.args[0]) else: s = '%s has quit %s.' % (msg.nick, network)