Add .reloadallmodules, and fix permissions.
This commit is contained in:
parent
8b8c59ee21
commit
1d3f05a8fe
2 changed files with 35 additions and 6 deletions
|
@ -3,16 +3,23 @@
|
|||
class Module(object):
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
self.module_name = False
|
||||
self.silent = False
|
||||
|
||||
events.on("received.command.loadmodule").hook(self.load,
|
||||
min_args=1, permission="load-module", help="Load a module",
|
||||
usage="<module-name>")
|
||||
events.on("received.command.unloadmodule").hook(self.unload,
|
||||
min_args=1, permission="unload-module", help="Unload a module",
|
||||
usage="<module-name>")
|
||||
|
||||
events.on("received.command.reloadmodule").hook(self.reload,
|
||||
min_args=1, permission="reload-module", help="Reload a module",
|
||||
min_args=1, permission="reload-module", help="Reoad a module",
|
||||
usage="<module-name>")
|
||||
|
||||
events.on("received.command.reloadallmodules").hook(self.reload_all,
|
||||
permission="reload-module", help="Reload all modules")
|
||||
|
||||
events.on("received.command.enablemodule").hook(self.enable,
|
||||
min_args=1, permission="enable-module", help="Enable a module",
|
||||
usage="<module-name>")
|
||||
|
@ -37,13 +44,35 @@ class Module(object):
|
|||
event["stdout"].write("Unloaded '%s'" % name)
|
||||
|
||||
def reload(self, event):
|
||||
name = event["args_split"][0].lower()
|
||||
name = self.module_name if self.module_name != False else event[
|
||||
"args_split"][0].lower()
|
||||
if not name in self.bot.modules.modules:
|
||||
event["stderr"].write("Module '%s' isn't loaded" % name)
|
||||
if self.silent == False:
|
||||
event["stderr"].write("Module '%s' isn't loaded" % name)
|
||||
return
|
||||
self.bot.modules.unload_module(name)
|
||||
self.bot.modules.load_module(name)
|
||||
event["stdout"].write("Reloaded '%s'" % name)
|
||||
|
||||
if self.silent == False:
|
||||
event["stdout"].write("Reloaded '%s'" % name)
|
||||
|
||||
def reload_all(self, event):
|
||||
modules_reloaded = []
|
||||
self.silent = True
|
||||
|
||||
for name, value in self.bot.modules.modules.items():
|
||||
if name in modules_reloaded:
|
||||
pass
|
||||
|
||||
self.module_name = name
|
||||
self.reload(event)
|
||||
modules_reloaded.append(name)
|
||||
|
||||
event["stdout"].write("Reloaded modules: %s" % \
|
||||
" ".join(modules_reloaded))
|
||||
|
||||
self.silent = False
|
||||
self.module_name = False
|
||||
|
||||
def enable(self, event):
|
||||
name = event["args_split"][0].lower()
|
||||
|
|
|
@ -177,7 +177,7 @@ class Module(object):
|
|||
target, registered, permissions = self._get_user_details(
|
||||
event["server"], event["args_split"][0])
|
||||
|
||||
if not registered:
|
||||
if target.identified_account == None:
|
||||
event["stderr"].write("%s isn't registered" % target.nickname)
|
||||
return
|
||||
|
||||
|
@ -194,7 +194,7 @@ class Module(object):
|
|||
target, registered, permissions = self._get_user_details(
|
||||
event["server"], event["args_split"][0])
|
||||
|
||||
if not registered:
|
||||
if target.identified_account == None:
|
||||
event["stderr"].write("%s isn't registered" % target.nickname)
|
||||
return
|
||||
|
||||
|
|
Loading…
Reference in a new issue