- Introduced a new utility function `get_config_timezone` to centralize timezone retrieval and validation from the bot's configuration.
- Updated various commands and the scheduler to utilize the new function, ensuring consistent timezone handling and fallback mechanisms.
- Removed direct dependencies on `pytz` in favor of a more flexible approach that supports both `pytz` and `zoneinfo` for timezone management.
- Enhanced logging for invalid timezone configurations to improve troubleshooting.
- Removed unnecessary import of the `html` module in `feed_manager.py`.
- Moved the `import inspect` statement to the module level in `plugin_loader.py` for better organization.
- Initialized `last_channel_ops_check_time` and `last_message_queue_check_time` attributes in `scheduler.py` to streamline message scheduling logic.
- Cleaned up redundant checks for attribute existence in the `MessageScheduler` class.
- Standardized the configuration keys for various commands by replacing specific `*_enabled` keys with a unified `enabled` key across configuration files.
- Updated command classes to support fallback mechanisms for legacy configuration keys, ensuring backward compatibility.
- Enhanced the logic in the `BaseCommand` class to handle both standard and legacy keys for command enabling.
- Added tests to verify the correct behavior of the new configuration handling and legacy support for commands including Stats, Sports, Hacker, and Alert.
- Standardized the configuration keys for joke commands by replacing `joke_enabled` and `dadjoke_enabled` with a unified `enabled` key in the configuration files.
- Updated the validation logic to warn users when both legacy `[Jokes]` and new `[Joke_Command]`/`[DadJoke_Command]` sections are present, suggesting the removal of the legacy section.
- Enhanced the command classes to support fallback mechanisms for legacy configuration keys, ensuring backward compatibility.
- Added tests to verify the correct behavior of the new configuration handling and legacy support.
- Enhanced .gitignore to allow test files in the tests/ directory and committed pytest.ini for test discovery.
- Added checks for missing sections in configuration files, specifically for Admin_ACL and Banned_Users, to prevent errors during bot startup.
- Updated generate_website.py and command_manager.py to handle cases where required sections are absent, returning empty lists instead of raising exceptions.
- Introduced optional dependencies for testing in pyproject.toml, ensuring a smoother development experience.
- Improved localization handling in core.py to default to English when the Localization section is missing, enhancing user experience.
- Add modules/config_validation.py and validate_config.py CLI to flag
non-standard section names (e.g. WebViewer -> Web_Viewer).
- Migrate JokeCommand/DadJokeCommand to Joke_Command/DadJoke_Command with
legacy [Jokes] fallback in base_command.get_config_value.
- Merge [Jokes] into [Joke_Command]/[DadJoke_Command] in config.ini.example
and add 3-line stubs for minimal-option commands.
- Add webviewer to camel_case_map; add --validate-config to meshcore_bot.py.
Co-authored-by: Cursor <cursoragent@cursor.com>
- Introduced a new mapping for the 'Weather' command to 'Wx_Command' in BaseCommand, clarifying the relationship between legacy and current command names.
- This change enhances command handling by ensuring that the new command structure is recognized while maintaining backward compatibility.
- Introduced `execute_query_on_connection` and `execute_update_on_connection` methods in DBManager to facilitate executing queries and updates on existing database connections.
- Enhanced the `_recalculate_distance_if_needed`, `_get_location_by_public_key`, and `_get_location_by_prefix` methods in MeshGraph to support optional database connection and location caching, improving performance during batch operations.
- Introduced a new configuration option for command prefix in config.ini.example, allowing users to customize command invocation.
- Updated CommandManager to load and utilize the command prefix, ensuring commands are processed correctly based on the configured prefix.
- Enhanced message handling logic to check for the command prefix, maintaining backward compatibility with the legacy "!" prefix.
- Improved keyword matching to ensure bot responses are only triggered when the bot is mentioned, refining interaction accuracy.
- Updated the message handling logic to format elapsed time more accurately, displaying "Nms" when the device clock is valid or "Sync Device Clock" when invalid.
- Introduced a new utility function `format_elapsed_display` to centralize elapsed time formatting, improving code maintainability.
- Modified configuration examples to clarify the usage of the {elapsed} placeholder.
- Added translations for the "Sync Device Clock" message in multiple languages to support internationalization.
- Added QueuedCommand dataclass to represent commands waiting for cooldown expiration.
- Enhanced CommandManager to support queuing commands when near global cooldown expiration, allowing for smoother command execution.
- Implemented background task to process queued commands, ensuring they are executed once cooldowns expire.
- Updated BaseCommand to include a method for retrieving queue threshold seconds, improving flexibility in command handling.
- Adjusted core.py to initiate the command queue processor upon bot startup.
- Updated the `generate_html` function to include detailed command usage information, including syntax, examples, and parameters for better user guidance.
- Added CSS styles for improved presentation of command usage and parameters in the generated website documentation.
- Enhanced command classes with structured documentation fields, allowing for consistent and informative command descriptions across the platform.
- Updated the CommandManager to include channel restrictions for help keyword processing, ensuring that help requests are only handled in monitored channels or DMs when enabled.
- Improved the HTML documentation for commands by adding a new "General Commands" section and refining existing command descriptions.
- Added new CSS styles for better presentation of command subcommands in the website documentation.
- Implemented `get_usage_info` method in `BaseCommand` to provide structured usage information, including descriptions, sub-commands, usage patterns, and examples.
- Enhanced `generate_html` function to display sub-commands in the generated HTML output, improving command documentation.
- Updated translations in `en.json` to include sub-command details for various commands, enhancing user guidance and interaction.
- Updated the `CommandManager` and `BaseCommand` classes to include an optional `skip_user_rate_limit` parameter in the `send_response`, `send_dm`, and `send_channel_message` methods, allowing automated responses to bypass user rate limits.
- Adjusted the `GreeterCommand` to utilize the new parameter, ensuring that automated greetings do not trigger user rate limiting checks.
- Enhanced documentation to clarify the purpose of the new parameter and its impact on message sending behavior.
- Removed per-command user cooldown tracking from individual command classes.
- Implemented a unified cooldown management system in BaseCommand for both global and per-user cooldowns.
- Updated command execution methods to call the new centralized cooldown handling, improving code clarity and reducing redundancy.
- Enhanced error handling and logging during cooldown checks to ensure robust command execution.
- Updated README to specify submitting pull requests against the dev branch.
- Added per-trigger lockout tracking in AnnouncementsCommand to prevent duplicate sends within a 60-second window.
- Implemented dynamic maximum message length calculation in BaseCommand for better message formatting.
- Enhanced response handling in PrefixCommand to support message splitting based on calculated length.
- Added configuration sections for joke and dadjoke commands in config.ini.example, allowing channel restrictions for command usage.
- Updated BaseCommand to derive configuration section names for commands, improving consistency in command management.
- Implemented channel access checks in can_execute methods for JokeCommand and DadJokeCommand to ensure commands are only executed in allowed channels.
- Improved error logging in FeedManager and MessageScheduler to include database path information for better debugging.
- Introduced caching mechanisms for internet connectivity status in CommandManager to optimize performance and reduce redundant checks.
- Updated command execution logic to skip commands requiring internet access when connectivity is unavailable, improving user experience and error handling.
- Added synchronous and asynchronous utility functions for checking internet connectivity in utils.py.
- Marked relevant commands (e.g., AlertCommand, AqiCommand, DadJokeCommand) as requiring internet access to ensure proper execution conditions.
Security Improvements:
- Add DNS timeout (2.0s default) to validate_external_url() to prevent DoS
attacks from malicious URLs causing DNS resolution to hang
- Make path validation OS-aware: supports Windows, macOS (Darwin), and Linux
with platform-specific dangerous path detection
- Add validation for negative max_length values in sanitize_input()
Code Quality Improvements:
- Extract bot_root property in MeshCoreBot class to eliminate code duplication
(was calculated twice in __init__ and setup_logging)
- Use explicit bot_root directory instead of '.' for predictable path validation
in both database and log file path validation
- Make sanitize_input() max_length parameter Optional to allow disabling length
check for radio messages (firmware enforces 150-char limit at hardware level)
- Update message_handler.py to use max_length=None for radio messages while
preserving control character stripping for security
- Replace inline regex with centralized validate_pubkey_format() function in
base_command.py for consistency and maintainability
- Improve documentation: add comments about socket timeout behavior and
firmware-enforced message length limits
All improvements have been tested and verified:
- Syntax checks pass
- All functions work correctly
- No circular dependencies
- Bot initializes successfully with all attributes present
Files modified:
- modules/security_utils.py: DNS timeout, OS-aware paths, Optional max_length
- modules/core.py: bot_root property, explicit base directory usage
- modules/message_handler.py: max_length=None for radio messages
- modules/commands/base_command.py: centralized validation function
- Add Flask + Flask-SocketIO web viewer with dashboard (modules/web_viewer/app.py and related)
- Add web viewer templates: index, realtime, tracking (contacts), cache, purging, stats (modules/web_viewer/templates/)
- Add integration hooks and utility functions for web viewer (modules/web_viewer/integration.py, modules/utils.py)
- Add command to launch web viewer from bot CLI (modules/commands/webviewer_command.py)
- Update .gitignore: ignore db/log files, test scripts, and web viewer artifacts
- Add restart_viewer.sh helper script for standalone web viewer restart/troubleshooting
- Add guidance and documentation for modern viewer in WEB_VIEWER.md and docs/
- Various code structure and import improvements to core bot and command modules to support integration
- Add ACL support for sensitive commands
- Example config updates
Benefits:
- Decouples monitoring/UI from bot core process
- Enables real-time browser dashboard and unified contact/repeater tracking
- Easier integration, dev, and troubleshooting