From bbcd70b1756c543034026fbbf70c20def8dbe228 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 17 Jul 2015 22:00:25 -0700 Subject: [PATCH] relay: add 'linked' command (closes #65) --- plugins/relay.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/relay.py b/plugins/relay.py index a19436d..f0b95ec 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -706,3 +706,18 @@ def handle_disconnect(irc, numeric, command, args): handle_quit(irc, k[1], 'PYLINK_DISCONNECT', {'text': 'Home network lost connection.'}) utils.add_hook(handle_disconnect, "PYLINK_DISCONNECT") + +@utils.add_cmd +def linked(irc, source, args): + networks = list(utils.networkobjects.keys()) + networks.remove(irc.name) + s = 'Connected networks: \x02%s\x02 %s' % (irc.name, ' '.join(networks)) + utils.msg(irc, source, s) + # Sort relay DB by channel name, and then sort. + for k, v in sorted(db.items(), key=lambda channel: channel[0][1]): + s = '\x02%s%s\x02 ' % k + if v['links']: + s += ' '.join([''.join(link) for link in v['links']]) + else: + s += '(no relays yet)' + utils.msg(irc, source, s)