Skip to content

[4.2.0] Add Signal platform support#146

Open
dam2452 wants to merge 2 commits intomainfrom
signal-support
Open

[4.2.0] Add Signal platform support#146
dam2452 wants to merge 2 commits intomainfrom
signal-support

Conversation

@dam2452
Copy link
Copy Markdown
Owner

@dam2452 dam2452 commented Mar 26, 2026

Description

This Pull Request introduces support for the Signal messenger as a new platform for the bot, utilizing the signal-cli tool.

Key changes introduced in this PR:

  • RPC Communication: Implemented the SignalRPC class (bot/adapters/signal/signal_rpc.py) to handle asynchronous JSON-RPC communication with the signal-cli process.
  • New Adapters: Created SignalMessage and SignalResponder, implementing AbstractMessage and AbstractResponder respectively, for seamless integration with the bot's core logic (handling text, Markdown, photos, videos, and documents).
  • Signal Platform Runner: Added run_signal_bot (bot/platforms/signal_runner.py), which listens for incoming Signal events, identifies commands, and passes them through the middleware chain. Updated main.py to initialize the platform when enabled.
  • Database Updates: Updated init_db.sql by adding the signal_users table and an ID sequence. Added the get_or_create_signal_user method to DatabaseManager.
  • Configuration (settings.py): Expanded settings with the ENABLE_SIGNAL flag, as well as SIGNAL_PHONE_NUMBER and SIGNAL_CLI_PATH variables. Added validation requiring a phone number if the Signal platform is active.
  • Version Bump: Updated VERSION from 4.1.0 to 4.2.0.

dam2452 added 2 commits March 26, 2026 13:39
Introduce Signal integration using signal-cli JSON-RPC: add Signal adapter (SignalMessage, SignalResponder, SignalRPC) and a signal_runner to process incoming commands and wire handlers/middlewares. Persist Signal users: add signal_user_id_seq and signal_users table/index in init_db.sql and implement DatabaseManager.get_or_create_signal_user. Add settings flags (ENABLE_SIGNAL, SIGNAL_PHONE_NUMBER, SIGNAL_CLI_PATH) and validation, and register the Signal platform in main.py. Also update PermissionLevelFactory to build middlewares by inspecting handler command lists. SignalRPC manages a subprocess with JSON-RPC, SignalResponder strips markdown and handles file cleanup; JSON responses are not supported by the responder.
Bump VERSION to 4.2.0 and refactor Signal adapter internals.

- Converted many single-underscore attributes to double-underscore (name-mangled) for stronger encapsulation across SignalMessage, SignalResponder and SignalRPC.
- Moved markdown stripping into SignalResponder as a private static method and made its regexes private.
- Reworked SignalRPC lifecycle and I/O handling: track event handler tasks, validate started state in __call, use asyncio.get_running_loop() for futures, add timeout cleanup, create/track event tasks for incoming events, and set exceptions on pending futures if the connection closes. Stop now cancels and awaits event tasks before terminating the subprocess.
- Minor change in signal_runner to ensure rpc.stop() is always awaited in finally (removed a no-op CancelledError catch).

Overall these changes strengthen encapsulation and make the Signal RPC code more robust and resilient to process/IO shutdowns.
@dam2452 dam2452 changed the title Add Signal platform support [4.2.0] Add Signal platform support Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant