Presence Stanza#

class slixmpp.stanza.Presence(*args, recv=False, **kwargs)[source]#

XMPP’s <presence> stanza allows entities to know the status of other clients and components. Since it is currently the only multi-cast stanza in XMPP, many extensions add more information to <presence> stanzas to broadcast to every entry in the roster, such as capabilities, music choices, or locations (XEP-0115: Entity Capabilities and XEP-0163: Personal Eventing Protocol).

Since <presence> stanzas are broadcast when an XMPP entity changes its status, the bulk of the traffic in an XMPP network will be from <presence> stanzas. Therefore, do not include more information than necessary in a status message or within a <presence> stanza in order to help keep the network running smoothly.

Example <presence> stanzas:

<presence />

<presence from="user@example.com">
  <show>away</show>
  <status>Getting lunch.</status>
  <priority>5</priority>
</presence>

<presence type="unavailable" />

<presence to="user@otherhost.com" type="subscribe" />
Stanza Interface:
  • priority: A value used by servers to determine message routing.

  • show: The type of status, such as away or available for chat.

  • status: Custom, human readable status message.

Attributes:
  • types: One of: available, unavailable, error, probe, subscribe, subscribed, unsubscribe, and unsubscribed.

  • showtypes: One of: away, chat, dnd, and xa.

del_type()[source]#

Remove both the type attribute and the <show> element.

get_priority()[source]#

Return the value of the <presence> element as an integer.

Return type

int

get_type()[source]#

Return the value of the <presence> stanza’s type attribute, or the value of the <show> element if valid.

Return type

str

reply(clear=True)[source]#

Create a new reply <presence/> stanza from self.

Overrides StanzaBase.reply.

Parameters

clear (bool) – Indicates if the stanza contents should be removed before replying. Defaults to True.

set_priority(value)[source]#

Set the entity’s priority value. Some server use priority to determine message routing behavior.

Bot clients should typically use a priority of 0 if the same JID is used elsewhere by a human-interacting client.

Parameters

value (int) – An integer value greater than or equal to 0.

set_show(show)[source]#

Set the value of the <show> element.

Parameters

show (str) – Must be one of: away, chat, dnd, or xa.

set_type(value)[source]#

Set the type attribute’s value, and the <show> element if applicable.

Parameters

value (str) – Must be in either self.types or self.showtypes.