feat(command_manager): enhance help command channel access handling

- Updated the `CommandManager` to respect the `channels` override for the help command, ensuring it checks channel permissions directly when processing help requests.
- Refactored the logic to fall back to global `monitor_channels` only when no specific help command is loaded, improving channel-specific access control.
- Added unit tests to verify the correct behavior of the help command in disallowed channels, ensuring it only responds in permitted contexts.
This commit is contained in:
agessaman
2026-06-28 09:52:37 -07:00
parent 0c37f48a45
commit b8decd8d66
2 changed files with 34 additions and 2 deletions
+10 -2
View File
@@ -738,8 +738,16 @@ class CommandManager:
if not self.bot.config.getboolean('Channels', 'respond_to_dms', fallback=True):
break # DMs disabled, skip help keyword
else:
# For channel messages, check if channel is in monitor_channels
if message.channel not in self.monitor_channels:
# For channel messages, honor the help command's channel access:
# its per-command `channels` override when set, otherwise the
# global monitor_channels. Without this the special path would
# ignore [Help_Command] channels = ... (it bypasses the plugin
# loop where is_channel_allowed is normally enforced). Fall back
# to a bare monitor_channels check when no help command is loaded.
if help_command is not None and hasattr(help_command, 'is_channel_allowed'):
if not help_command.is_channel_allowed(message):
break # Not allowed in this channel, skip help keyword
elif message.channel not in self.monitor_channels:
break # Channel not monitored, skip help keyword
# When channel_keywords is set, only allow listed triggers in channel
if not self._is_channel_trigger_allowed('help', message):