aboutsummaryrefslogtreecommitdiff
path: root/modules/which.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-09-04 15:39:56 +0100
committerGravatar jesopo2019-09-04 15:39:56 +0100
commit9561cba1683599c0586dd6b2cb8677975ac2a448 (patch)
tree12a169469da120dd73baaabff44e11286f88b01a /modules/which.py
parentcache when a setting isn't set but don't cache "default" value (diff)
signature
add which.py - closes #134
Diffstat (limited to 'modules/which.py')
-rw-r--r--modules/which.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/which.py b/modules/which.py
new file mode 100644
index 00000000..a1b51658
--- /dev/null
+++ b/modules/which.py
@@ -0,0 +1,18 @@
+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__))