mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-10-15 18:49:52 +00:00
Improve monitor channel handling by adding support for quoted values
- Introduced `strip_optional_quotes` function to handle monitor channel values with optional surrounding quotes. - Updated `load_monitor_channels` method in `CommandManager` to utilize the new function, ensuring compatibility with quoted and unquoted channel configurations. - Modified `generate_samples` function to apply the same logic for consistency. - Added tests for `strip_optional_quotes` to validate behavior with various input cases.
This commit is contained in:
@@ -17,6 +17,7 @@ from .models import MeshMessage
|
||||
from .plugin_loader import PluginLoader
|
||||
from .commands.base_command import BaseCommand
|
||||
from .utils import check_internet_connectivity_async, decode_escape_sequences, format_keyword_response_with_placeholders
|
||||
from .config_validation import strip_optional_quotes
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -423,8 +424,11 @@ class CommandManager:
|
||||
return any(sender_id.startswith(entry) for entry in self.banned_users)
|
||||
|
||||
def load_monitor_channels(self) -> List[str]:
|
||||
"""Load monitored channels from config"""
|
||||
channels = self.bot.config.get('Channels', 'monitor_channels', fallback='')
|
||||
"""Load monitored channels from config.
|
||||
Values may be quoted, e.g. \"#bot,#bot-everett,#bots\" or unquoted.
|
||||
"""
|
||||
raw = self.bot.config.get('Channels', 'monitor_channels', fallback='')
|
||||
channels = strip_optional_quotes(raw)
|
||||
return [channel.strip() for channel in channels.split(',') if channel.strip()]
|
||||
|
||||
def load_channel_keywords(self) -> Optional[List[str]]:
|
||||
|
||||
Reference in New Issue
Block a user