feat: Add command enable/disable configuration for various commands

- Implemented a configuration option for enabling or disabling commands across multiple command classes.
- Each command now checks its enabled state before execution, improving control over command availability.
- Updated the configuration loading mechanism to retrieve the enabled state from the config file for commands like Advert, AQI, Catfact, and others.
This commit is contained in:
agessaman committed 2026-01-10 09:33:15 -08:00
1 parent 7ee77c16c0
commit cc3fffeb54
25 files changed
+417 -10

No files matched your search

+14
View File
@@ -34,6 +34,7 @@ class PrefixCommand(BaseCommand):
bot: The bot instance.
"""
super().__init__(bot)
self.prefix_enabled = self.get_config_value('Prefix_Command', 'enabled', fallback=True, value_type='bool')
# Get API URL from config, no fallback to regional API
self.api_url = self.bot.config.get('External_Data', 'repeater_prefix_api_url', fallback="")
@@ -67,6 +68,19 @@ class PrefixCommand(BaseCommand):
self.max_prefix_range > 0
)
def can_execute(self, message: MeshMessage) -> bool:
"""Check if this command can be executed with the given message.
Args:
message: The message triggering the command.
Returns:
bool: True if command is enabled and checks pass, False otherwise.
"""
if not self.prefix_enabled:
return False
return super().can_execute(message)
def get_help_text(self) -> str:
"""Get help text for the prefix command.