Commit Graph

407 Commits

Author SHA1 Message Date
agessaman
a4d1f678cf Enhance path handling in BotDataViewer and ModernContactsManager
- Added support for bytes per hop in the BotDataViewer, allowing for better path data representation.
- Updated the contacts template to display bytes per hop and adjusted path formatting based on this value.
- Improved the decode path functionality to utilize the correct bytes per hop for decoding paths, enhancing overall path handling and user experience.
2026-03-06 10:02:45 -08:00
agessaman
7d76ed443b Update dependencies and enhance path handling for multi-byte support
- Updated `meshcore` dependency version to `2.2.14` in both `pyproject.toml` and `requirements.txt`.
- Added multi-byte path support in the `PathCommand`, allowing for 1-, 2-, and 3-byte-per-hop paths.
- Enhanced `MessageHandler` to utilize `routing_info` for accurate path extraction and validation.
- Improved path extraction methods in `MultitestCommand` and `TestCommand` to prefer `routing_info` for node IDs.
- Refactored path handling logic across various commands to ensure consistent multi-byte path processing.
2026-03-05 13:37:38 -08:00
agessaman
4e5addd5df Add support for local plugins and services
- Updated `.gitignore` to include local configuration and plugin directories, allowing users to add custom commands and services without modifying core code.
- Enhanced `config.ini.example` with instructions for using local plugins and added sections for local service configurations.
- Refactored `PluginLoader` and `ServicePluginLoader` to support loading local commands and services from specified directories, improving extensibility.
- Updated `mkdocs.yml` to include documentation for local plugins and the check-in API.
- Added tests to verify the discovery and loading of local plugins, ensuring functionality and preventing name collisions with built-in plugins.
2026-03-04 18:33:45 -08:00
agessaman
1474174ba5 Refactor path handling in TraceCommand to prevent truncation of return paths
- Updated the logic in `TraceCommand` to avoid capping the `path_nodes` after building the reciprocal path, ensuring that the return path is preserved.
- Improved clarity in the code by adding a comment to explain the rationale behind the change.
2026-03-03 18:55:44 -08:00
agessaman
83dea195a4 Add hops placeholder for Keywords.
- Added support for `{hops}` and `{hops_label}` placeholders in `config.ini.example` and `core.py`, allowing for dynamic display of total hop count and pluralized labels in messages.
- Updated `format_keyword_response_with_placeholders` function in `utils.py` to extract and format hop count from message data, improving message clarity and detail.
- Ensured backward compatibility by providing default values for hop-related placeholders when not set.
2026-03-03 18:51:05 -08:00
agessaman
f789b72b92 Implement bot response bridging for Discord and Telegram
- Added configuration options to bridge the bot's own channel responses to Discord and Telegram, allowing command replies to be sent to respective channels.
- Updated `DiscordBridgeService` and `TelegramBridgeService` to register listeners for bot-sent messages, ensuring they are included in the bridging process.
- Enhanced `CommandManager` to invoke listeners with a synthetic event when a message is successfully sent, providing context about the message.
- Updated `config.ini.example` to reflect the new `bridge_bot_responses` option for both services.
- Added tests to verify the correct invocation of listeners upon successful message sending.
2026-03-02 16:39:30 -08:00
agessaman
d2f63c1025 Implement channel-specific triggers for random lines
- Added support for channel-specific triggers in the CommandManager, allowing triggers to be restricted to designated channels via `channel.<key>` or `channels.<key>` configuration.
- Updated `config.ini.example` to include examples of channel restrictions for triggers.
- Enhanced tests to verify that triggers only match in specified channels, ensuring proper functionality of the new feature.
2026-03-02 16:04:12 -08:00
agessaman
e348fd8d53 Enhance profanity filtering to include hate symbol detection and censorship
- Updated the profanity filter to check for hate symbols (e.g., swastika Unicode) in addition to word-based profanity, ensuring comprehensive message filtering.
- Modified the `censor` function to replace hate symbols with `***`, maintaining functionality even when the `better-profanity` package is unavailable.
- Updated documentation in `discord-bridge.md` and `telegram-bridge.md` to reflect the new hate symbol handling features.
- Added tests to verify detection and censorship of hate symbols, ensuring robustness of the profanity filter.
2026-03-01 21:56:13 -08:00
agessaman
3c56cbb69d Add profanity filter options for Discord and Telegram bridges
- Introduced `filter_profanity` configuration option in `config.ini.example` to handle profanity in bridged messages: options include `drop` (default), `censor`, or `off`.
- Updated `requirements.txt` to include `better-profanity` for profanity filtering functionality.
- Enhanced `DiscordBridgeService` and `TelegramBridgeService` to implement the profanity filter logic, allowing messages with profanity to be dropped or censored before bridging.
- Updated documentation in `discord-bridge.md` and `telegram-bridge.md` to reflect the new profanity handling feature.
2026-03-01 21:47:53 -08:00
agessaman
4982ba482d Enhance mesh graph handling for multi-resolution prefix support
- Updated `MeshGraph` to support multi-resolution storage of edges, allowing prefixes of 2, 4, or 6 hex chars without truncation.
- Implemented prefix matching logic to ensure distinct links are maintained and accurately retrieved based on prefix queries.
- Refactored methods in `MessageHandler` and `PathCommand` to accommodate variable prefix lengths during graph lookups.
- Enhanced tests to validate prefix match functionality and edge management in the mesh graph.
2026-03-01 20:42:06 -08:00
agessaman
1ac1060c18 Update config example and refactor prefix handling in BotDataViewer
- Commented out the 'help' command output in `config.ini.example` for clarity on overrides.
- Refactored prefix handling in `BotDataViewer` to use a dynamically retrieved `prefix_hex_chars` value instead of a hardcoded reference, improving flexibility and maintainability.
- Ensured consistent prefix handling across multiple instances in the `BotDataViewer` class.
2026-03-01 17:19:49 -08:00
agessaman
5c8ee3564e Fix time zone handling in format_elapsed_display function -- issue #75
- Updated the import statement for time zone handling in the `format_elapsed_display` function to use `timezone.utc` instead of `UTC` from `datetime`.
- Improved clarity and consistency in time zone management within the function.
2026-03-01 17:00:32 -08:00
agessaman
217d2a4089 Refactor database connection handling across multiple modules
- Replaced direct SQLite connection calls with a context manager in various modules to ensure proper resource management and prevent file descriptor leaks.
- Introduced a new `connection` method in `DBManager` to standardize connection handling.
- Updated all relevant database interactions in modules such as `feed_manager`, `scheduler`, `commands`, and others to utilize the new connection method.
- Improved code readability and maintainability by consolidating connection logic.
2026-03-01 14:12:22 -08:00
agessaman
c115d446e1 Improve channel message sending to use meshcore_py directly, initial implementation of optional flood scope
- Added `flood_scope` option to `[Channels]` section in `config.ini.example` for scoped flooding of channel messages.
- Updated `config-validation.md` to reflect the new `flood_scope` feature.
- Modified `CommandManager` to support optional flood scope during message sending, restoring global flood settings afterward.
- Removed unused imports from `core.py` related to meshcore-cli.
2026-03-01 13:33:02 -08:00
agessaman
7dc68cfb82 Enhance path formatting and translation updates for stats command
- Updated `_format_path_for_display` method to support multi-byte path formatting based on `bot.prefix_hex_chars`, ensuring compatibility with both legacy and new path formats.
- Improved handling of descriptive text in paths and added fallback logic for legacy paths.
- Added a synopsis format for path display in the stats command, providing a concise representation when message limits are exceeded.
- Updated translation files for multiple languages to include the new synopsis format for path data.
2026-03-01 11:23:35 -08:00
agessaman
dcb90188c0 feat(telegram-bridge): add one-way MeshCore → Telegram channel bridge
- Add TelegramBridgeService: CHANNEL_MSG_RECV → sendMessage, per-chat queues,
  rate limiting, retries; aiohttp with requests fallback; HTML formatting,
  truncation, no DMs
