From 376825ea96099efc0f5e890370a417db1902df1a Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 10 Oct 2018 10:42:41 +0100 Subject: Mark command hooks that are aliases ('g' vs 'google') --- modules/commands.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'modules/commands.py') diff --git a/modules/commands.py b/modules/commands.py index 8eb0b96b..0f22c2d8 100644 --- a/modules/commands.py +++ b/modules/commands.py @@ -112,6 +112,13 @@ class Module(ModuleManager.BaseModule): return hook = self.get_hook(command) + alias_of = self._get_alias_of(hook) + if alias_of: + if self.has_command(alias_of): + hook = self.get_hook(alias_of) + else: + raise ValueError("'%s' is an alias of unknown command '%s'" + % (command.lower(), alias_of.lower())) is_channel = False if "channel" in event: @@ -197,6 +204,8 @@ class Module(ModuleManager.BaseModule): return hook.get_kwarg("usage", None) def _get_prefix(self, hook): return hook.get_kwarg("prefix", None) + def _get_alias_of(self, hook): + return hook.get_kwarg("alias_of", None) @utils.hook("received.command.help") def help(self, event): @@ -222,8 +231,10 @@ class Module(ModuleManager.BaseModule): for child in self.events.on("received.command").get_children(): hooks = self.events.on("received.command").on(child).get_hooks() - if hooks and self._get_help(hooks[0]): + if hooks and self._get_help(hooks[0] + ) and not self._get_alias_of(hooks[0]): help_available.append(child) + help_available = sorted(help_available) event["stdout"].write("Commands: %s" % ", ".join(help_available)) -- cgit v1.3.1-10-gc9f91