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:
agessaman
2026-02-15 21:02:48 -08:00
parent 669f02c96e
commit 04bd004f36
5 changed files with 58 additions and 6 deletions
+6 -2
View File
@@ -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]]: