mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-06-07 08:01:39 +00:00
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:
@@ -26,6 +26,7 @@ class PathCommand(BaseCommand):
|
||||
|
||||
def __init__(self, bot):
|
||||
super().__init__(bot)
|
||||
self.path_enabled = self.get_config_value('Path_Command', 'enabled', fallback=True, value_type='bool')
|
||||
# Get bot location from config for geographic proximity calculations
|
||||
# Check if geographic guessing is enabled (bot has location configured)
|
||||
self.geographic_guessing_enabled = False
|
||||
@@ -85,6 +86,19 @@ class PathCommand(BaseCommand):
|
||||
except Exception as e:
|
||||
self.logger.warning(f"Error reading bot location from config: {e} - geographic proximity guessing disabled")
|
||||
|
||||
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.path_enabled:
|
||||
return False
|
||||
return super().can_execute(message)
|
||||
|
||||
def matches_keyword(self, message: MeshMessage) -> bool:
|
||||
"""Check if message starts with 'path' keyword or 'p' shortcut (if enabled)"""
|
||||
content = message.content.strip()
|
||||
|
||||
Reference in New Issue
Block a user