move !which to help.py

This commit is contained in:
jesopo 2019-10-08 14:48:39 +01:00
parent c547df81dd
commit a5e489655d
2 changed files with 16 additions and 18 deletions

View file

@ -85,6 +85,22 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write("Commands for %s module: %s" % ( event["stdout"].write("Commands for %s module: %s" % (
module.name, ", ".join(commands))) module.name, ", ".join(commands)))
@utils.hook("received.command.which")
@utils.kwarg("min_args", 1)
@utils.kwarg("help", "Find where a command is provided")
@utils.kwarg("usage", "<command>")
def which(self, event):
command = event["args_split"][0].lower()
hooks = self.events.on("received.command").on(command).get_hooks()
if not hooks:
raise utils.EventError("Unknown command '%s'" % command)
hook = hooks[0]
module = self.bot.modules.from_context(hook.context)
event["stdout"].write("%s%s is provided by %s.%s" % (
event["command_prefix"], command, module.name,
hook.function.__name__))
@utils.hook("received.command.apropos") @utils.hook("received.command.apropos")
@utils.kwarg("min_args", 1) @utils.kwarg("min_args", 1)
@utils.kwarg("help", "Show commands with a given string in them") @utils.kwarg("help", "Show commands with a given string in them")

View file

@ -1,18 +0,0 @@
from src import ModuleManager, utils
class Module(ModuleManager.BaseModule):
@utils.hook("received.command.which")
@utils.kwarg("min_args", 1)
@utils.kwarg("help", "Find where a command is provided")
@utils.kwarg("usage", "<command>")
def which(self, event):
command = event["args_split"][0].lower()
hooks = self.events.on("received.command").on(command).get_hooks()
if not hooks:
raise utils.EventError("Unknown command '%s'" % command)
hook = hooks[0]
module = self.bot.modules.from_context(hook.context)
event["stdout"].write("%s%s is provided by %s.%s" % (
event["command_prefix"], command, module.name,
hook.function.__name__))