diff --git a/plugins/commands.py b/plugins/commands.py index f69571c..3bb7fbb 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -77,6 +77,35 @@ def _do_showuser(irc, source, u): f('\x02PyLink identification\x02: %s; \x02Services account\x02: %s; \x02Away status\x02: %s' % \ ((userobj.account or _none), (userobj.services_account or _none), userobj.away or _none)) + # Show relay user data if available + relay = world.plugins.get('relay') + if relay: + try: + userpair = relay.get_orig_user(irc, u) or (irc.name, u) + remoteusers = relay.relayusers[userpair].items() + except KeyError: + pass + else: + nicks = [] + if remoteusers: + # Display all of the user's relay subclients, if there are any + nicks.append('%s:\x02%s\x02' % (userpair[0], + world.networkobjects[userpair[0]].users[userpair[1]].nick)) + for r in remoteusers: + remotenet, remoteuser = r + remoteirc = world.networkobjects[remotenet] + nicks.append('%s:\x02%s\x02' % (remotenet, remoteirc.users[remoteuser].nick)) + irc.reply("\x02Relay nicks\x02: %s" % ', '.join(nicks), private=True) + if verbose: + # Show the relay channels the user is in, if applicable + relaychannels = [] + for ch in irc.users[u].channels: + relayentry = relay.get_relay(irc, ch) + if relayentry: + relaychannels.append(''.join(relayentry)) + if relaychannels and verbose: + irc.reply("\x02Relay channels\x02: %s" % ' '.join(relaychannels), private=True) + @utils.add_cmd def showuser(irc, source, args): """ @@ -147,6 +176,15 @@ def showchan(irc, source, args): f('\x02User list\x02: %s' % ' '.join(nicklist)) + # Show relay info, if applicable + relay = world.plugins.get('relay') + if relay: + relayentry = relay.get_relay(irc, channel) + if relayentry: + relays = ['\x02%s\x02' % ''.join(relayentry)] + relays += [''.join(link) for link in relay.db[relayentry]['links']] + f('\x02Relayed channels:\x02 %s' % (' '.join(relays))) + @utils.add_cmd def version(irc, source, args): """takes no arguments. diff --git a/plugins/relay.py b/plugins/relay.py index 812523b..b360971 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -2709,73 +2709,6 @@ def linkacl(irc, source, args): else: irc.error('Unknown subcommand %r: valid ones are ALLOW, DENY, and LIST.' % cmd) -@utils.add_cmd -def showuser(irc, source, args): - """ - - Shows relay data about the given user. This supplements the 'showuser' command in the 'commands' plugin, which provides more general information.""" - try: - target = args[0] - except IndexError: - # No errors here; showuser from the commands plugin already does this - # for us. - return - u = irc.nick_to_uid(target) - if u: - irc.reply("Showing relay information on user \x02%s\x02:" % irc.users[u].nick, private=True) - try: - userpair = get_orig_user(irc, u) or (irc.name, u) - remoteusers = relayusers[userpair].items() - except KeyError: - pass - else: - nicks = [] - if remoteusers: - nicks.append('%s:\x02%s\x02' % (userpair[0], - world.networkobjects[userpair[0]].users[userpair[1]].nick)) - for r in remoteusers: - remotenet, remoteuser = r - remoteirc = world.networkobjects[remotenet] - nicks.append('%s:\x02%s\x02' % (remotenet, remoteirc.users[remoteuser].nick)) - irc.reply("\x02Relay nicks\x02: %s" % ', '.join(nicks), private=True) - relaychannels = [] - for ch in irc.users[u].channels: - relay = get_relay(irc, ch) - if relay: - relaychannels.append(''.join(relay)) - if relaychannels and (irc.is_oper(source) or u == source): - irc.reply("\x02Relay channels\x02: %s" % ' '.join(relaychannels), private=True) - -@utils.add_cmd -def showchan(irc, source, args): - """ - - Shows relay data about the given channel. This supplements the 'showchan' command in the 'commands' plugin, which provides more general information.""" - try: - channel = irc.to_lower(args[0]) - except IndexError: - return - if channel not in irc.channels: - return - - f = lambda s: irc.reply(s, private=True) - - c = irc.channels[channel] - - # Only show verbose info if caller is oper or is in the target channel. - verbose = source in c.users or irc.is_oper(source) - secret = ('s', None) in c.modes - if secret and not verbose: - # Hide secret channels from normal users. - return - - else: - relayentry = get_relay(irc, channel) - if relayentry: - relays = ['\x02%s\x02' % ''.join(relayentry)] - relays += [''.join(link) for link in db[relayentry]['links']] - f('\x02Relayed channels:\x02 %s' % (' '.join(relays))) - @utils.add_cmd def save(irc, source, args): """takes no arguments.