From 89951aace5d8a4ee9de16925e0d8aae60cd75e33 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 3 Oct 2018 15:59:36 +0100 Subject: [PATCH] Add !connect in modules/admin.py --- modules/admin.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/admin.py b/modules/admin.py index 84ecad14..77260711 100644 --- a/modules/admin.py +++ b/modules/admin.py @@ -42,3 +42,27 @@ class Module(ModuleManager.BaseModule): :permission: reconnect """ event["server"].send_quit("Reconnecting") + + @utils.hook("received.command.connect", min_args=1) + def connect(self, event): + """ + :help: Connect to a network + :usage: + """ + id = event["args_split"][0] + if not id.isdigit(): + event["stderr"].write("Please provide a numeric server ID") + return + + id = int(id) + if not self.bot.database.servers.get(id): + event["stderr"].write("Unknown server ID") + return + + existing_server = self.bot.get_server(id) + if existing_server: + event["stderr"].write("Already connected to %s" % str( + existing_server)) + return + server = self.bot.add_server(id) + event["stdout"].write("Connecting to %s" % str(server))