slidgram.group

Attributes

Classes

Bookmarks

This is instantiated once per BaseSession

MUC

Mixin for XMPP entities that have avatars that represent them.

Participant

A legacy participant of a legacy group chat.

Functions

is_owner_privileges(privileges)

Module Contents

class slidgram.group.Bookmarks(session)[source]

Bases: slidge.group.LegacyBookmarks[int, MUC]

This is instantiated once per BaseSession

Parameters:

session (slidge.core.session.BaseSession)

session: slidgram.session.Session[source]
property tg: slidgram.telegram.Client[source]
Return type:

slidgram.telegram.Client

static legacy_id_to_jid_local_part(legacy_id)[source]
Async:

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.

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

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

Bases: slidgram.reactions.ReactionsMixin, slidgram.avatar.SetAvatarMixin, slidge.group.LegacyMUC[int, int, Participant, int]

Mixin for XMPP entities that have avatars that represent them.

Both slidge.LegacyContact and slidge.LegacyMUC use AvatarMixin.

session: slidgram.session.Session[source]
legacy_id: int[source]
pinned_message_ids[source]
property tg: slidgram.telegram.Client[source]
Return type:

slidgram.telegram.Client

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.

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.

async fill_participants()[source]

This method should yield the list of all members of this group.

Typically, use participant = self.get_participant(), self.get_participant_by_contact(), of self.get_user_participant(), and update their affiliation, hats, etc. before yielding them.

async backfill(after=None, before=None)[source]

Override this if the legacy network provide server-side group archives.

In it, send history messages using self.get_participant(xxx).send_xxxx, with the archive_only=True kwarg. This is only called once per slidge run for a given group.

Parameters:
  • after (slidge.util.types.HoleBound | None) – Fetch messages after this one. If None, it’s up to you to decide how far you want to go in the archive. If it’s not None, it means slidge has some messages in this archive and you should really try to complete it to avoid “holes” in the history of this group.

  • before (slidge.util.types.HoleBound | None) – Fetch messages before this one. If None, fetch all messages up to the most recent one

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, ban (affiliation=outcast).

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

  • affiliation (slidge.util.types.MucAffiliation) – The new affiliation

  • reason (str | None) – A reason for this affiliation change

  • nickname (str | None)

async on_kick(contact, reason, nickname)[source]

Triggered when the user requests changing the role of a contact to “none” for this group. Action commonly known as “kick”.

Parameters:
async _on_ban(member, contact, until=zero_datetime())[source]
Parameters:
Return type:

None

async _on_set_member(member, contact)[source]
Parameters:
Return type:

None

async _on_set_admin(member, contact)[source]
Parameters:
Return type:

None

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 (str | None) – The new name of the room.

  • description (str | None) – The new description of the room.

async on_destroy_request(reason)[source]

Triggered when the user requests room destruction.

Parameters:

reason (str | None) – Optionally, a reason for the destruction

async on_avatar(data, mime)[source]

Called when the user tries to set the avatar of the room from an XMPP client.

If the set avatar operation is completed, should return a legacy image unique identifier. In this case the MUC avatar will be immediately updated on the XMPP side.

If data is not None and this method returns None, then we assume that self.set_avatar() will be called elsewhere, eg triggered by a legacy room update event.

Parameters:
  • data (bytes | None) – image data or None if the user meant to remove the avatar

  • mime (str | None) – the mime type of the image. Since this is provided by the XMPP client, there is no guarantee that this is valid or correct.

Returns:

A unique avatar identifier, which will trigger slidge.group.room.LegacyMUC.set_avatar(). Alternatively, None, if LegacyMUC.set_avatar() is meant to be awaited somewhere else.

Return type:

None

async on_set_subject(subject)[source]

Triggered when the user requests changing the room subject.

The legacy module is responsible for updating subject of this instance.

Parameters:

subject (str) – The new subject for this room.

Return type:

None

set_tg_pinned_message(message=None)[source]
Parameters:

message (pyrogram.types.Message | None)

Return type:

None

async set_tg_pinned_message_ids(message_ids, pinned)[source]
Parameters:
Return type:

None

serialize_extra_attributes()[source]
Return type:

dict

deserialize_extra_attributes(data)[source]
Parameters:

data (dict)

Return type:

None

class slidgram.group.Participant(*a, **kw)[source]

Bases: slidgram.tg_msg.TelegramMessageSenderMixin, slidge.group.LegacyParticipant

A legacy participant of a legacy group chat.

muc: MUC[source]
async send_tg_msg(message, carbon=False, correction=False, archive_only=False)[source]
Parameters:

message (pyrogram.types.Message)

Return type:

None

update_tg_member(member)[source]
Parameters:

member (pyrogram.types.ChatMember)

slidgram.group.is_owner_privileges(privileges)[source]
Parameters:

privileges (pyrogram.types.ChatPrivileges | None)

Return type:

bool

slidgram.group._NO_PRIVILEGES[source]
slidgram.group._ALL_PRIVILEGES[source]