add !servers command

This commit is contained in:
jesopo 2019-11-27 13:13:42 +00:00
parent 4914c47401
commit efbe71bc0e

View file

@ -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())