slidge.plugins.skype#

Module Contents#

Classes#

Gateway

Must be subclassed by a plugin to set up various aspects of the XMPP

Contact

This class centralizes actions in relation to a specific legacy contact.

ListenThread

A class that represents a thread of control.

Session

Represents a gateway user logged in to the network and performing actions.

Functions#

Attributes#

class slidge.plugins.skype.Gateway[source]#

Bases: slidge.BaseGateway[Session]

Must be subclassed by a plugin to set up various aspects of the XMPP component behaviour, such as its display name or its registration process.

On slidge launch, a singleton is instantiated, and it will be made available to public classes such LegacyContact or BaseSession as the .xmpp attribute. Since it inherits from slixmpp.componentxmpp.ComponentXMPP, this gives you a hand on low-level XMPP interactions via slixmpp plugins, e.g.:

self.send_presence(
    pfrom="somebody@component.example.com",
    pto="someonwelse@anotherexample.com",
)

However, you should not need to do so often since the classes of the plugin API provides higher level abstractions around most commonly needed use-cases, such as sending messages, or displaying a custom status.

REGISTRATION_INSTRUCTIONS = Enter skype credentials[source]#
REGISTRATION_FIELDS[source]#
ROSTER_GROUP = Skype[source]#
COMPONENT_NAME = Skype (slidge)[source]#
COMPONENT_TYPE = skype[source]#
COMPONENT_AVATAR = https://logodownload.org/wp-content/uploads/2017/05/skype-logo-1-1-2048x2048.png[source]#
async validate(user_jid, registration_form)[source]#

Validate a registration form from a user.

Since XEP-0077 is pretty limited in terms of validation, it is OK to validate anything that looks good here and continue the legacy auth process via direct messages to the user (using BaseGateway.input() for instance)

Parameters
shutdown()[source]#

Called by the slidge entrypoint on normal exit.

Sends offline presences from all contacts of all user sessions and from the gateway component itself. No need to call this manually, slidge.__main__.main() should take care of it.

class slidge.plugins.skype.Contact(session, legacy_id, jid_username)[source]#

Bases: slidge.LegacyContact

This class centralizes actions in relation to a specific legacy contact.

You shouldn’t create instances of contacts manually, but rather rely on LegacyRoster.by_legacy_id() to ensure that contact instances are singletons. The LegacyRoster instance of a session is accessible through the BaseSession.contacts attribute.

Typically, your plugin should have methods hook to the legacy events and call appropriate methods here to transmit the “legacy action” to the xmpp user. This should look like this:

Parameters
  • session (slidge.core.session.SessionType) – The session this contact is part of

  • legacy_id (slidge.util.types.LegacyContactIdType) – The contact’s legacy ID

  • jid_username (str) – User part of this contact’s ‘puppet’ JID. NB: case-insensitive, and some special characters are not allowed

update_presence(status)[source]#
Parameters

status (skpy.SkypeUtils.Status) –

class slidge.plugins.skype.ListenThread(session, *a, **kw)[source]#

Bases: threading.Thread

A class that represents a thread of control.

This class can be safely subclassed in a limited fashion. There are two ways to specify the activity: by passing a callable object to the constructor, or by overriding the run() method in a subclass.

This constructor should always be called with keyword arguments. Arguments are:

group should be None; reserved for future extension when a ThreadGroup class is implemented.

target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.

name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.

args is the argument tuple for the target invocation. Defaults to ().

kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.

If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.

Parameters

session (Session) –

skype_blocking()[source]#
stop()[source]#
class slidge.plugins.skype.Session(user)[source]#

Bases: slidge.BaseSession[Contact, slidge.LegacyRoster, Gateway]

Represents a gateway user logged in to the network and performing actions.

Will be instantiated automatically when a user sends an online presence to the gateway component, as per XEP-0100.

Must be subclassed for a functional slidge plugin.

skype_token_path :pathlib.Path[source]#
sk :skpy.Skype[source]#
async login()[source]#

Login the gateway user to the legacy network.

Triggered when the gateway start and on user registration. It is recommended that this function returns once the user is logged in, so if you need to await forever (for instance to listen to incoming events), it’s a good idea to wrap your listener in an asyncio.Task.

Returns

Optionally, a text to use as the gateway status, e.g., “Connected as ‘dude@legacy.network’”

async on_skype_event(event)[source]#
Parameters

event (skpy.SkypeEvent) –

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

async logout()[source]#

Logout the gateway user from the legacy network.

Called on user unregistration and gateway shutdown.

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.LegacyContact) – 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.LegacyContact) –

async composing(c)[source]#

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

Parameters

c (slidge.LegacyContact) –

async paused(c)[source]#

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

Parameters

c (slidge.LegacyContact) –

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 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
  • text (str) –

  • legacy_msg_id (Any) –

  • c (Contact) –

async retract(legacy_msg_id, c)[source]#

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

Parameters
  • legacy_msg_id (Any) – Legacy ID of the retracted message

  • c (Contact) – The contact this retraction refers to

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

get_msg(legacy_msg_id, contact)[source]#
Parameters
Return type

skpy.SkypeTextMsg

slidge.plugins.skype.handle_thread_exception(args)[source]#
Parameters

args (threading.ExceptHookArgs) –

slidge.plugins.skype.excepthook[source]#
slidge.plugins.skype.log[source]#