3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-02 15:44:06 +01:00

relay: implement 'showchan' with links info

Closes #353.
This commit is contained in:
James Lu 2016-11-12 10:43:55 -08:00
parent e570779a03
commit 691a8178b2

View File

@ -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):
"""<user>
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.