signalcli

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package signalcli adapts the Signal messenger to the inbox Source and Sink ports by speaking JSON-RPC to a signal-cli daemon. signal-cli runs as a separate, operator-supplied process (it links to an existing Signal account as a secondary device, so no separate phone number is needed) and exposes a newline-delimited JSON-RPC interface on a loopback TCP port. This package is a pure-Go client over that socket: it never embeds signal-cli and dials only the loopback daemon.

Incoming messages arrive as JSON-RPC "receive" notifications and are emitted as inbox entries; replies are sent with the "send" method. Each request carries a unique id and the client awaits the matching response before returning, so a reply is correlated to its call and a send is never lost behind another.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Signal source and sink backed by a signal-cli JSON-RPC daemon. Construct it with New.

func New

func New(tcpAddr string, opts ...Option) (*Client, error)

New builds a Signal client that talks to the signal-cli JSON-RPC daemon at the given loopback TCP address (for example 127.0.0.1:7583).

func (*Client) Name

func (c *Client) Name() string

Name identifies the source and its paired sink.

func (*Client) Receive

func (c *Client) Receive(ctx context.Context) (<-chan inbox.Spec, error)

Receive connects to the daemon and streams each incoming text message as an inbox.Spec until ctx is cancelled, reconnecting after a dropped connection. The returned channel is closed when ctx is cancelled. The Spec's Source is left for the ingester to stamp.

func (*Client) Send

func (c *Client) Send(ctx context.Context, conversation, text string) error

Send delivers a reply to a conversation: a +number is sent to that recipient, any other id is treated as a group id. It assigns a unique request id and waits for the matching response, so the reply is confirmed and never lost behind another.

type Option

type Option func(*Client)

Option configures a Client.

func WithAccount

func WithAccount(a string) Option

WithAccount sets the Signal account (the linked +number) to act as, required only when the daemon serves multiple accounts. Single-account daemons need none.

func WithClock

func WithClock(clk clock.Timing) Option

WithClock sets the clock that paces reconnect backoff, so a test drives re-dial timing with a Manual clock instead of sleeping. Production leaves the default System clock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL