From c8287c47443c17efa90567b3e34afb662f6374f8 Mon Sep 17 00:00:00 2001 From: Martin Flygenring Date: Mon, 24 Feb 2025 17:40:22 +0100 Subject: [PATCH 1/3] Fix for situationally broken apropos command #1711 --- errbot/core_plugins/help.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/errbot/core_plugins/help.py b/errbot/core_plugins/help.py index 633e4504d..0eda3f442 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,12 +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() @@ -105,8 +105,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 +164,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)) From 67031696c60ee78e5e2d44be33b00307a0928cf1 Mon Sep 17 00:00:00 2001 From: Martin Flygenring Date: Mon, 24 Feb 2025 17:41:05 +0100 Subject: [PATCH 2/3] Cleanup unused get_name function --- errbot/core_plugins/help.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/errbot/core_plugins/help.py b/errbot/core_plugins/help.py index 0eda3f442..cd45729b7 100644 --- a/errbot/core_plugins/help.py +++ b/errbot/core_plugins/help.py @@ -92,9 +92,6 @@ def help(self, msg, args): """Returns a help string listing available options. Automatically assigned to the "help" command.""" - def get_name(named): - return named.__name__.lower() - # Normalize args to lowercase for ease of use args = args.lower() if args else "" usage = "" From 050fe9a4550793fc1ecb0577f26ef183ede54c95 Mon Sep 17 00:00:00 2001 From: Martin Flygenring Date: Thu, 27 Feb 2025 12:21:09 +0100 Subject: [PATCH 3/3] Added fix to CHANGES.rst --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index ce9fbc903..89415cb3d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -15,6 +15,8 @@ fixes: - chore: use ruff for formatting (#1706) - chore: bump setuptools to 75.7.0 (#1709) - chore: bump pyOpenSSL to 24.3.0 (#1710) +- Fix: situationally broken apropos command (#1711) + v6.2.0 (2024-01-01) -------------------