Something went wrong. Try again.
Ruby API client for signal-cli JSON-RPC endpoint
Something went wrong. Try again.
Files
README.md
# signal_cli
Ruby API client for [signal-cli](https://github.com/AsamK/signal-cli) JSON-RPC endpoint.
A direct port of [pysignalclijsonrpc](https://gitlab.com/morph027/pysignalclijsonrpc) to Ruby.
Reference:
* [The JSON-RPC man page](https://github.com/AsamK/signal-cli/blob/master/man/signal-cli-jsonrpc.5.adoc)
*
## Installation
Add this line to your application's Gemfile:
```ruby
gem "signal_cli"
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install signal_cli
## Usage
Signal accounts can be specified in one of four formats:
* **Phone Number:** Standard international format, e.g. `+15551234567`
* **ACI:** The stable signal user id that does not ever change. It is in UUID format. e.g. `f7e7c8c4-5294-4011-9912-091d172e45ed`
* **PNI:** The signal identifier tied to particular phone number. The user that is attached to this PNI can change if a new user registers with an old phone number. Prefix the UUID with "PNI:". e.g. `PNI:ff7e7c8c-5294-4011-9912-091d172e45ed`
* **Username:** The temporary handle the user has chosen for themselves. Internally, signal-cli resolves this to an ACI. Add "u:" prefix. e.g. `u:username.123`
### Setup
```ruby
require "signal_cli"
client = SignalCli::Api.new(
endpoint: "http://localhost:8080/api/v1/rpc",
account: "+49123456789"
)
```
### Account lifecycle
```ruby
# Register your phone number with Signal
client.register
# Verify with the code received via SMS or voice call
client.verify(verification_code: "123-456")
# Check the signal-cli version
client.version # => "0.11.5.1"
```
### Sending messages
```ruby
# Send a simple text message
client.send_message(
recipients: ["+49123456789"],
message: "Hello from signal_rb!"
)
# Send a message with an attachment from a file
client.send_message(
recipients: ["+49123456789"],
message: "Check this out",
attachments_as_files: ["/path/to/photo.jpg"]
)
# Send a message with an attachment from raw bytes
client.send_message(
recipients: ["+49123456789"],
message: "Here's a …