slidgram.group#

Module Contents#

Classes#

Bookmarks

This is instantiated once per BaseSession

MUC

A room, a.k.a. a Multi-User Chat.

Participant

A legacy participant of a legacy group chat.

Attributes#

exception slidgram.group.NotAMember(status)[source]#

Bases: slixmpp.exceptions.XMPPError

A generic exception that may be raised while processing an XMPP stanza to indicate that an error response stanza should be sent.

The exception method for stanza objects extending RootStanza will create an error stanza and initialize any additional substanzas using the extension information included in the exception.

Meant for use in Slixmpp plugins and applications using Slixmpp.

Extension information can be included to add additional XML elements to the generated error stanza.

Parameters:
  • condition – The XMPP defined error condition. Defaults to 'undefined-condition'.

  • text – Human readable text describing the error.

  • etype – The XMPP error type, such as 'cancel' or 'modify'. Defaults to 'cancel'.

  • extension – Tag name of the extension’s XML content.

  • extension_ns – XML namespace of the extensions’ XML content.

  • extension_args – Content and attributes for the extension element. Same as the additional arguments to the Element constructor.

  • clear – Indicates if the stanza’s contents should be removed before replying with an error. Defaults to True.

  • status (aiotdlib.api.ChatMemberStatus) –

Initialize self. See help(type(self)) for accurate signature.

class slidgram.group.Bookmarks(*a, **k)[source]#

Bases: slidge.LegacyBookmarks[int, MUC]

This is instantiated once per BaseSession

session: slidgram.session.Session[source]#
async static legacy_id_to_jid_local_part(legacy_id)[source]#
Parameters:

legacy_id (int) –

async by_legacy_id(legacy_id)[source]#
Parameters:

legacy_id (int) –

Return type:

MUC

async by_group_id(group_id)[source]#
Parameters:

group_id (int) –

Return type:

Optional[MUC]

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.

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

class slidgram.group.MUC(*a, **k)[source]#

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

A room, a.k.a. a Multi-User Chat.

MUC instances are obtained by calling slidge.group.bookmarks.LegacyBookmarks() on the user’s slidge.core.session.BaseSession.

MAX_SUPER_GROUP_PARTICIPANTS = 200[source]#
session: slidgram.session.Session[source]#
_VALID_MEMBER_STATUSES = ()[source]#
static __avatar_id(best)[source]#
Parameters:

best (aiotdlib.api.File) –

Return type:

Optional[int]

async __fetch_avatar(best)[source]#
Parameters:

best (aiotdlib.api.File) –

update_tg_photo(photo)[source]#
Parameters:

photo (Optional[aiotdlib.api.ChatPhoto]) –

Return type:

None

async get_group()[source]#
Return type:

Union[aiotdlib.api.BasicGroup, aiotdlib.api.Supergroup]

async get_info()[source]#
Return type:

Union[aiotdlib.api.BasicGroupFullInfo, aiotdlib.api.SupergroupFullInfo]

async update_info(info=None)[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.

To take advantage of the slidge avatar cache, you can check the .avatar property to retrieve the “legacy file ID” of the cached avatar. If there is no change, you should not call slidge.core.mixins.avatar.AvatarMixin.set_avatar() or attempt to modify the :attr:.avatar property.

Parameters:

info (Optional[Union[aiotdlib.api.BasicGroupFullInfo, aiotdlib.api.SupergroupFullInfo]]) –

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

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

async fill_participants(info=None)[source]#

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

Parameters:

info (Optional[Union[aiotdlib.api.BasicGroupFullInfo, aiotdlib.api.SupergroupFullInfo]]) –

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

async admin_set_avatar(data, mime)[source]#
Parameters:
  • data (Optional[bytes]) –

  • mime (Optional[str]) –

Return type:

Optional[Union[int, str]]

async on_set_affiliation(contact, affiliation, reason, nickname)[source]#

Triggered when the user requests changing the affiliation of a contact for this group,

Examples: promotion them to moderator, kick (affiliation=none), ban (affiliation=outcast).

Parameters:
  • contact (slidgram.contact.Contact) – The contact whose affiliation change is requested

  • affiliation (slixmpp.types.MucAffiliation) – The new affiliation

  • reason (Optional[str]) – A reason for this affiliation change

  • nickname (Optional[str]) –

async on_set_config(name, description)[source]#

Triggered when the user requests changing the room configuration. Only title and description can be changed at the moment.

The legacy module is responsible for updating title and/or description of this instance.

If HAS_DESCRIPTION is set to False, description will always be None.

Parameters:
  • name (Optional[str]) – The new name of the room.

  • description (Optional[str]) – The new description of the room.

async on_destroy_request(reason)[source]#

Triggered when the user requests room destruction.

Parameters:

reason (Optional[str]) – Optionally, a reason for the destruction

async parse_mentions_utf16(text)[source]#
Parameters:

text (bytes) –

Return type:

list[slidge.util.types.Mention]

slidgram.group.AFFILIATIONS[source]#
class slidgram.group.Participant(*a, **k)[source]#

Bases: slidge.LegacyParticipant, slidgram.util.TelegramToXMPPMixin

A legacy participant of a legacy group chat.

contact: slidgram.contact.Contact[source]#
session: slidgram.session.Session[source]#
muc: MUC[source]#
__hash__()[source]#

Return hash(self).

slidgram.group.BACKFILLABLE = ()[source]#