Add !connect in modules/admin.py
This commit is contained in:
parent
69d58eede2
commit
89951aace5
1 changed files with 24 additions and 0 deletions
|
@ -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: <server id>
|
||||
"""
|
||||
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))
|
||||
|
|
Loading…
Reference in a new issue