- Config [TelegramBridge]: api_token (or TELEGRAM_BOT_TOKEN), bridge.<channel>=chat_id
- Normalize channel matching (strip #, case-insensitive) so bridge.HashTagChannel matches #HashTagChannel
- Add config.ini / config.ini.example sections and docs/telegram-bridge.md
  (setup, private chat ID, troubleshooting)
2026-03-01 10:23:38 -08:00
agessaman
6b624c567a Enhance path handling and database schema for multi-byte prefix support
- Introduced a new utility function `decode_path_len_byte` to decode RF packet path length bytes, supporting both legacy and multi-byte paths.
- Updated various modules to utilize the new decoding logic, ensuring compatibility with configured prefix lengths.
- Modified database schemas to include `bytes_per_hop` and `out_bytes_per_hop` columns for better path management.
- Enhanced path parsing and validation across commands and services to accommodate variable prefix lengths.
- Improved logging and error handling for path-related operations, ensuring robustness during transitions.
2026-02-28 13:03:48 -08:00
Adam Gessaman
5c00e50cdc Merge pull request #77 from ianrifkin/prefixes
Add transitional support for 2-byte prefixes (while keeping legacy compatibility)
2026-02-28 10:20:09 -08:00
Adam Gessaman
af5961bf53 Merge branch 'dev' into prefixes 2026-02-28 10:19:50 -08:00
Ian Rifkin
36a8a67543 Add transitional support for 2-byte prefixes while keeping legacy 1-byte compatibility
- Update prefix command to accept BOTH legacy 2-char prefixes and
  configured prefix_hex_chars (e.g. 4-char) during firmware transition
- Replace strict length validation with dual-length validation (2 or N)
- Ensure prefix lookups work with either input length via LIKE matching
- Update related SQL prefix extraction to use configured prefix length
- Add fallback handling in path parsing for legacy 2-char route data

Notes:
- This is an interim compatibility change to support mixed networks
  where RF path data is still 1-byte while bot config may be 2-byte.
- Needs additional testing across real multi-hop scenarios and mixed
  bot configurations.
- Translation updates are incomplete: only English strings were updated;
  other translation files still need review.
- Behavior and UX may need refinement after real-world testing.
2026-02-27 23:48:27 -05:00
Adam Gessaman
1a576e80a6 Reverse path nodes in TraceCommand for correct tracing direction 2026-02-27 06:51:04 -08:00
agessaman
e5b6606ace Add output format configuration to trace command
- Updated `config.ini.example` to include an `output_format` option for the trace command, allowing users to choose between inline and vertical formats for trace results.
- Enhanced the `TraceCommand` class to handle the new output format, implementing methods for both inline and vertical formatting of trace results.
- Improved documentation within the code to clarify the behavior of the new output format feature.
2026-02-26 15:19:55 -08:00
agessaman
1921b23395 Enhance trace command functionality and documentation
- Updated the trace command's description and help text to clarify the behavior of the `trace` and `tracer` commands regarding path handling.
- Modified the `_format_trace_result` method to include the sender's ID in the response for better context in trace results.
- Adjusted the logic in the `execute` method to ensure proper path handling for tracer commands and when no path is provided.
2026-02-25 19:09:18 -08:00
agessaman
fcfde7ea33 Add data retention configuration and cleanup functionality
- Introduced a new `[Data_Retention]` section in `config.ini.example` to manage retention periods for various database tables, including packet stream, daily stats, and observed paths.
- Updated `mkdocs.yml` and `configuration.md` to include documentation for the new data retention settings.
- Implemented data retention cleanup methods in `mesh_graph.py`, `repeater_manager.py`, and `scheduler.py` to enforce retention policies automatically.
- Enhanced the web viewer's data cleanup logic to utilize the new retention settings, ensuring efficient database management.
2026-02-24 22:01:49 -08:00
Ian Rifkin
a4174beddf Adding example data files for momjokes and funfacts so it's a fully functioning thing 2026-02-25 00:16:43 -05:00
Ian Rifkin
7671c3a8de Add RandomLine matcher for file-based trigger responses with default momjokes and fun facts 2026-02-25 00:06:09 -05:00
agessaman
99328d6dd7 Update earthquake-service documentation to include credit section 2026-02-23 16:41:25 -08:00
agessaman
e9913c5780 Add Earthquake Service configuration and documentation
- Introduced `[Earthquake_Service]` section in `config.ini.example` to enable earthquake alerts with customizable parameters such as polling interval, time window, and minimum magnitude.
- Updated `service-plugins.md` to include documentation for the new Earthquake Service, detailing its functionality and default settings.
2026-02-23 16:37:31 -08:00
agessaman
513d1ec65b Add Earthquake Service configuration and documentation
- Introduced `[Earthquake_Service]` section in `config.ini.example` to enable earthquake alerts with customizable parameters such as polling interval, time window, and minimum magnitude.
- Updated `service-plugins.md` to include documentation for the new Earthquake Service, detailing its functionality and default settings.
2026-02-23 16:36:36 -08:00
agessaman
1c204dc389 Add trace command, configuration and documentation
- Introduced `[Trace_Command]` section in `config.ini.example` to enable link diagnostics with customizable parameters such as maximum hops, trace mode, and retry settings.
- Updated `command-reference.md` to include usage instructions and examples for the new `trace` and `tracer` commands, detailing their functionality for manual and round-trip tracing.
- Enhanced `mesh_graph.py` to support 2-byte trace confirmation for improved path weighting.
- Modified `message_handler.py` to update the mesh graph based on trace data, ensuring accurate edge representation in the graph.
- Added translations for the new trace commands in `en.json` to support user interaction in multiple languages.
2026-02-23 14:26:50 -08:00
agessaman
87b58d7ff8 Merge main into dev (port changes since 0.8.2) 2026-02-22 21:29:54 -08:00
agessaman
5cfa86d9e6 Increase SQLite connection timeout and implement WAL mode for improved concurrency in web viewer
- Updated SQLite connection timeout from 30 seconds to 60 seconds across multiple methods to reduce lock contention.
- Enabled Write-Ahead Logging (WAL) mode for better concurrent access between the bot and web viewer.
- Refactored packet insertion logic to include retry mechanism for handling locked database scenarios.
2026-02-22 21:02:31 -08:00
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
3604125b14 Enhance FAQ and error handling in bot operations
- Added a new FAQ section addressing common issues when moving a database to a new install, including schema mismatches, stale operations, and timeout errors.
- Updated error logging in `feed_manager.py` and `scheduler.py` to use `logger.exception` for better traceback visibility during message queue and channel operation errors.
- Improved command help text generation in `command_manager.py` to ensure proper formatting and context filtering based on message length.
- Enhanced command availability checks in `cmd_command.py` and `help_command.py` to respect channel-specific overrides and improve user experience.
2026-02-22 18:55:35 -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.
v0.8.2.1
2026-02-22 12:01:02 -08:00
agessaman
bb1dd95f1c Refactor timezone handling across commands and utilities
- 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.
2026-02-22 11:53:33 -08:00
Adam Gessaman
c634802d47 v0.8.2
- Added a version indicator to the bottom of the Web Viewer
- Added ability to filter by packet type in Packet Capture Service.
- Improved mesh graph efficiency, added documentation for how to configure mesh graph calculations (or disable it) on lightweight nodes like Raspberry Pi Zero 2s.
- Simplify contact removal logic. Occasional errors will still occur until race condition in meshcore_py 
- Improvements to documentation.
v0.8.2
2026-02-21 09:53:14 -08:00
agessaman
99f4ed32d9 Add packet type filtering documentation to packet-capture.md 2026-02-21 09:34:29 -08:00
agessaman
5d79f41b4c fix footer version formatting 2026-02-21 09:10:54 -08:00
agessaman
cb9d8255d7 Enhance web viewer integration with circuit breaker logic and improved error handling
- Introduced a circuit breaker mechanism to manage consecutive connection failures when sending updates to the web viewer, preventing log flooding during outages.
- Added methods to track send attempts and determine when to skip sending based on the circuit breaker state.
- Updated logging to provide feedback on circuit status and failures, improving troubleshooting capabilities.
- Refined message handling to ensure efficient communication with the web viewer, reducing unnecessary requests during downtime.
2026-02-20 15:51:23 -08:00
agessaman
54936a806e Refactor packet logging and enhance MQTT publishing metrics in PacketCaptureService
- Updated packet logging to indicate whether packets are captured or skipped based on filtering criteria.
- Modified the `publish_packet_mqtt` method to return additional metrics, including a flag for packets skipped due to type filtering.
- Improved clarity in logging and metrics to aid in diagnosing packet handling behavior.
2026-02-20 15:41:59 -08:00
Adam Gessaman
f5fedb52fd Add MQTT upload packet types configuration to config.ini.example and update PacketCaptureService to handle packet type filtering
- Introduced new configuration options for specifying packet types to upload in `config.ini.example`.
- Enhanced `PacketCaptureService` to parse and apply these settings, allowing for selective packet type uploads based on user-defined criteria.
- Improved logging to provide feedback when packets are skipped due to type filtering.
2026-02-20 13:41:55 -08:00
agessaman
6dcf256c77 Simplify contact removal logic and add versioning to webviewer. 2026-02-19 19:39:32 -08:00
agessaman
3afdfe6e01 Update Raspberry Pi Zero 2 W FAQ section with memory management tips
- Expanded the guidance on running meshcore-bot on Raspberry Pi Zero 2 W, detailing two steps to optimize memory usage: disabling the web viewer and tuning the Mesh Graph settings.
- Included specific configuration examples to help users effectively manage resource constraints on the device.
2026-02-18 15:46:16 -08:00
agessaman
de6580c231 Enhance web viewer troubleshooting documentation
- Added a comprehensive troubleshooting section for accessing the web viewer on devices like Orange Pi and SBCs, detailing configuration checks, process verification, log inspection, firewall settings, and standalone run instructions.
- Updated installation commands to include necessary dependencies for Flask and flask-socketio, improving clarity on setup requirements.
- Revised port conflict resolution steps to include updated commands for checking active ports.
2026-02-18 15:36:09 -08:00
agessaman
ff2f03d363 Enhance FAQ and path command configuration documentation
- Added a new section in the FAQ detailing how to run meshcore-bot on a Raspberry Pi Zero 2 W, including specific configuration settings to manage memory usage effectively.
- Updated the path command configuration documentation to clarify the default values and usage of `graph_startup_load_days` and `graph_capture_enabled`, improving user understanding of these settings.
2026-02-18 15:22:09 -08:00
agessaman
5b7250cdd4 Enhance graph data handling and configuration options
- Updated `config.ini.example` to include new settings for edge loading and graph data capture, providing clearer guidance on usage.
- Modified `MeshGraph` class to respect the new `graph_capture_enabled` setting, controlling the collection of edge data from incoming packets.
- Adjusted message handling to ensure graph updates only occur when data capture is enabled, optimizing performance and resource usage.
- Added tests to validate the new configuration options, ensuring proper functionality in various scenarios.
2026-02-18 15:09:53 -08:00
Adam Gessaman
da7db842be Merge pull request #59 from agessaman/dev
Minor release fixes.

Fix logic in multitest command to avoid having a subsequent request block both test requests.
Fixed issue with per-user rate limit that prevented second message responses from commands from being sent.
v0.8.1
2026-02-18 10:00:16 -08:00
agessaman
1b5a3dbd0e Improve message handling across multiple commands to respect per-user rate limits
- Updated the `send_response` method calls in various command classes to include a `skip_user_rate_limit` parameter for message continuations, ensuring that the per-user rate limit applies only to the first message.
- This change improves user experience by allowing seamless message continuations without unnecessary rate limiting.
2026-02-18 09:16:42 -08:00