slidge.core.muc
#
Submodules#
Package Contents#
Classes#
Abstract base class for generic types. |
|
Abstract base class for generic types. |
|
int([x]) -> integer |
- class slidge.core.muc.LegacyBookmarks(session)[source]#
Bases:
Generic
[slidge.util.types.LegacyGroupIdType
,slidge.util.types.LegacyMUCType
],slidge.core.mixins.lock.NamedLockMixin
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) –
- property user_nick#
- __iter__()#
- __repr__()#
Return repr(self).
- async __finish_init_muc(legacy_id, jid)#
- Parameters:
legacy_id (slidge.util.types.LegacyGroupIdType) –
jid (slixmpp.JID) –
- async legacy_id_to_jid_local_part(legacy_id)#
- Parameters:
legacy_id (slidge.util.types.LegacyGroupIdType) –
- async by_jid(jid)#
- Parameters:
jid (slixmpp.JID) –
- Return type:
slidge.util.types.LegacyMUCType
- async by_legacy_id(legacy_id)#
- Parameters:
legacy_id (slidge.util.types.LegacyGroupIdType) –
- Return type:
slidge.util.types.LegacyMUCType
- async fill()#
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.core.muc.LegacyParticipant(muc, nickname=None, is_user=False, is_system=False)[source]#
Bases:
slidge.core.mixins.PresenceMixin
,slidge.core.mixins.MessageMixin
,slidge.core.mixins.ChatterDiscoMixin
- Parameters:
muc (slidge.core.muc.room.LegacyMUC) –
nickname (Optional[str]) –
- property DISCO_NAME#
- mtype: slixmpp.types.MessageTypes = 'groupchat'#
- _can_send_carbon = False#
- USE_STANZA_ID = True#
- STRIP_SHORT_DELAY = False#
- __repr__()#
Return repr(self).
- _make_presence(*, last_seen=None, status_codes=None, user_full_jid=None, **presence_kwargs)#
- Parameters:
last_seen (Optional[datetime.datetime]) –
user_full_jid (Optional[slixmpp.JID]) –
- __send_presence_if_needed(stanza, full_jid, archive_only)#
- Parameters:
stanza (Union[slixmpp.Message, slixmpp.Presence]) –
full_jid (slixmpp.JID) –
archive_only (bool) –
- _send(stanza, full_jid=None, archive_only=False, **send_kwargs)#
- Parameters:
stanza (Union[slixmpp.Message, slixmpp.Presence]) –
full_jid (Optional[slixmpp.JID]) –
- mucadmin_item()#
- send_initial_presence(full_jid, nick_change=False, presence_id=None)#
Called when the user joins a MUC, as a mechanism to indicate to the joining XMPP client the list of “participants”.
Can be called this to trigger a “participant has joined the group” event.
- Parameters:
full_jid (slixmpp.JID) – Set this to only send to a specific user XMPP resource.
nick_change – Used when the user joins and the MUC renames them (code 210)
presence_id (Optional[str]) – set the presence ID. used internally by slidge
- leave()#
To be called only by room. To remove a participant, call Room.remove_participant(self) instead.
- get_disco_info()#
- class slidge.core.muc.LegacyMUC(session, legacy_id, jid)[source]#
Bases:
Generic
[slidge.util.types.LegacyGroupIdType
,slidge.util.types.LegacyMessageType
,slidge.util.types.LegacyParticipantType
,slidge.util.types.LegacyUserIdType
],slidge.core.mixins.lock.NamedLockMixin
,slidge.core.mixins.disco.ChatterDiscoMixin
,slidge.core.mixins.recipient.ReactionRecipientMixin
,slidge.core.mixins.recipient.ThreadRecipientMixin
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) –
legacy_id (slidge.util.types.LegacyGroupIdType) –
jid (slixmpp.JID) –
- property user_nick#
- property user_nick_non_none#
- property avatar#
- property name#
- property subject#
- property user_muc_jid#
- subject_date: datetime.datetime | None#
- max_history_fetch = 100#
- description = ''#
- type#
- is_group = True#
- DISCO_TYPE = 'text'#
- DISCO_CATEGORY = 'conference'#
- DISCO_NAME = 'unnamed-room'#
- STABLE_ARCHIVE = False#
Because legacy events like reactions, editions, etc. don’t all map to a stanza with a proper legacy ID, slidge usually cannot guarantee the stability of the archive across restarts.
Set this to True if you know what you’re doing, but realistically, this can’t be set to True until archive is permanently stored on disk by slidge.
This is just a flag on archive responses that most clients ignore anyway.
- _ALL_INFO_FILLED_ON_STARTUP = False#
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.
- __repr__()#
Return repr(self).
- async __fill_participants()#
- async __fill_history()#
- async __set_avatar(a)#
- Parameters:
a (Optional[slidge.util.types.AvatarType]) –
- __get_vcard()#
- async send_avatar(iq)#
- Parameters:
iq (slixmpp.Iq) –
- Parameters:
p (slixmpp.Presence) –
- async backfill(oldest_message_id=None, oldest_message_date=None)#
Override this if the legacy network provide server-side archive. In it, send history messages using
self.get_participant().send*
, with thearchive_only=True
kwarg.You only need to fetch messages older than
oldest_message_id
.- Parameters:
oldest_message_id (Optional[slidge.util.types.LegacyMessageType]) – The oldest message ID already present in the archive
oldest_message_date (Optional[datetime.datetime]) – The oldest message date already present in the archive
- async update_info()#
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.
- features()#
- async extended_features()#
- _make_subject_message(user_full_jid)#
- Parameters:
user_full_jid (slixmpp.JID) –
- shutdown()#
- user_full_jids()#
- _legacy_to_xmpp(legacy_id)#
- Parameters:
legacy_id (slidge.util.types.LegacyMessageType) –
- async echo(msg, legacy_msg_id=None)#
- Parameters:
msg (slixmpp.Message) –
legacy_msg_id (Optional[slidge.util.types.LegacyMessageType]) –
- _send_room_presence(user_full_jid=None)#
- Parameters:
user_full_jid (Optional[slixmpp.JID]) –
- async join(join_presence)#
- Parameters:
join_presence (slixmpp.Presence) –
- async get_user_participant(**kwargs)#
Get the participant representing the gateway user
- Parameters:
kwargs – additional parameters for the
Participant
construction (optional)- Returns:
- Return type:
slidge.util.types.LegacyParticipantType
- __store_participant(p)#
- Parameters:
p (slidge.util.types.LegacyParticipantType) –
- async get_participant(nickname, raise_if_not_found=False, fill_first=False, **kwargs)#
Get a participant by their nickname.
In non-anonymous groups, you probably want to use
LegacyMUC.get_participant_by_contact()
instead.- Parameters:
nickname (str) – Nickname of the participant (used as resource part in the MUC)
raise_if_not_found – Raise XMPPError(“item-not-found”) if they are not in the participant list (internal use by slidge, plugins should not need that)
fill_first – Ensure
LegacyMUC.fill_participants()
has been called first (internal use by slidge, plugins should not need that)kwargs – additional parameters for the
Participant
construction (optional)
- Returns:
- Return type:
slidge.util.types.LegacyParticipantType
- get_system_participant()#
Get a pseudo-participant, representing the room itself
Can be useful for events that cannot be mapped to a participant, e.g. anonymous moderation events, or announces from the legacy service :return:
- async get_participant_by_contact(c, **kwargs)#
Get a non-anonymous participant.
This is what should be used in non-anonymous groups ideally, to ensure that the Contact jid is associated to this participant
- Parameters:
c (slidge.core.contact.LegacyContact) – The
LegacyContact
instance corresponding to this contactkwargs – additional parameters for the
Participant
construction (optional)
- Returns:
- Return type:
slidge.util.types.LegacyParticipantType
- async get_participant_by_legacy_id(legacy_id, **kwargs)#
- Parameters:
legacy_id (slidge.util.types.LegacyUserIdType) –
- Return type:
slidge.util.types.LegacyParticipantType
- async get_participants()#
Get all known participants of the group, ensure
LegacyMUC.fill_participants()
has been awaited once before. Plugins should not use that, internal slidge use only. :return:
- remove_participant(p)#
This ho :param p: :return:
- Parameters:
p (slidge.util.types.LegacyParticipantType) –
- async fill_participants()#
In here, call self.get_participant(), self.get_participant_by_contact(), of self.get_user_participant() to make an initial list of participants.
- async _fill_history(full_jid, maxchars=None, maxstanzas=None, seconds=None, since=None)#
Old-style history join (internal slidge use)
- Parameters:
full_jid (slixmpp.JID) –
maxchars (Optional[int]) –
maxstanzas (Optional[int]) –
seconds (Optional[int]) –
since (Optional[datetime.datetime]) –
- Returns:
- async send_mam(iq)#
- Parameters:
iq (slixmpp.Iq) –
- async send_mam_metadata(iq)#
- Parameters:
iq (slixmpp.Iq) –
- class slidge.core.muc.MucType[source]#
-
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
Initialize self. See help(type(self)) for accurate signature.
- GROUP = 0#
- CHANNEL = 1#