From efbe71bc0e792c05426afa39acd673958b06d0b1 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 27 Nov 2019 13:13:42 +0000 Subject: [PATCH] add !servers command --- modules/stats.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/stats.py b/modules/stats.py index a5ca5127..8ccb88a2 100644 --- a/modules/stats.py +++ b/modules/stats.py @@ -147,14 +147,26 @@ class Module(ModuleManager.BaseModule): channels = [] for channel in event["server"].channels.values(): hidden = bool(HIDDEN_MODES&set(channel.modes.keys())) - if hidden and ( - event["is_channel"] and not channel == event["target"]): + if (hidden and + event["is_channel"] and + not channel == event["target"]): continue channels.append(channel.name) event["stdout"].write("Current channels: %s" % " ".join(sorted(channels))) + @utils.hook("received.command.servers") + @utils.kwarg("help", "List all servers (* = connected)") + @utils.kwarg("permission", "listservers") + def servers_command(self, event): + servers = [] + for id, alias in self.bot.database.servers.get_all(): + if not self.bot.get_server_by_id(id) == None: + alias = "*%s" % alias + servers.append(alias) + event["stdout"].write("Servers: %s" % ", ".join(sorted(servers))) + @utils.hook("api.get.modules") def modules_api(self, event): return list(self.bot.modules.modules.keys())