diff options
| author | 2019-10-08 14:45:46 +0100 | |
|---|---|---|
| committer | 2019-10-08 14:45:46 +0100 | |
| commit | c547df81dda35f0a64944184b90bb4240e769638 (patch) | |
| tree | f583d63dba29e9b390d9c71541a081d7298e8428 /modules | |
| parent | do 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.py | 16 |
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))) |
