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