Transports

Handles communication with signal-cli.

class signal_bot_framework.transport.TcpTransport(connection)

Bases: JsonRpcTransport

JsonRpcTransport for the tcp:// scheme.

async classmethod create(connection)

Create an instance of this transport.

Parameters:

connection (ParseResult) – urllib parsed connections string.

Return type:

Self

async write(data)

Write a notification to signal-cli.

Parameters:

data (NotificationFrame) – The notification to send.

Return type:

None

async listen(handler)

Listen for notifications and responses from signal-cli.

Parameters:

handler (JsonRpcHandler) – The class that will handle any received notifications or responses.

Return type:

None

class signal_bot_framework.transport.SubprocessTransport(signal_cli)

Bases: JsonRpcTransport

JsonRpcTransport for the ipc:// (interprocess communication) scheme.

async classmethod create(connection)

Create an instance of this transport.

Parameters:

connection (ParseResult) – urllib parsed connections string.

Return type:

Self

async write(data)

Write a notification to signal-cli.

Parameters:

data (NotificationFrame) – The notification to send.

Return type:

None

async listen(handler)

Listen for notifications and responses from signal-cli.

Parameters:

handler (JsonRpcHandler) – The class that will handle any received notifications or responses.

Return type:

None

Base Classes

class signal_bot_framework.transport.JsonRpcHandler(*args, **kwargs)

Bases: Protocol

Notified by JsonRpcTransport of incoming JSON RPC responses and notifications.

This abstract Protocol is implemented by SignalBot.

async handle_notification(notification)

Handle a JSON-RPC notification (a message that is not a response to a request).

Parameters:

notification (NotificationFrame) – The notification that was received.

Return type:

None

async handle_response(response)

Handle a JSON-RPC response (the result of a request).

Parameters:

response (ResponseFrame) – The response that was received.

Return type:

None

class signal_bot_framework.transport.JsonRpcTransport(*args, **kwargs)

Bases: Protocol

Allows for communication with signal-cli.

PROTOS: Dict[str, Type[Self]] = {'ipc': <class 'signal_bot_framework.transport.SubprocessTransport'>, 'tcp': <class 'signal_bot_framework.transport.TcpTransport'>}
abstract async classmethod create(connection)

Create an instance of this transport.

Parameters:

connection (ParseResult) – urllib parsed connections string.

Return type:

Self

abstract async write(data)

Write a notification to signal-cli.

Parameters:

data (NotificationFrame) – The notification to send.

Return type:

None

abstract async listen(handler)

Listen for notifications and responses from signal-cli.

Parameters:

handler (JsonRpcHandler) – The class that will handle any received notifications or responses.

Return type:

None

async terminate()

Terminate the connection to signal-cli (if necessary).

Return type:

None