Fixed relaywhois to not require the network if the relay is only relaying between two networks. Also fixed a possible later UnboundLocalError in a few places.

This commit is contained in:
Jeremy Fincher 2003-08-25 06:48:28 +00:00
parent c6f1d74d34
commit a92798c9d8

View File

@ -135,6 +135,9 @@ class Relay(callbacks.Privmsg):
relaying messages from that network to other networks, the users relaying messages from that network to other networks, the users
will show up as 'user@oftc'. will show up as 'user@oftc'.
""" """
if isinstance(irc, irclib.Irc):
realIrc = irc
else:
realIrc = irc.getRealIrc() realIrc = irc.getRealIrc()
self.originalIrc = realIrc self.originalIrc = realIrc
abbreviation = privmsgs.getArgs(args) abbreviation = privmsgs.getArgs(args)
@ -152,6 +155,9 @@ class Relay(callbacks.Privmsg):
that network to other networks. that network to other networks.
""" """
abbreviation, server = privmsgs.getArgs(args, needed=2) abbreviation, server = privmsgs.getArgs(args, needed=2)
if isinstance(irc, irclib.Irc):
realIrc = irc
else:
realIrc = irc.getRealIrc() realIrc = irc.getRealIrc()
if ':' in server: if ':' in server:
(server, port) = server.split(':') (server, port) = server.split(':')
@ -240,7 +246,9 @@ class Relay(callbacks.Privmsg):
the channel itself. Returns the nicks of the people in the channel on the channel itself. Returns the nicks of the people in the channel on
the various networks the bot is connected to. the various networks the bot is connected to.
""" """
if not isinstance(irc, irclib.Irc): if isinstance(irc, irclib.Irc):
realIrc = irc
else:
realIrc = irc.getRealIrc() realIrc = irc.getRealIrc()
channel = privmsgs.getChannel(msg, args) channel = privmsgs.getChannel(msg, args)
if channel not in self.channels: if channel not in self.channels:
@ -260,10 +268,22 @@ class Relay(callbacks.Privmsg):
Returns the WHOIS response <network> gives for <nick>. Returns the WHOIS response <network> gives for <nick>.
""" """
nickAtNetwork = privmsgs.getArgs(args) nickAtNetwork = privmsgs.getArgs(args)
if isinstance(irc, irclib.Irc):
realIrc = irc
else:
realIrc = irc.getRealIrc()
try: try:
(nick, network) = nickAtNetwork.split('@', 1) (nick, network) = nickAtNetwork.split('@', 1)
nick = ircutils.toLower(nick) nick = ircutils.toLower(nick)
except ValueError: except ValueError:
if len(self.abbreviations) == 2:
# If there are only two networks being relayed, we can safely
# pick the *other* one.
nick = ircutils.toLower(nickAtNetwork)
for (keyIrc, net) in self.abbreviations.iteritems():
if keyIrc != realIrc:
network = net
else:
raise callbacks.ArgumentError raise callbacks.ArgumentError
if network not in self.ircs: if network not in self.ircs:
irc.error(msg, 'I\'m not on that network.') irc.error(msg, 'I\'m not on that network.')