slidge.plugins.whatsapp.group#

Module Contents#

Classes#

Participant

MUC

Abstract base class for generic types.

Bookmarks

Abstract base class for generic types.

class slidge.plugins.whatsapp.group.Participant(muc, nickname=None, is_user=False, is_system=False)[source]#

Bases: slidge.core.muc.LegacyParticipant

Parameters:
contact: slidge.plugins.whatsapp.contact.Contact[source]#
muc: MUC[source]#
send_text(body, legacy_msg_id, **kw)[source]#

Transmit a message from the entity to the user

Parameters:
  • body – Content of the message

  • legacy_msg_id – If you want to be able to transport read markers from the gateway user to the legacy network, specify this

  • when – when the message was sent, for a “delay” tag (XEP-0203)

  • reply_to – Quote another message (XEP-0461)

  • hints

  • thread

  • carbon – (only in 1:1) Reflect a message sent to this Contact by the user. Use this to synchronize outgoing history for legacy official apps.

  • correction – whether this message is a correction or not

  • archive_only – (only in groups) Do not send this message to user, but store it in the archive. Meant to be used during MUC.backfill()

async send_file(file_path, legacy_msg_id, **kw)[source]#

Send a message with an attachment

Parameters:
  • file_path – Path to the attachment

  • data_stream – Alternatively, a stream of bytes (such as a File object)

  • data – Alternatively, a bytes object

  • file_url – Alternatively, a URL

  • file_name – How the file should be named.

  • content_type – MIME type, inferred from filename if not given

  • legacy_msg_id – If you want to be able to transport read markers from the gateway user to the legacy network, specify this

  • reply_to – Quote another message (XEP-0461)

  • when – when the file was sent, for a “delay” tag (XEP-0203)

  • caption – an optional text that is linked to the file

  • legacy_file_id – A unique identifier for the file on the legacy network. Plugins should try their best to provide it, to avoid duplicates.

  • thread

_store(legacy_msg_id)[source]#
Parameters:

legacy_msg_id (str) –

class slidge.plugins.whatsapp.group.MUC(*a, **kw)[source]#

Bases: slidge.core.muc.LegacyMUC[str, str, Participant, str]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
session: slidge.plugins.whatsapp.session.Session[source]#
REACTIONS_SINGLE_EMOJI = True[source]#
type[source]#
_ALL_INFO_FILLED_ON_STARTUP = True[source]#
async join(*a, **kw)[source]#
get_message_sender(legacy_msg_id)[source]#
Parameters:

legacy_msg_id (str) –

async update_whatsapp_info(info)[source]#

Set MUC information based on WhatsApp group information, which may or may not be partial in case of updates to existing MUCs.

Parameters:

info (slidge.plugins.whatsapp.generated.whatsapp.Group) –

class slidge.plugins.whatsapp.group.Bookmarks(session)[source]#

Bases: slidge.core.muc.LegacyBookmarks[str, MUC]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
Parameters:

session (slidge.plugins.whatsapp.session.Session) –

session: slidge.plugins.whatsapp.session.Session[source]#
async fill()[source]#

Establish a user’s known groups.

This has to be overridden in plugins with group support and at the minimum, this should await self.by_legacy_id(group_id) for all the groups a user is part of.

Ideally, set the group subject, friendly, number, etc. in this method

Slidge internals will call this on successful BaseSession.login()

async add_whatsapp_group(data)[source]#
Parameters:

data (slidge.plugins.whatsapp.generated.whatsapp.Group) –

async legacy_id_to_jid_local_part(legacy_id)[source]#
Parameters:

legacy_id (str) –

async jid_local_part_to_legacy_id(local_part)[source]#
Parameters:

local_part (str) –