Skip to content

Commit 9fda9b8

Browse files
zaughonMartin Flygenringsijis
authored
Fix for situationally broken apropos command #1711 (#1712)
* Fix for situationally broken apropos command #1711 * Cleanup unused get_name function * Added fix to CHANGES.rst --------- Co-authored-by: Martin Flygenring <[email protected]> Co-authored-by: Sijis Aviles <[email protected]>
1 parent 69f4537 commit 9fda9b8

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

CHANGES.rst

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ fixes:
1616
- chore: bump setuptools to 75.7.0 (#1709)
1717
- chore: bump pyOpenSSL to 24.3.0 (#1710)
1818
- chore: bump jinja2 to 3.1.5 and requests to 2.32.0 (#1714)
19+
- Fix: situationally broken apropos command (#1711)
20+
1921

2022
v6.2.0 (2024-01-01)
2123
-------------------

errbot/core_plugins/help.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ def is_git_directory(self, path="."):
2424

2525
return tags.pop(-1) if tags is not None else None
2626

27+
def may_access_command(self, m, cmd):
28+
m, _, _ = self._bot._process_command_filters(
29+
msg=m, cmd=cmd, args=None, dry_run=True
30+
)
31+
return m is not None
32+
2733
# noinspection PyUnusedLocal
2834
@botcmd(template="about")
2935
def about(self, msg, args):
@@ -52,7 +58,7 @@ def apropos(self, msg, args):
5258
commands = cls_commands.get(cls, [])
5359
if (
5460
not self.bot_config.HIDE_RESTRICTED_COMMANDS
55-
or self._bot.check_command_access(msg, name)[0]
61+
or self.may_access_command(msg, name)
5662
):
5763
commands.append((name, command))
5864
cls_commands[cls] = commands
@@ -86,15 +92,6 @@ def help(self, msg, args):
8692
"""Returns a help string listing available options.
8793
Automatically assigned to the "help" command."""
8894

89-
def may_access_command(m, cmd):
90-
m, _, _ = self._bot._process_command_filters(
91-
msg=m, cmd=cmd, args=None, dry_run=True
92-
)
93-
return m is not None
94-
95-
def get_name(named):
96-
return named.__name__.lower()
97-
9895
# Normalize args to lowercase for ease of use
9996
args = args.lower() if args else ""
10097
usage = ""
@@ -105,8 +102,9 @@ def get_name(named):
105102
cls = self._bot.get_plugin_class_from_method(command)
106103
obj = command.__self__
107104
_, commands = cls_obj_commands.get(cls, (None, []))
108-
if not self.bot_config.HIDE_RESTRICTED_COMMANDS or may_access_command(
109-
msg, name
105+
if (
106+
not self.bot_config.HIDE_RESTRICTED_COMMANDS
107+
or self.may_access_command(msg, name)
110108
):
111109
commands.append((name, command))
112110
cls_obj_commands[cls] = (obj, commands)
@@ -163,7 +161,7 @@ def get_name(named):
163161
if command._err_command_hidden:
164162
continue
165163

166-
if not may_access_command(msg, name):
164+
if not self.may_access_command(msg, name):
167165
continue
168166
pairs.append((name, command))
169167

0 commit comments

Comments
 (0)