slidge.plugins.signal.session#

Module Contents#

Classes#

Session

Represents a signal account

Functions#

Attributes#

log

slidge.plugins.signal.session.handle_unregistered_recipient(func)[source]#
class slidge.plugins.signal.session.Session(user)[source]#

Bases: slidge.BaseSession[slidge.plugins.signal.contact.Contact, slidge.plugins.signal.contact.Roster, slidge.plugins.signal.gateway.Gateway]

Represents a signal account

Parameters

user (slidge.GatewayUser) –

static xmpp_msg_id_to_legacy_msg_id(i)[source]#

Convert a legacy XMPP ID to a valid XMPP msg ID. Needed for read marks and message corrections.

The default implementation just converts the legacy ID to a str, but this should be overridden in case some characters needs to be escaped, or to add some additional, legacy network-specific logic.

The default implementation is an identity function

Parameters

i (str) – The XMPP stanza ID

Returns

An ID that can be used to identify a message on the legacy network

Return type

int

async paused(c)[source]#

Triggered when the user pauses typing in the window of a legacy contact (XEP-0085)

Parameters

c (slidge.plugins.signal.contact.Contact) –

async correct(text, legacy_msg_id, c)[source]#

Triggered when the user corrected a message using XEP-0308

This is only possible if a valid legacy_msg_id was passed when transmitting a message from a contact to the user in LegacyContact.send_text() or slidge.LegacyContact.send_file().

Parameters
async search(form_values)[source]#

Triggered when the user uses Jabber Search (XEP-0055) on the component

Form values is a dict in which keys are defined in BaseGateway.SEARCH_FIELDS

Parameters

form_values (dict[str, str]) – search query, defined for a specific plugin by overriding in BaseGateway.SEARCH_FIELDS

Returns

async login()[source]#

Attempt to listen to incoming events for this account, or pursue the registration process if needed.

async on_websocket_connection_state(state)[source]#
Parameters

state (aiosignald.generated.WebSocketConnectionStatev1) –

async register()[source]#
async send_linking_qrcode()[source]#
async logout()[source]#

Logout the gateway user from the legacy network.

Called on user unregistration and gateway shutdown.

async add_contacts_to_roster()[source]#

Populate a user’s roster

async on_signal_message(msg)[source]#

User has received ‘something’ from signal

Parameters

msg (aiosignald.generated.IncomingMessagev1) –

async send_text(t, c, *, reply_to_msg_id=None)[source]#

Triggered when the user sends a text message from xmpp to a bridged contact, e.g. to translated_user_name@slidge.example.com.

Override this and implement sending a message to the legacy network in this method.

Parameters
Returns

An ID of some sort that can be used later to ack and mark the message as read by the user

Return type

int

async send_file(u, c, *, reply_to_msg_id=None)[source]#

Triggered when the user has sends a file using HTTP Upload (XEP-0363)

Parameters
Returns

An ID of some sort that can be used later to ack and mark the message as read by the user

async active(c)[source]#

Triggered when the user sends an ‘active’ chat state to the legacy network (XEP-0085)

Parameters

c (slidge.plugins.signal.contact.Contact) – Recipient of the active chat state

async inactive(c)[source]#

Triggered when the user sends an ‘inactive’ chat state to the legacy network (XEP-0085)

Parameters

c (slidge.plugins.signal.contact.Contact) –

async composing(c)[source]#

Triggered when the user starts typing in the window of a legacy contact (XEP-0085)

Parameters

c (slidge.plugins.signal.contact.Contact) –

async displayed(legacy_msg_id, c)[source]#

Triggered when the user reads a message sent by a legacy contact. (XEP-0333)

This is only possible if a valid legacy_msg_id was passed when transmitting a message from a contact to the user in LegacyContact.sent_text() or slidge.LegacyContact.send_file().

Parameters
async react(legacy_msg_id, emojis, c)[source]#

Triggered when the user sends message reactions (XEP-0444).

Parameters
  • legacy_msg_id (int) – ID of the message the user reacts to

  • emojis (list[str]) – Unicode characters representing reactions to the message legacy_msg_id. An empty string means “no reaction”, ie, remove all reactions if any were present before

  • c (slidge.plugins.signal.contact.Contact) – Contact the reaction refers to

async retract(legacy_msg_id, c)[source]#

Triggered when the user retracts (XEP-0424) a message.

Parameters
async add_device(uri)[source]#
Parameters

uri (str) –

slidge.plugins.signal.session.log[source]#