Commit Graph

38 Commits

Author SHA1 Message Date
agessaman
df8dc8cafb feat: Enhance path selection and observation tracking
- Added new configuration options for path selection presets and proximity methods in config.ini.example, allowing users to customize routing behavior.
- Implemented a new database table for storing observed paths, enabling better tracking of paths from advertisements and messages.
- Updated MessageHandler to store complete paths in the observed_paths table, improving path validation and selection accuracy.
- Enhanced the PathCommand class to utilize new proximity and recency settings, optimizing repeater selection based on user-defined criteria.
- Improved web viewer functionality to display multiple paths for contacts, enhancing user experience and interaction with path data.
2026-01-25 10:12:46 -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
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
106e7efca8 feat: Add light mode support for modal and UI elements in web viewer
- Implemented comprehensive light mode styles for various components in the web viewer, including modals, segment cards, and tables.
- Enhanced visual consistency by applying theme-based background and text colors across different UI elements.
- Updated styles for header and message content to ensure readability and aesthetic appeal in light mode.
2026-01-10 19:44:24 -08:00
agessaman
ca80924e38 feat: Enhance web viewer functionality and configuration options
- Updated `config.ini.example` to include a new option for additional hashtag channels to decode in the packet stream.
- Modified `BotDataViewer` to retrieve and display additional decode-only channels from the configuration.
- Improved packet handling in `message_handler.py` to capture full packet data for web viewer integration.
- Enhanced the web viewer's JavaScript to support detailed packet analysis and display, including color-coded hex breakdowns and improved user interface elements.
- Added new styles and scripts to the web viewer templates for better visual representation of packet data and improved user experience.
2026-01-10 16:39:07 -08:00
agessaman
760bf7ad1f feat: Enhance logging and client management in BotDataViewer
- Added a rotating file handler for logging to manage log file size and backups.
- Implemented thread safety for connected clients using a lock to prevent race conditions.
- Introduced a method to clean up stale clients based on inactivity, improving resource management.
- Updated logging messages to reflect changes in logging setup and client connection status.
2026-01-10 10:34:37 -08:00
agessaman
e14574580a fix: Improve database cleanup process in BotDataViewer
- Enhanced error logging to include stack traces for better debugging.
- Optimized the cleanup of old packet stream data by implementing smaller batch deletions to reduce lock contention.
- Adjusted database connection settings for improved concurrency and added handling for database busy errors.
- Removed periodic cleanup from BotIntegration, delegating this responsibility to the web viewer subprocess to avoid contention.
2026-01-10 09:42:28 -08:00
agessaman
1acbee0b5b feat: Enhance bot signal handling and update dependencies
- Refactored bot's main execution flow to use asyncio.run() with improved signal handling for graceful shutdown on Unix systems.
- Added new dependencies in pyproject.toml: urllib3, paho-mqtt, cryptography, and pynacl for enhanced functionality.
- Updated Nix flake to include flake-parts for better modularization and added translation path for NixOS module compatibility.
- Improved argument parsing in web viewer to maintain clarity and consistency.
2026-01-07 20:06:43 -08:00
Tilman Baumann
2be93ebf6f Allowign to pass --config to web viewer 2026-01-07 15:15:42 +01:00
Tilman Baumann
a6c56ecd3c Add Nix flake with NixOS module and modernize Python packaging
This commit adds comprehensive Nix/NixOS support and modernizes the
Python packaging structure to enable declarative system-wide deployments.

Added complete Nix flake infrastructure in nix/:
- packages.nix: Package definition with all dependencies
- nixos-module.nix: NixOS module for declarative service configuration
- nixos-test.nix: Comprehensive NixOS VM tests (basic + web viewer)
- shell.nix: Development shell with all build tools

The NixOS module (services.meshcore-bot) provides:
- Automatic user/group creation (meshcore-bot:meshcore-bot)
- Serial port access (dialout group membership)
- Systemd service with security hardening
- Automatic directory management via StateDirectory/LogsDirectory
- INI config generation from Nix attribute sets
- Sensible defaults for system paths

Example NixOS configuration:
  services.meshcore-bot = {
    enable = true;
    settings = {
      Connection.connection_type = "serial";
      Connection.serial_port = "/dev/ttyUSB0";
      Bot.bot_name = "MyBot";
    };
  };

Migrated from requirements.txt to pyproject.toml:
- Defined proper package metadata and dependencies
- Created entry points: meshcore-bot, meshcore-viewer
- Enables standard 'pip install -e .' workflow
- Maintains compatibility with existing setups

Changes to existing code are minimal and only where necessary:

1. **Added --config parameter** (meshcore_bot.py, app.py)
   - Wrapped main logic in main() function for entry point
   - Added argparse to accept --config parameter
   - Required for NixOS to pass generated config from /nix/store
   - Backwards compatible: defaults to 'config.ini' in current directory
   - No changes to core bot logic

2. **Fixed web viewer subprocess spawning** (modules/web_viewer/integration.py)
   - Changed from sys.executable to 'meshcore-viewer' entry point
   - Ensures Nix wrapper script sets up correct PYTHONPATH
   - Resolves Flask module import issues in Nix environment
   - No functional change for traditional installations

