From a5e489655de806590d9cc55ae9bada85cfb5dd3d Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 8 Oct 2019 14:48:39 +0100 Subject: move !which to help.py --- modules/help.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'modules/help.py') diff --git a/modules/help.py b/modules/help.py index bb3924c8..c2bb0f12 100644 --- a/modules/help.py +++ b/modules/help.py @@ -85,6 +85,22 @@ class Module(ModuleManager.BaseModule): event["stdout"].write("Commands for %s module: %s" % ( 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", "") + 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.kwarg("min_args", 1) @utils.kwarg("help", "Show commands with a given string in them") -- cgit v1.3.1-10-gc9f91