aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-10-08 14:45:46 +0100
committerGravatar jesopo2019-10-08 14:45:46 +0100
commitc547df81dda35f0a64944184b90bb4240e769638 (patch)
treef583d63dba29e9b390d9c71541a081d7298e8428 /modules
parentdo not permit a space between () and karma modifier (diff)
signature
add !apropos - to show commands with a given string in them
closes #133
Diffstat (limited to 'modules')
-rw-r--r--modules/help.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/help.py b/modules/help.py
index 4ebd2a2a..bb3924c8 100644
--- a/modules/help.py
+++ b/modules/help.py
@@ -84,3 +84,19 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write("Commands for %s module: %s" % (
module.name, ", ".join(commands)))
+
+ @utils.hook("received.command.apropos")
+ @utils.kwarg("min_args", 1)
+ @utils.kwarg("help", "Show commands with a given string in them")
+ @utils.kwarg("usage", "<query>")
+ def apropos(self, event):
+ query = event["args_split"][0]
+ query_lower = query.lower()
+
+ commands = []
+ for command, hook in self._all_command_hooks().items():
+ if query_lower in command.lower():
+ commands.append("%s%s" % (event["command_prefix"], command))
+ if commands:
+ event["stdout"].write("Apropos of '%s': %s" %
+ (query, ", ".join(commands)))