From 9db02212b75af310449d2eea2714255465f52855 Mon Sep 17 00:00:00 2001 From: user Date: Sun, 15 Feb 2026 04:30:28 +0100 Subject: [PATCH] fix: filter help output by per-channel plugin config !help now only lists commands from plugins allowed in the current channel. !help and !help return "unknown" for filtered plugins. PMs remain unrestricted. --- plugins/core.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/core.py b/plugins/core.py index 138f32b..66940ac 100644 --- a/plugins/core.py +++ b/plugins/core.py @@ -18,23 +18,25 @@ async def cmd_help(bot, message): Usage: !help [command|plugin] """ + channel = message.target if message.is_channel else None parts = message.text.split(None, 2) if len(parts) > 1: name = parts[1].lower().lstrip(bot.prefix) # Check command first handler = bot.registry.commands.get(name) - if handler: + if handler and bot._plugin_allowed(handler.plugin, channel): help_text = handler.help or "No help available." await bot.reply(message, f"{bot.prefix}{name} -- {help_text}") return # Check plugin module = bot.registry._modules.get(name) - if module: + if module and bot._plugin_allowed(name, channel): desc = (getattr(module, "__doc__", "") or "").split("\n")[0].strip() cmds = sorted( - k for k, v in bot.registry.commands.items() if v.plugin == name + k for k, v in bot.registry.commands.items() + if v.plugin == name and bot._plugin_allowed(v.plugin, channel) ) lines = [f"{name} -- {desc}" if desc else name] if cmds: @@ -45,8 +47,11 @@ async def cmd_help(bot, message): await bot.reply(message, f"Unknown command or plugin: {name}") return - # List all commands - names = sorted(bot.registry.commands.keys()) + # List all commands visible in this channel + names = sorted( + k for k, v in bot.registry.commands.items() + if bot._plugin_allowed(v.plugin, channel) + ) await bot.reply(message, f"Commands: {', '.join(bot.prefix + n for n in names)}")