Skip to content
Back to top
View this page

# XEP-0441: Message Archive Management Preferences

class slixmpp.plugins.xep_0441.XEP_0441(xmpp, config=None)

  XEP-0441: Message Archive Management Preferences

  dependencies: ClassVar[Set[str]] = {'xep_0313'}

    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-0441: Message Archive Management Preferences'

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

  async get_preferences(**iqkwargs)

    Get the current MAM preferences.

    Return type:

      `Tuple`[`Literal`[`'always'`, `'never'`, `'roster'`], `List`[`JID`], `List`[`JID`]]

    Returns:

      A tuple of MAM preferences with (default, always, never)

  name: str = 'xep_0441'

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

  set_preferences(default='roster', always=None, never=None, *, ito=None, ifrom=None, **iqkwargs)

    Set MAM Preferences.

    The server answer MAY contain different items.

    Parameters:

      - default (`Literal`[`'always'`, `'never'`, `'roster'`] | `None`) – Default behavior (one of ‘always’, ‘never’, ‘roster’).

      - always (`List`[`JID`] | `None`) – List of JIDs whose messages will always be stored.

      - never (`List`[`JID`] | `None`) – List of JIDs whose messages will never be stored.

    Return type:

      `Future`

## Stanza elements

class slixmpp.plugins.xep_0441.stanza.Preferences(xml=None, parent=None)

  MAM Preferences payload.

      <iq type='set' id='juliet3'>
        <prefs xmlns='urn:xmpp:mam:2' default='roster'>
          <always>
            <jid>romeo@montague.lit</jid>
          </always>
          <never>
            <jid>montague@montague.lit</jid>
          </never>
        </prefs>
      </iq>

  get_always()
    Return type:

      `Set`[`JID`]

  get_never()
    Return type:

      `Set`[`JID`]

  interfaces: ClassVar[Set[str]] = {'always', 'default', 'never'}

    Available interfaces:

    - `default`: Default MAM policy (must be one of ‘roster’, ‘always’, ‘never’

    - `always` (`List[JID]`): list of JIDs to always store conversations with.

    - `never` (`List[JID]`): list of JIDs to never store conversations with.

  name: ClassVar[str] = 'prefs'

    The XML tag name of the element, not including any namespace prefixes. For example, an `ElementBase` object for `<message />` would use `name = 'message'`.

  namespace: str = 'urn:xmpp:mam:2'

    The XML namespace for the element. Given `<foo xmlns="bar" />`, then `namespace = "bar"` should be used. The default namespace is `jabber:client` since this is being used in an XMPP library.

  plugin_attrib: ClassVar[str] = 'mam_prefs'

    For `ElementBase` subclasses which are intended to be used as plugins, the `plugin_attrib` value defines the plugin name. Plugins may be accessed by using the `plugin_attrib` value as the interface. An example using `plugin_attrib = 'foo'`:

        register_stanza_plugin(Message, FooPlugin)
        msg = Message()
        msg['foo']['an_interface_from_the_foo_plugin']

  set_always(value)
  set_never(value)
  sub_interfaces: ClassVar[Set[str]] = {'always', 'never'}

    A subset of `interfaces` which maps interfaces to direct subelements of the underlying XML object. Using this set, the text of these subelements may be set, retrieved, or removed without needing to define custom methods.