From 691a8178b2c8db325e01c1c49089651466cfb15f Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 12 Nov 2016 10:43:55 -0800 Subject: [PATCH] relay: implement 'showchan' with links info Closes #353. --- plugins/relay.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/plugins/relay.py b/plugins/relay.py index 3e77526..5c03538 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -1888,6 +1888,36 @@ def showuser(irc, source, args): if relaychannels and (irc.isOper(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.toLower(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.isOper(source) + secret = ('s', None) in c.modes + if secret and not verbose: + # Hide secret channels from normal users. + return + + else: + relayentry = getRelay((irc.name, 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.