diff --git a/CHANGES.rst b/CHANGES.rst index 10100cc4d..5c07d859b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,8 @@ fixes: - chore: bump setuptools to 75.7.0 (#1709) - chore: bump pyOpenSSL to 24.3.0 (#1710) - chore: bump jinja2 to 3.1.5 and requests to 2.32.0 (#1714) +- Fix: situationally broken apropos command (#1711) + v6.2.0 (2024-01-01) ------------------- diff --git a/errbot/core_plugins/help.py b/errbot/core_plugins/help.py index 633e4504d..cd45729b7 100644 --- a/errbot/core_plugins/help.py +++ b/errbot/core_plugins/help.py @@ -24,6 +24,12 @@ def is_git_directory(self, path="."): return tags.pop(-1) if tags is not None else None + def may_access_command(self, m, cmd): + m, _, _ = self._bot._process_command_filters( + msg=m, cmd=cmd, args=None, dry_run=True + ) + return m is not None + # noinspection PyUnusedLocal @botcmd(template="about") def about(self, msg, args): @@ -52,7 +58,7 @@ def apropos(self, msg, args): commands = cls_commands.get(cls, []) if ( not self.bot_config.HIDE_RESTRICTED_COMMANDS - or self._bot.check_command_access(msg, name)[0] + or self.may_access_command(msg, name) ): commands.append((name, command)) cls_commands[cls] = commands @@ -86,15 +92,6 @@ def help(self, msg, args): """Returns a help string listing available options. Automatically assigned to the "help" command.""" - def may_access_command(m, cmd): - m, _, _ = self._bot._process_command_filters( - msg=m, cmd=cmd, args=None, dry_run=True - ) - return m is not None - - def get_name(named): - return named.__name__.lower() - # Normalize args to lowercase for ease of use args = args.lower() if args else "" usage = "" @@ -105,8 +102,9 @@ def get_name(named): cls = self._bot.get_plugin_class_from_method(command) obj = command.__self__ _, commands = cls_obj_commands.get(cls, (None, [])) - if not self.bot_config.HIDE_RESTRICTED_COMMANDS or may_access_command( - msg, name + if ( + not self.bot_config.HIDE_RESTRICTED_COMMANDS + or self.may_access_command(msg, name) ): commands.append((name, command)) cls_obj_commands[cls] = (obj, commands) @@ -163,7 +161,7 @@ def get_name(named): if command._err_command_hidden: continue - if not may_access_command(msg, name): + if not self.may_access_command(msg, name): continue pairs.append((name, command))