slidge.core.muc.room#

Module Contents#

Classes#

MucType

int([x]) -> integer

LegacyMUC

Abstract base class for generic types.

Functions#

Attributes#

class slidge.core.muc.room.MucType[source]#

Bases: int, enum.Enum

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[source]#
CHANNEL = 1[source]#
slidge.core.muc.room.ADMIN_NS = 'http://jabber.org/protocol/muc#admin'[source]#
class slidge.core.muc.room.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:
property user_nick[source]#
property user_nick_non_none[source]#
property avatar[source]#
property name[source]#
property subject[source]#
property user_muc_jid[source]#
subject_date: datetime.datetime | None[source]#
n_participants: int | None[source]#
max_history_fetch = 100[source]#
description = ''[source]#
type[source]#
is_group = True[source]#
DISCO_TYPE = 'text'[source]#
DISCO_CATEGORY = 'conference'[source]#
DISCO_NAME = 'unnamed-room'[source]#
STABLE_ARCHIVE = False[source]#

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[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.

__repr__()[source]#

Return repr(self).

async __fill_participants()[source]#
async __fill_history()[source]#
async __set_avatar(a)[source]#
Parameters:

a (Optional[slidge.util.types.AvatarType]) –

__get_vcard()[source]#
async send_avatar(iq)[source]#
Parameters:

iq (slixmpp.Iq) –

_on_presence_unavailable(p)[source]#
Parameters:

p (slixmpp.Presence) –

async backfill(oldest_message_id=None, oldest_message_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 (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()[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.

update_subject(subject=None)[source]#
Parameters:

subject (Optional[str]) –

features()[source]#
async extended_features()[source]#
_make_subject_message(user_full_jid)[source]#
Parameters:

user_full_jid (slixmpp.JID) –

shutdown()[source]#
user_full_jids()[source]#
_legacy_to_xmpp(legacy_id)[source]#
Parameters:

legacy_id (slidge.util.types.LegacyMessageType) –

async echo(msg, legacy_msg_id=None)[source]#
Parameters:
  • msg (slixmpp.Message) –

  • legacy_msg_id (Optional[slidge.util.types.LegacyMessageType]) –

_send_room_presence(user_full_jid=None)[source]#
Parameters:

user_full_jid (Optional[slixmpp.JID]) –

async join(join_presence)[source]#
Parameters:

join_presence (slixmpp.Presence) –

async get_user_participant(**kwargs)[source]#

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)[source]#
Parameters:

p (slidge.util.types.LegacyParticipantType) –

async get_participant(nickname, raise_if_not_found=False, fill_first=False, **kwargs)[source]#

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()[source]#

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)[source]#

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:
Returns:

Return type:

slidge.util.types.LegacyParticipantType

async get_participant_by_legacy_id(legacy_id, **kwargs)[source]#
Parameters:

legacy_id (slidge.util.types.LegacyUserIdType) –

Return type:

slidge.util.types.LegacyParticipantType

async get_participants()[source]#

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)[source]#

This ho :param p: :return:

Parameters:

p (slidge.util.types.LegacyParticipantType) –

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 _fill_history(full_jid, maxchars=None, maxstanzas=None, seconds=None, since=None)[source]#

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)[source]#
Parameters:

iq (slixmpp.Iq) –

async send_mam_metadata(iq)[source]#
Parameters:

iq (slixmpp.Iq) –

async kick_resource(r)[source]#

Kick a XMPP client of the user. (slidge internal use)

Parameters:

r (str) – The resource to kick

slidge.core.muc.room.set_origin_id(msg, origin_id)[source]#
Parameters:
  • msg (slixmpp.Message) –

  • origin_id (str) –

slidge.core.muc.room.int_or_none(x)[source]#
slidge.core.muc.room.equals_zero(x)[source]#
slidge.core.muc.room.str_to_datetime_or_none(date)[source]#
Parameters:

date (Optional[str]) –

slidge.core.muc.room.log[source]#