Commit Graph

159 Commits

Author SHA1 Message Date
agessaman
5ae67bc071 Refactor command handling and enhance plugin validation
- Removed redundant command list in config example for clarity.
- Improved plugin validation by adding checks for required attributes and types, ensuring better error handling during plugin instantiation.
- Enhanced rate limiter classes to track total sends and throttled attempts, providing statistics for better monitoring.
- Updated command implementations to include metadata for better organization and clarity in command handling.
2026-01-01 12:03:54 -08:00
agessaman
e5f98d69e6 Implement internet connectivity caching and enhance command handling in CommandManager
- Introduced a thread-safe InternetStatusCache class to manage internet connectivity status with caching.
- Refactored internet connectivity checks to utilize the new cache, reducing redundant checks.
- Added a unified method for handling message send results, improving error logging and response management.
- Enhanced rate limit checks to streamline command execution and prevent spam.
- Improved plugin loading error handling and validation, ensuring robust plugin management.
2026-01-01 11:42:35 -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
5c31ee75ff Improve stability of web viewer integration by logging stdout/stderr to file instead of PIPE. 2026-01-01 10:38:38 -08:00
agessaman
e4e70930f9 Update README and enhance command functionality
- 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.
2025-12-31 16:54:38 -08:00
agessaman
316119c3fe Add announcements command and configuration options config.ini.example 2025-12-29 20:44:00 -08:00
agessaman
427b27fee3 Enhance help command to provide a dynamic list of available commands based on usage statistics. Implemented database querying for command usage and improved fallback mechanisms for command listing. Updated CommandManager to utilize the new method for better help text suggestions. 2025-12-29 16:46:57 -08:00
Adam Gessaman
53b31c20a5 Merge pull request #24 from lincomatic/prm8
add magic8 command
2025-12-29 16:01:53 -08:00
Adam Gessaman
a7b14df9ef Enhance magic8 command response formatting
Format the magic8 command response based on message type.
2025-12-29 16:01:11 -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
3ae6d6dbd5 Update database path configuration for web viewer
- Added db_path configuration options in config.ini.example for both the main bot and web viewer
- Updated BotDataViewer and BotIntegration classes to retrieve the database path from the new Web_Viewer section
2025-12-29 10:46:08 -08:00
Adam Gessaman
b80ff093fb Merge pull request #21 from lincomatic/pr
add elapsed time for test command
2025-12-29 09:43:21 -08:00
agessaman
ccc38a3294 Update database connection handling in scheduler and integration modules
- Set a timeout of 30 seconds for SQLite connections in MessageScheduler and BotIntegration to improve reliability.
- Added validation for the database path in BotIntegration, ensuring it is safe and relative to the bot root, enhancing robustness.
- Introduced a bot_root attribute in BotDataViewer for path validation.
2025-12-29 09:33:57 -08:00
agessaman
759ee372cb Refactor geocoding logic in wx_international to utilize geocode_city_sync 2025-12-29 09:22:06 -08:00
agessaman
251c2dbc27 Update SportsCommand with additional WHL teams and aliases
- Removed redundant team aliases for Spokane Chiefs and Vancouver Giants.
- Added new teams and their aliases for the WHL, including Tri-City Americans, Wenatchee Wild, and several others, enhancing the sports command's coverage of hockey teams.
- Updated city-to-code mappings to include new entries for better identification of teams.
2025-12-28 23:09:33 -08:00
agessaman
7b2288f578 Enhance scheduled messaging with mesh information retrieval
- Added a new method in MessageScheduler to fetch and format mesh statistics for scheduled messages, including total contacts, repeaters, companions, and recent activity.
- Updated the message formatting logic to replace placeholders with actual mesh data, improving the relevance of scheduled updates.
- Enhanced logging for better debugging of mesh info retrieval and message processing.
- Updated config.ini.example to include examples of new placeholders for mesh network information.
2025-12-28 23:01:49 -08:00
agessaman
4ccfe86494 Enhance weather command functionality with provider selection and delegation
- Added a new configuration option in config.ini.example for selecting the weather provider (NOAA or Open-Meteo), defaulting to NOAA.
- Updated WxCommand to delegate to wx_international when the Open-Meteo provider is selected, improving global weather command support.
- Implemented fallback behavior to use wx_international as the wx command if the default wx command is missing, enhancing user experience.
- Improved logging to provide clearer information on command delegation and provider usage.
2025-12-28 21:45:22 -08:00
agessaman
055db64ded Add TheSportsDB client integration for enhanced sports data retrieval
- Introduced TheSportsDBClient class to handle API requests with rate limiting, allowing for efficient data fetching for teams and events.
- Updated SportsCommand to utilize TheSportsDB API for leagues not supported by ESPN, including Canadian Football League (CFL) and Western Hockey League (WHL) teams.
- Implemented methods for fetching team and league events, including upcoming and past games, with robust error handling and logging.
- Enhanced team and league score retrieval to support both ESPN and TheSportsDB APIs, improving overall sports command functionality.
2025-12-28 21:32:54 -08:00
agessaman
63ed0fd73d Update database connection handling to ensure string paths and set timeout
- Modified database connection calls in DBManager, FeedManager, and MessageScheduler to convert db_path to a string and set a timeout of 30 seconds, improving reliability and performance of database operations.
- Enhanced error logging to include detailed information about database path existence and permissions, aiding in debugging and ensuring smoother operation.
2025-12-28 12:12:15 -08:00
agessaman
c2bd1f06e3 Implement database path validation in BotDataViewer and BotIntegration
- Added validation for the database path using the validate_safe_path function to ensure paths are safe and relative to the bot root.
- Enhanced error handling to log warnings when invalid paths are detected, defaulting to 'bot_data.db' if necessary.
- This change improves the robustness of database connections across the application.
2025-12-28 09:23:37 -08:00
agessaman
f4cd1a27e5 Fix issue where bot is sometimes unable to open the database file.
- Updated the validate_safe_path function to resolve the base directory to an absolute path and handle target paths more accurately.
- Enhanced logic to ensure that if the file_path is absolute, it is used directly; otherwise, it is joined with the base directory before resolution, improving handling of relative paths.
2025-12-28 09:17:23 -08:00
agessaman
3cdeae8a0d Implement caching for location name in WeatherService to optimize reverse geocoding 2025-12-27 10:23:46 -08:00
agessaman
d7f16f31e4 Refactor MQTT connection handling in PacketCaptureService and WeatherService to be non-blocking
- Updated connection and reconnection logic in PacketCaptureService to use asyncio's run_in_executor, preventing blocking of the event loop during MQTT operations.
- Enhanced WeatherService to implement non-blocking connection and subscription handling, ensuring smoother operation and improved error logging for connection failures.
2025-12-27 09:35:34 -08:00
agessaman
35bc6260a4 Enhance command configuration and logging for joke commands
- 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.
2025-12-27 08:21:51 -08:00
lincomatic
e62765baf0 add magic8 2025-12-24 16:56:24 -08:00
lincomatic
2395c0765d add elapsed for test command 2025-12-24 16:10:26 -08:00
agessaman
b200c3f500 Enhance WxCommand logic for period handling and improve map uploader service memory management
- Updated WxCommand to better handle period identification for tomorrow's weather, ensuring accurate retrieval of daytime and nighttime periods based on current conditions.
- Added a cleanup mechanism in MapUploaderService to manage memory usage by periodically removing old entries from seen_adverts, preventing unbounded growth and improving performance.
- Optimized packet capture service to utilize indexed lookups for faster data retrieval and ensure fallback mechanisms for backward compatibility.
2025-12-22 23:33:17 -08:00
agessaman
43c217fb0d Update map uploader service documentation for coordinate validation
- Clarified comments in config.ini.example and map_uploader_service.py to specify that adverts with any coordinate exactly 0.0 are considered invalid and will be skipped during uploads. This enhances understanding of the coordinate validation logic in the map uploader service.
2025-12-22 12:02:56 -08:00
agessaman
7e80dedb6d Add map uploader configuration and update requirements
- Introduced a new [MapUploader] section in config.ini.example to configure the map uploader service, including options for enabling the service, API endpoint, private key path, re-upload interval, and verbose logging.
- Updated requirements.txt to include cryptography and pynacl packages for enhanced security features in the map uploader service.
2025-12-22 11:43:25 -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
5f65d36d8c added a http internet connection check fallback to http 2025-12-21 22:19:16 -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
32929dedad Update CommandManager with internet connectivity checks for commands
- 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.
2025-12-17 12:38:54 -08:00
agessaman
f0b4f1e078 Refine command manager logging and enhance weather command alert handling
- Updated CommandManager to log rate limiting warnings only for meaningful wait times, avoiding misleading messages.
- Enhanced WxCommand to support a new "alerts" keyword for fetching weather alerts, with special handling for alert data.
- Improved alert fetching logic to differentiate duplicate special statements and prioritize alerts based on severity and urgency.
- Added methods for compactly formatting alerts and abbreviating city names for better display in responses.
2025-12-16 18:28:26 -08:00
agessaman
399a6b9773 Fixed country counts in WebViewer 2025-12-13 21:57:25 -08:00
agessaman
f525d2e1d0 Enhance message handling and web viewer with path information support
- Updated MessageHandler to extract and store path information from packet_info and routing_info, improving data tracking.
- Added a new API endpoint in the web viewer for decoding path hex strings to repeater names.
- Enhanced the contacts template to display path information with tooltips, improving user experience.
- Implemented tooltip functionality for path data in the web viewer, allowing users to view detailed repeater information on hover.
2025-12-13 14:41:56 -08:00
agessaman
bdd3a0fd41 Enhance SportsCommand with improved game fetching logic
- Added mappings for Professional Women's Hockey League (PWHL) teams with placeholders for team IDs.
- Updated city mappings to include PWHL teams for relevant cities.
- Enhanced game fetching logic to prioritize live games, recent past games, and upcoming games within specified timeframes.
- Introduced methods for fetching and formatting team schedules, improving user experience for schedule queries.
- Improved handling of live event data to ensure real-time score updates for ongoing games.
2025-12-12 21:15:40 -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
4d997afbcc Remove 'repeater_interactions' from the DBManager class whitelist as it isn't used. 2025-12-09 22:08:40 -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
7bacd5b485 Implement upgrade mode in install-service.sh for non-destructive updates and enhance channel fetching logic in MessageScheduler to eliminate periodic refresh. The upgrade mode allows users to update files and dependencies without losing existing configurations. Additionally, the channel fetching now occurs only once on launch to prevent data loss during updates. 2025-12-07 19:40:38 -08:00
agessaman
d446640a50 Enhance channel fetching logic in ChannelManager to include device connectivity checks and implement timeout protection during channel refresh in MessageScheduler. Introduce sender location prioritization in PathCommand and TestCommand for improved repeater selection accuracy. Update logging for better diagnostics on fetch operations and proximity calculations. 2025-12-07 14:02:14 -08:00
agessaman
cc53ab4268 Refactor proximity selection logic in PathCommand and TestCommand to prioritize bot location for the last repeater. Introduce configurable recency and proximity weights for scoring, enhancing the accuracy of repeater selection. Update logging for better debugging of selection scores. 2025-12-06 19:38:03 -08:00
agessaman
36b6746550 Enhance channel management and dark mode styling in web viewer. Update BotDataViewer to dynamically retrieve max channel limits from configuration, improving error messages for channel availability. Implement dark mode styles for modals, tables, and other UI elements across multiple templates, ensuring better contrast and readability. Update JavaScript logic in RadioManager to reflect dynamic channel limits and provide user feedback on available slots. 2025-12-06 19:03:55 -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
b34ca9fa07 Implement retry logic for NOAA API calls in WxCommand to enhance resilience against timeouts and transient errors. Reduce URL timeout from 10 to 8 seconds for faster failure detection. Update weather data fetching methods to utilize a retry-enabled session, improving error handling and logging for better diagnostics. 2025-12-06 16:18:00 -08:00
agessaman
183976e899 Add dark mode support across web viewer templates. 2025-12-06 12:35:58 -08:00
agessaman
ff1adf719e Implement bot reply rate calculations for 24-hour, 7-day, and 30-day time windows in the analytics. Update web viewer template to display these new reply rates and adjust JavaScript to handle the updated data structure. 2025-12-06 10:29:55 -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