From 45c7ce6da5c637fff1bf20de4c78bc8a01e2d10e Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 20 Nov 2018 14:27:24 +0000 Subject: [PATCH] Add !disconnect to admin.py --- modules/admin.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/admin.py b/modules/admin.py index 118ff4c9..4406b78a 100644 --- a/modules/admin.py +++ b/modules/admin.py @@ -50,6 +50,7 @@ class Module(ModuleManager.BaseModule): """ :help: Connect to a network :usage: + :permission: connect """ id = event["args_split"][0] if not id.isdigit(): @@ -66,3 +67,23 @@ class Module(ModuleManager.BaseModule): server = self.bot.add_server(id) event["stdout"].write("Connecting to %s" % str(server)) + + @utils.hook("received.command.disconnect") + def disconnect(self, event): + """ + :help: Disconnect from a server + :usage: [server id] + :permission: disconnect + """ + id = event["server"].id + if event["args"]: + id = event["args_split"][0] + if not id.isdigit(): + raise utils.EventError("Please provide a numeric server ID") + + id = int(id) + if not self.bot.database.servers.get(id): + raise utils.EventError("Unknown server ID") + server = self.bot.get_server(id) + server.disconnect() + self.bot.disconnect(server)