slidge_whatsapp.group#
Classes#
A legacy participant of a legacy group chat. |
|
A room, a.k.a. a Multi-User Chat. |
|
This is instantiated once per |
Functions#
|
|
|
Module Contents#
- class slidge_whatsapp.group.Participant(muc, nickname=None, is_user=False, is_system=False, role='participant', affiliation='member')[source]#
Bases:
slidge.group.LegacyParticipant
A legacy participant of a legacy group chat.
- Parameters:
muc (slidge.group.room.LegacyMUC) –
nickname (Optional[str]) –
role (slidge.util.types.MucRole) –
affiliation (slidge.util.types.MucAffiliation) –
- class slidge_whatsapp.group.MUC(session, legacy_id, jid)[source]#
Bases:
slidge.group.LegacyMUC
[str
,str
,Participant
,str
]A room, a.k.a. a Multi-User Chat.
MUC instances are obtained by calling
slidge.group.bookmarks.LegacyBookmarks()
on the user’sslidge.core.session.BaseSession
.- Parameters:
session (slidge.core.session.BaseSession) –
legacy_id (slidge.util.types.LegacyGroupIdType) –
jid (slixmpp.JID) –
- HAS_DESCRIPTION = False[source]#
Set this to false if the legacy network does not allow setting a description for the group. In this case the description field will not be present in the room configuration form.
- _ALL_INFO_FILLED_ON_STARTUP = True[source]#
Set this to true if the fill_participants() / fill_participants() design does not fit the legacy API, ie, no lazy loading of the participant list and history.
- 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 backfill(after=None, before=None)[source]#
Request history for messages older than the oldest message given by ID and date.
- Parameters:
after (slidge.util.types.HoleBound | None) –
before (slidge.util.types.HoleBound | None) –
- 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:
- 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.- Return type:
AsyncIterator[Participant]
- 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:
- Returns:
A unique avatar identifier, which will trigger
slidge.group.room.LegacyMUC.set_avatar()
. Alternatively, None, ifLegacyMUC.set_avatar()
is meant to be awaited somewhere else.- 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/ordescription
of this instance.If
HAS_DESCRIPTION
is set to False, description will always beNone
.
- 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.
- 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 (slidge_whatsapp.contact.Contact) – The contact whose affiliation change is requested
affiliation (slidge.util.types.MucAffiliation) – The new affiliation
reason (Optional[str]) – A reason for this affiliation change
nickname (Optional[str]) –
- class slidge_whatsapp.group.Bookmarks(session)[source]#
Bases:
slidge.group.LegacyBookmarks
[str
,MUC
]This is instantiated once per
BaseSession
- Parameters:
session (slidge_whatsapp.session.Session) –
- 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()