Skip to content
Back to top
View this page

# XEP-0410: MUC Self-Ping (Schrödinger’s Chat)

class slixmpp.plugins.xep_0410.XEP_0410(xmpp, config=None)

  XEP-0410: MUC Self-Ping (Schrödinger’s Chat)

  This plugin provides features for clients (or non-MUC components) to enable or disable self-ping.

  Configuration options:

  - ping_interval: the number of seconds between the last activity and a ping.

  Ping status is represented using the `PingStatus` class.

  Users of this plugin can either schedule the pings manually and send them using send_self_ping, or they can use the provided scheduler with enable_self_ping and disable_self_ping.

  Doing so requires calling update_nick if your nickname in a MUC changes, because the plugin is not aware of this. The scheduled ping will trigger a muc_ping_changed event in case the ping status changes, which should be handled properly.

  default_config: ClassVar[dict[str, Any]] = {'ping_interval': 900, 'ping_timeout': 30}

    The basic, standard configuration for the plugin, which may be overridden when initializing the plugin. The configuration fields included here may be accessed directly as attributes of the plugin. For example, including the configuration field ‘foo’ would mean accessing plugin.foo returns the current value of plugin.config[‘foo’].

  dependencies: ClassVar[set[str]] = {'xep_0045', 'xep_0199'}

    Some plugins may depend on others in order to function properly. Any plugin names included in `dependencies` will be initialized as needed if this plugin is enabled.

  description: str = "XEP-0410: MUC Self-Ping (Schrödinger's Chat)"

    A longer name for the plugin, describing its purpose. For example, a plugin for XEP-0030 would use ‘Service Discovery’ as its description value.

  disable_self_ping(muc_resource, orig_jid=None)

    Disable client self-ping. Cancels the scheduled pings for the given MUC resource.

    Parameters:

      - muc_resource (`JID`) – The MUC resource to send the ping to.

      - orig_jid (`JID` | `None`) – The “from” resource the ping was sent from (for components).

    Return type:

      `None`

  enable_self_ping(muc_resource, orig_jid=None, interval=None, timeout=None)

    Enable client self-ping. The given MUC resource will be pinged periodically if the MUC is inactive, and an event will be generated in case of changes.

    Parameters:

      - muc_resource (`JID`) – The MUC resource to send the ping to.

      - orig_jid (`JID` | `None`) – The “from” resource to send the ping from (for components).

    Return type:

      `None`

  get_ping_status(muc_resource, orig_jid=None)

    Return the last pinged status for a specific muc resource.

    Parameters:

      - muc_resource (`JID`) – The MUC resource to send the ping to.

      - orig_jid (`JID` | `None`) – The “from” resource the ping was sent from (for components).

    Return type:

      `PingStatus`

    Returns:

      The status, or None if no ping has been sent yet.

  name: str = 'xep_0410'

    A short name for the plugin based on the implemented specification. For example, a plugin for XEP-0030 would use ‘xep_0030’.

  async send_self_ping(muc_resource, orig_jid=None, timeout=None)

    Send a single self-ping to a MUC, and return the result.

    Parameters:

      - muc_resource (`JID`) – The MUC resource to send the ping to.

      - orig_jid (`JID` | `None`) – The “from” resource the ping was sent from (for components).

    Return type:

      `PingStatus`

    Returns:

      The ping status

  update_nick(previous_jid, new_jid)

    Update the self-ping targets when a nickname changes.

    Parameters:

      - previous_jid (`JID`) – full JID of the previous MUC resource.

      - new_jid (`JID`) – full JID of the new MUC resource.

    Return type:

      `None`

class slixmpp.plugins.xep_0410.PingStatus(*values)

  Enum representing the status of a ping.

  - UNTRIED: the ping was not sent yet

  - JOINED: we were considered still in the MUC at the last ping

  - JOINED_NICKCHANGED: we were joined but another client just changed the nick.

  - DISCONNECTED: we got disconnected

  - TIMEOUT: slixmpp was unable to reach the server