Commit Graph

63 Commits

Author SHA1 Message Date
agessaman
94418bebee Refactor configuration handling in MeshCoreBot
- Removed custom _DuplicateAwareConfigParser in favor of standard configparser.ConfigParser.
- Simplified configuration loading process while maintaining existing functionality.
2026-02-22 20:43:43 -08:00
agessaman
870e57b4c9 Revert "fix duplicate option handling in config parser for Python 3.13 compatibility"
This reverts commit 39c6c221e6.
2026-02-22 20:36:15 -08:00
agessaman
39c6c221e6 fix duplicate option handling in config parser for Python 3.13 compatibility
- Updated the `_handle_option` method to accommodate changes in Python 3.13, ensuring proper handling of duplicate options in configuration files.
- Enhanced logging to provide clearer error messages when duplicate options are detected, improving troubleshooting capabilities.
2026-02-22 12:01:02 -08:00
agessaman
6dcf256c77 Simplify contact removal logic and add versioning to webviewer. 2026-02-19 19:39:32 -08:00
agessaman
652712eb0c Update documentation links and file references for consistency
- Renamed various documentation files to use lowercase for improved consistency, including `WEB_VIEWER.md`, `DOCKER.md`, and `PATH_COMMAND_CONFIG.md`.
- Updated references in `config.ini.example`, `docker-setup.sh`, `README.md`, and multiple documentation files to reflect the new file names.
- Removed obsolete documentation files related to the Discord Bridge, Map Uploader, Packet Capture, and Weather Service, streamlining the documentation structure.
2026-02-16 17:15:52 -08:00
agessaman
a2c02e699f Implement automatic creation of config.ini from example file
- Added logic to the `install-service.sh` script to automatically create a `config.ini` file from `config.ini.example` if it does not exist in the installation directory.
- Included warnings for users if the example file is not found, ensuring proper configuration setup before starting the bot.
- Refactored joke command configuration in `core.py` to maintain consistency and clarity in the configuration structure.
2026-02-16 14:59:31 -08:00
agessaman
53b5bdef69 Enhance configuration file reading to support UTF-8 encoding
- Updated the `MeshCoreBot` class to read the configuration file with UTF-8 encoding, ensuring proper parsing of emoji and non-ASCII characters on Windows.
- Applied the same encoding change to the configuration reload logic, maintaining consistency across configuration handling.
2026-02-15 21:43:37 -08:00
agessaman
3575d025ba Implement feed manager configuration and refactor command settings
- Added a new [Feed_Manager] section in the configuration to enable or disable RSS/API feed subscriptions, defaulting to false.
- Updated the FeedManager class to handle missing configuration sections gracefully, ensuring compatibility with upgrades.
- Refactored joke command configuration to standardize the use of an `enabled` key, replacing legacy `*_enabled` keys for clarity.
- Adjusted the PathCommand class to enable the "p" shortcut by default, improving user experience.
2026-02-12 22:03:02 -08:00
agessaman
d699ea1cf1 Update configuration handling and validation for bot sections
- 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.
2026-02-12 19:23:35 -08:00
Adam Gessaman
67c16995da fix: Enhance logging configuration handling
- Updated logging setup to use default values when the [Logging] section is missing, ensuring consistent behavior.
- Improved handling of colored output and log file configuration based on the presence of the [Logging] section across multiple modules.
- Refactored related code in core and service plugins for better clarity and maintainability.
2026-02-12 17:19:29 -08:00
Adam Gessaman
40e30def2c feat: Implement per-user rate limiting for bot responses
- Added per-user rate limiting functionality to control the minimum time between bot replies to the same user, identified by public key or sender name.
- Updated configuration files to include `per_user_rate_limit_seconds` and `per_user_rate_limit_enabled` options for enabling and configuring this feature.
- Enhanced the command manager and message handler to support per-user rate limiting, ensuring efficient message handling and reduced spam.
- Updated documentation to reflect the new rate limiting options and their usage.
2026-02-11 09:13:24 -08:00
Adam Gessaman
ac2825a25d feat: Add channel keyword filtering to configuration
- Introduced `channel_keywords` option in the configuration files to limit bot responses in monitored channels to specified keywords, enhancing control over channel interactions.
- Updated relevant documentation and examples to reflect the new feature, ensuring users understand how to implement keyword restrictions.
- Modified the command manager to support the new keyword filtering logic, allowing for more efficient message handling in channels.
2026-02-09 11:56:43 -08:00
agessaman
4a86e7243d feat: Improve database path handling for web viewer integration
- Updated the configuration handling for the web viewer to use the [Bot] db_path when [Web_Viewer] db_path is unset, ensuring consistent database access.
- Added warnings in the logging to notify users when the web viewer database path differs from the bot database path, guiding them to configure it correctly.
- Refactored database path resolution logic across multiple modules for better maintainability and clarity.
2026-02-08 10:20:40 -08:00
agessaman
a102e6eabe feat: Add automatic device name update feature
- Introduced a new configuration option `auto_update_device_name` in config.ini.example to control whether the device name should automatically match the bot_name on startup.
- Implemented the `set_device_name` method in core.py to check and update the device name based on the configuration, ensuring consistency between the device and bot name.
- Enhanced logging for device name checks and updates to improve debugging and user awareness of the device state.
2026-01-27 20:28:21 -08:00
agessaman
1559860dcb feat: Introduce prefix best location feature and enhance message handling
- Added configuration options for the "prefix best <location>" command in config.ini.example, allowing users to enable/disable the feature and customize its behavior.
- Implemented logic in the PrefixCommand class to find the best prefix for a given location, considering neighbor prefixes and user-defined criteria.
- Enhanced MessageHandler to skip processing old cached messages based on connection time, improving message handling efficiency.
- Updated core bot to track connection time, ensuring accurate message processing and cache management.
2026-01-26 17:15:25 -08:00
agessaman
bd2849655c feat: Enhance mesh graph functionality and path validation
- Added a new mesh graph feature for improved path validation, allowing for enhanced routing accuracy.
- Introduced configuration options for recency decay half-life and graph-based validation settings in config.ini.example.
- Updated the PathCommand class to utilize graph-based selection methods, combining graph and geographic scores for better repeater selection.
- Implemented new methods in MessageHandler to update the mesh graph with advertisement paths and trace packet data.
- Created a new database table for mesh connections to support graph-based path validation.
- Enhanced web viewer integration to display mesh graph updates in real-time, improving user interaction and monitoring capabilities.
2026-01-23 20:26:56 -08:00
agessaman
ba33fed1a8 feat: Implement service health checks and restart logic
- Added a new configuration option for service restart backoff timing in config.ini.example.
- Enhanced the MeshCoreBot class to track service health and manage restarts for unhealthy services.
- Introduced a new method for service health checks in the BaseServicePlugin class, allowing for custom health validation in subclasses.
- Updated the PacketCaptureService to include specific health check logic based on connection status.
2026-01-20 20:35:29 -08:00
agessaman
abe8e57ae3 feat: Update banned user handling to support prefix matching
- Modified configuration examples to clarify that banned users are now identified by sender names using prefix matching.
- Implemented a new method in CommandManager to check if a user is banned based on prefix matching, enhancing the bot's ability to ignore messages from banned senders.
- Updated message handling logic to utilize the new prefix matching functionality for improved user management.
2026-01-18 20:04:50 -08:00
agessaman
aa3951827a feat: Implement command queuing for global cooldowns in CommandManager
- 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.
2026-01-17 21:12:24 -08:00
agessaman
58901a2857 chore: Update docker-setup.sh and documentation for improved serial device handling and logging
- Enhanced docker-setup.sh to ensure device mappings are correctly moved from the volumes section to the devices section in Docker Compose files.
- Added checks for serial device permissions and provided detailed instructions in DOCKER.md for resolving permission issues.
- Updated Dockerfile to add the meshcore user to the dialout group for serial port access, improving compatibility with serial devices.
- Improved logging functionality in core.py to handle log file paths more robustly, ensuring directories are created as needed and handling errors gracefully.
2026-01-17 12:12:33 -08:00
agessaman
db0db96f7e feat: Add reload configuration functionality and update admin commands
- Introduced a new method `reload_config` to allow dynamic reloading of the configuration without restarting the bot, ensuring seamless updates to settings.
- Added a helper method `_get_radio_settings` to retrieve current radio settings for comparison during reload.
- Updated `admin_commands` in `config.ini.example` to include the new `reload` command, enabling admin users to reload configurations on-the-fly.
- Enhanced the `setup_scheduled_messages` method in the scheduler to clear existing jobs before reloading, preventing duplicates.
2026-01-16 19:55:44 -08:00
agessaman
7984fa3af6 feat: Enhance command messaging with repeat tracking and transmission monitoring
- Updated `send_dm` and `send_channel_message` methods to include an optional `command_id` for tracking message repeats.
- Integrated transmission tracking to record and manage repeat messages, improving message handling and response accuracy.
- Enhanced `capture_command` method in `BotIntegration` to store repeat information for better analysis in the web viewer.
- Added favicon support and improved web viewer templates to display repeat information effectively.
- Implemented JavaScript updates in the web viewer to handle command updates and display repeat counts dynamically.
2026-01-11 20:30:02 -08:00
agessaman
50724d1fed feat: Enhance asyncio event loop handling across modules
- Introduced a mechanism to utilize the main event loop for scheduling coroutines, preventing deadlocks when the main loop is running.
- Updated the JWT renewal interval to 12 hours, with tokens now valid for 24 hours, improving token management.
- Refactored various async function calls in the MessageScheduler, WeatherService, and PacketCaptureService to ensure consistent event loop usage.
- Improved error handling and logging for scheduled tasks, enhancing robustness and maintainability.
2026-01-02 09:25:31 -08:00
agessaman
a32fe0dcfd docs: Add docstrings and type hints across modules for improved clarity and maintainability. 2026-01-01 20:12:49 -08:00
agessaman
73492c8ff1 Add system health monitoring and reporting functionality
- Implemented periodic updates of system health status to the database every 30 seconds.
- Added a new method to aggregate and return comprehensive health status of all components, including core connection, database, services, and web viewer.
- Introduced an API endpoint at /api/system-health to retrieve system health data, providing a structured response for health status and component details.
- Enhanced error handling for health data storage and retrieval processes, ensuring robust logging and feedback in case of issues.
2026-01-01 16:37:03 -08:00
agessaman
cf43362ad5 Enhance error handling and cache management in core and message handler modules
- Improved exception handling in MeshCoreBot to catch specific errors related to database and service initialization.
- Added a new method in MessageHandler for cleaning up stale RF data cache entries, enforcing maximum size limits and periodic cleanup.
- Updated message processing to handle potential AttributeError in multitest listener, ensuring robustness during message handling.
2026-01-01 11:34:57 -08:00
agessaman
afda22f0fe Refactor database path and placeholder handling across modules
- Replaced the validate_safe_path function with a new resolve_path utility to simplify database path resolution in BotDataViewer, BotIntegration, and MapUploaderService.
- Updated the logic to ensure that both relative and absolute paths are handled correctly, enhancing the robustness of database connections.
- Improved code readability and maintainability by centralizing path resolution logic.
- Centralized placeholder handling in utils instead of individual function handlers
2025-12-29 15:42:35 -08:00
agessaman
c3d3c85f01 Implement service plugin architecture and enhance weather service configuration
- Introduced a new service plugin architecture in core.py to manage multiple services, including the packet capture service.
- Updated the configuration file (config.ini.example) to include a new [Weather_Service] section for enabling weather forecasts and alerts, along with relevant settings.
- Enhanced the base service plugin class to support optional configuration section names and service descriptions for better metadata management.
- Improved the packet capture service with explicit configuration section and description for clarity.
2025-12-22 10:29:43 -08:00
agessaman
d6aec8ce29 Add service plugins configuration and packet capture integration
- Introduced a new [PacketCapture] section in config.ini.example to enable packet capture service with options for output file, verbosity, and MQTT configuration.
- Updated core.py to initialize and manage the packet capture service, including starting and stopping the service during bot operation.
- Enhanced DiceCommand to support mixed dice notation and added functionality for decade dice rolls, improving user experience for tabletop gaming commands.
- Updated translations to reflect new dice command usage and descriptions, ensuring clarity for users.
2025-12-21 15:44:46 -08:00
agessaman
4abd6fff69 Update configuration and command handling for prefix settings
- Simplified comments in config.ini.example and core.py to clarify API endpoint configuration.
- Changed default value for prefix_free_days from 30 to 7 in prefix_command.py to align with recent adjustments in prefix handling logic.
- Enhanced logic in prefix_command.py to prioritize API cache for used prefixes and fallback to database only when necessary, improving efficiency and accuracy in prefix data retrieval.
2025-12-11 20:41:31 -08:00
agessaman
d62e63cdb9 Apply code quality improvements to PR16 security enhancements
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
2025-12-09 21:44:42 -08:00
eddieoz
8a35dc8270 feat: Add security utilities for path validation, SQL injection prevention, and input sanitization. 2025-12-09 21:26:42 -08:00
agessaman
d52b0f8744 added backup script for the databases, added device time setting to radio connection handler 2025-12-06 18:27:11 -08:00
agessaman
c151fba7a5 Enhance configuration and database management for feed and channel operations. Add channel refresh interval setting to config.ini.example, implement feed manager functionality with new database tables for feed subscriptions and activity tracking, and improve greeter command logic with human greeting detection and Levenshtein distance matching for user greetings. Update web viewer to include feed management pages and integrate global template variables for better user experience. 2025-12-06 10:18:12 -08:00
agessaman
92f063b4bc Add Nominatim rate limiting and caching enhancements across commands. Introduce NominatimRateLimiter for API compliance, update geocoding methods to utilize rate-limited calls, and extend caching duration for geocoding results to 30 days. Refactor command implementations to improve efficiency and prevent duplicate API requests. 2025-11-26 14:34:45 -08:00
agessaman
5c2af1a014 added generic per-command channel configuration, allows commands to be mapped to different channels or dms only 2025-11-25 21:19:48 -08:00
agessaman
6c660dc14c Enhance configuration and command files to support new distance metrics in message responses. Updated Keywords section to include {path_distance} and {firstlast_distance} placeholders. Refactored distance calculation methods into utils and improved path command logic for better accuracy in distance reporting. Added detailed logging for packet hash calculations and message handling in multitest command. 2025-11-20 21:41:10 -08:00
agessaman
412883ac67 Enhance weather command functionality by adding support for multi-day and tomorrow forecasts. Updated parsing logic to handle forecast type options and improved response formatting. Integrated new weather data retrieval methods for both local and global commands, ensuring consistent user experience across different locales. Added localization support for new forecast messages in multiple languages. 2025-11-18 18:51:10 -08:00
agessaman
7e2c478662 Implement localization support across various commands and configuration. Added language settings in config.ini.example, integrated translation functionality in command responses, and enhanced error handling with localized messages. Improved fallback mechanisms for missing translations and updated help text for better user guidance. 2025-11-16 20:17:58 -08:00
agessaman
ed7f5691c7 Add support for plugin overrides in configuration, allowing alternative plugin implementations. Enhanced weather display settings with configurable units for temperature, wind speed, and precipitation. Updated repeater_manager to improve contact removal logic with better error handling and logging. 2025-11-15 15:07:43 -08:00
agessaman
f162336d44 updated documentation about placeholders in responses, improvements to path data in webviewer 2025-11-11 20:18:01 -08:00
agessaman
cc97c48bbf add initial tcp support to the bot 2025-11-06 20:06:18 -08:00
agessaman
b3ddef401c Add prefix time window configuration options
- Introduced `prefix_heard_days` and `prefix_free_days` settings in the configuration to define time windows for showing heard and free prefixes.
- Updated `PrefixCommand` to utilize these new settings for filtering repeaters based on their last heard time.
2025-11-02 21:41:21 -08:00
agessaman
972474d040 Fix BLE connection parameter in core.py to use the correct variable name for device name. 2025-10-29 21:41:29 -07:00
agessaman
4f195b050e added configuration option for path guessing symbols 2025-10-27 14:10:12 -07:00
agessaman
7bb51f219b Web Viewer Integration
- 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
2025-10-21 21:57:00 -07:00
agessaman
f524b3109d removed hardcoded reference to map.w0z.is, updated the path command to try to resolve prefix collisions using proximity and recency 2025-10-18 18:24:22 -07:00
agessaman
4adf9fe301 Updated database schema for complete contact tracking and optimized handling of repeater commands. Revised method for removing contacts from the device to use meshcore.py. 2025-10-18 17:16:50 -07:00
agessaman
fea21b85bd initial update to include proximity-based path resolution 2025-10-18 14:46:31 -07:00
agessaman
025d3d539f Refactor command syntax and enhance test command functionality
- Updated the test command response format to include optional phrases.
- Removed the at_phrase command and its references from the command manager and help command.
- Adjusted configuration examples to reflect the new syntax for message acknowledgments.
- Enhanced the sports command with additional WNBA team support and improved city mappings for team searches.
2025-09-17 21:12:43 -07:00