Note: The dev branch's resolve_path() utility already handles both
relative and absolute paths correctly, making it compatible with
NixOS system paths (/var/lib, /var/log) without additional changes.

All NixOS VM tests passing:
- nixos-module-basic: Service startup, file creation, TCP connection
- nixos-module-webviewer: Flask available, port listening, HTTP responses

No breaking changes to existing workflows. The bot continues to work
exactly as before when run with traditional Python methods.
2026-01-07 14:01:39 +01:00
agessaman
6ca74723c9 fix: Improve error handling and client connection management in BotDataViewer
- Enhanced the handle_connect, handle_disconnect, handle_subscribe_commands, handle_subscribe_packets, and handle_ping methods to include better error handling and logging.
- Added checks for client_id to prevent issues during connection and disconnection events.
- Implemented database file existence and accessibility checks in the polling loop, with detailed logging for errors.
- Improved handling of database connection errors, including exponential backoff for persistent issues, ensuring more robust database interactions.
2026-01-03 20:57:29 -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
80b6bcceea Refactor database connection handling in web viewer and improve error logging; fix keyword reporting to web viewer
- Simplified database connection management by using context managers to ensure connections are properly closed.
- Enhanced error handling during MQTT client disconnection in packet capture service, logging specific exceptions.
- Updated message handling in MessageHandler to capture command data for web viewer integration, improving response tracking.
2026-01-01 12:16:22 -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
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
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
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
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
eddieoz
8a35dc8270 feat: Add security utilities for path validation, SQL injection prevention, and input sanitization. 2025-12-09 21:26:42 -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
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
agessaman
4cc9cc4c9c Implement duplicate greeting cleanup and enhance greeter command logic. Add new API endpoints for greeter management and update web viewer to include greeter statistics. Improve error handling and logging for greeted users, ensuring unique entries in the database. 2025-12-02 21:15:40 -08:00
agessaman
71d157a974 Enhance command execution and analytics features. Update CommandManager to allow DM-only commands in public channels to silently ignore errors if the channel is not configured. Refactor BaseCommand to improve execution checks based on channel permissions. In the web viewer, add time window parameters for analytics in the database stats API, and implement Chart.js for visualizing activity trends over the last 30 days. Update dashboard templates to include time window selectors for top users, commands, paths, and channels, improving user experience and data accessibility. 2025-11-30 20:04:20 -08:00
agessaman
b1c39edbb8 Add contact deletion functionality to the API and UI. Implement a new endpoint for deleting contacts, including error handling and logging. Update the contacts management interface to include a delete confirmation modal and handle the deletion process, ensuring proper updates to the displayed contact list and statistics. 2025-11-30 16:37:35 -08:00
agessaman
82aa5ee160 Add greeter command configuration to config.ini.example and implement greeter functionality in message handling. Introduce favorite status management for repeaters, allowing users to toggle favorite status via API. Update path command and test command to incorporate favorite bias in scoring. Enhance database schema to support star status tracking for repeaters and roomservers. 2025-11-25 17:26:40 -08:00
agessaman
bfd3336fe6 Removed connection toast as redundant. 2025-11-21 19:17:51 -08:00
agessaman
acc599c112 Initialize packet_stream table for real-time monitoring in the database. Added methods to create the table and relevant indexes in both BotDataViewer and BotIntegration classes, ensuring robust data handling and logging for initialization errors. 2025-11-21 19:07:44 -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
72bc36f081 Enhance geocoding functionality and logging in RepeaterManager and BotDataViewer 2025-11-06 21:38:33 -08:00
agessaman
e114de7947 Implement companion contact purging and configurable recency/proximity weighting
- Added configuration options for companion contact purging, including thresholds for inactivity based on direct messages and advertisements.
- Enhanced the RepeaterManager to support automatic purging of companions when contact limits are exceeded.
- Updated PathCommand to utilize configurable recency/proximity weighting for improved path routing decisions.
- Introduced new commands for purging companions and updated existing commands to handle companion purging logic.
- Added API endpoint for manual geocoding of contacts and improved web viewer functionality for geocoding contacts.
2025-11-06 20:58:52 -08:00
agessaman
acd17621a6 Enhance RepeaterManager with daily advertisement tracking and statistics
- Added a new 'daily_stats' table for tracking daily advertisement statistics.
- Implemented methods to track daily advertisement counts and retrieve statistics over specified date ranges.
- Updated existing advertisement tracking logic to utilize the new daily statistics.
- Modified web viewer to display advertisement metrics using the new daily tracking data.
- Improved path command logic to prioritize database queries over API cache for path decoding.
2025-10-24 22:27:25 -07:00
agessaman
836af3341a - Renamed 'modern_tracking.html' to 'contacts.html' for clarity in web viewer.
- Updated routes in 'app.py' to reflect the new contacts template.
- Enhanced 'sports_command.py' adding support for additional Portland teams
- Improved game data fetching logic to check multiple dates for recent and upcoming games.
2025-10-22 21:49:12 -07:00
agessaman
2b9ee79f23 remove purging template stub 2025-10-21 22:07:50 -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