Add !disconnect to admin.py
This commit is contained in:
parent
80dd3bb5e1
commit
45c7ce6da5
1 changed files with 21 additions and 0 deletions
|
@ -50,6 +50,7 @@ class Module(ModuleManager.BaseModule):
|
|||
"""
|
||||
:help: Connect to a network
|
||||
:usage: <server id>
|
||||
: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)
|
||||
|
|
Loading…
Reference in a new issue