slidge.plugins.telegram.group#

Module Contents#

Classes#

Bookmarks

Abstract base class for generic types.

MUC

Abstract base class for generic types.

Participant

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

Bases: slidge.LegacyBookmarks[int, 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.core.session.BaseSession) –

session: slidge.plugins.telegram.session.Session[source]#
async static legacy_id_to_jid_local_part(legacy_id)[source]#
Parameters:

legacy_id (int) –

async jid_local_part_to_legacy_id(local_part)[source]#
Parameters:

local_part (str) –

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()

class slidge.plugins.telegram.group.MUC(*a, **k)[source]#

Bases: slidge.plugins.telegram.util.AvailableEmojisMixin, slidge.LegacyMUC[int, int, Participant, int]

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
MAX_SUPER_GROUP_PARTICIPANTS = 200[source]#
session: slidge.plugins.telegram.session.Session[source]#
type[source]#
async update_info()[source]#

Fetch information about this group from the legacy network

This is awaited on MUC instantiation, and should be overridden to update the attributes of the group chat, like title, subject, number of participants etc.

async update_subject_from_msg(msg=None)[source]#
Parameters:

msg (Optional[aiotdlib.api.Message]) –

async fill_participants()[source]#

In here, call self.get_participant(), self.get_participant_by_contact(), of self.get_user_participant() to make an initial list of participants.

async send_text(text)[source]#
Parameters:

text (str) –

Return type:

int

async participant_by_tg_user(user)[source]#
Parameters:

user (aiotdlib.api.User) –

Return type:

Participant

async get_tg_chat()[source]#
async backfill(oldest_message_id=None, oldest_date=None)[source]#

Override this if the legacy network provide server-side archive. In it, send history messages using self.get_participant().send*, with the archive_only=True kwarg.

You only need to fetch messages older than oldest_message_id.

Parameters:
  • oldest_message_id – The oldest message ID already present in the archive

  • oldest_message_date – The oldest message date already present in the archive

async fetch_history(n, before=None)[source]#
Parameters:
  • n (int) –

  • before (Optional[int]) –

async participant_by_sender_id(sender_id)[source]#
Parameters:

sender_id (aiotdlib.api.MessageSender) –

class slidge.plugins.telegram.group.Participant(*a, **k)[source]#

Bases: slidge.LegacyParticipant, slidge.plugins.telegram.util.TelegramToXMPPMixin

contact: slidge.plugins.telegram.contact.Contact[source]#
session: slidge.plugins.telegram.session.Session[source]#
muc: MUC[source]#
__hash__()[source]#

Return hash(self).