mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-28 05:14:12 +00:00
fix: List only commands that are enabled in cmd response
Signed-off-by: Gerard Hickey <hickey@kinetic-compute.com>
This commit is contained in:
@@ -543,6 +543,13 @@ class BaseCommand(ABC):
|
||||
# Check if channel matches allowed list
|
||||
return message_channel_normalized in allowed_normalized
|
||||
|
||||
def is_enabled(self) -> bool:
|
||||
"""Return whether this command is enabled per config."""
|
||||
for attr_name, attr_val in vars(self).items():
|
||||
if attr_name.endswith('_enabled') and isinstance(attr_val, bool):
|
||||
return attr_val
|
||||
return True
|
||||
|
||||
def can_execute(self, message: MeshMessage, skip_channel_check: bool = False) -> bool:
|
||||
"""Check if this command can be executed with the given message.
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ class CmdCommand(BaseCommand):
|
||||
for cmd_name, cmd_instance in self.bot.command_manager.commands.items():
|
||||
# Skip system commands without keywords (like greeter)
|
||||
if hasattr(cmd_instance, 'keywords') and cmd_instance.keywords:
|
||||
if hasattr(cmd_instance, 'is_enabled') and not cmd_instance.is_enabled():
|
||||
continue
|
||||
if not self._is_command_valid_for_channel(cmd_name, cmd_instance, message):
|
||||
continue
|
||||
all_commands.append(cmd_name)
|
||||
|
||||
Reference in New Issue
Block a user