mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-29 07:08:45 +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:
@@ -23,6 +23,7 @@ class MultitestCommand(BaseCommand):
|
||||
|
||||
def __init__(self, bot):
|
||||
super().__init__(bot)
|
||||
self.multitest_enabled = self.get_config_value('Multitest_Command', 'enabled', fallback=True, value_type='bool')
|
||||
self.listening = False
|
||||
self.collected_paths: Set[str] = set()
|
||||
self.listening_start_time = 0
|
||||
@@ -31,6 +32,19 @@ class MultitestCommand(BaseCommand):
|
||||
self.triggering_timestamp: float = 0.0 # Timestamp of the triggering message
|
||||
self._load_config()
|
||||
|
||||
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.multitest_enabled:
|
||||
return False
|
||||
return super().can_execute(message)
|
||||
|
||||
def _load_config(self):
|
||||
"""Load configuration for multitest command"""
|
||||
response_format = self.get_config_value('Multitest_Command', 'response_format', fallback='')
|
||||
|
||||
Reference in New Issue
Block a user