Skip to content
Back to top
View this page

# XEP-0441: Message Archive Management Preferences

XEP-0441 on xmpp.org

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

  XEP-0441: Message Archive Management Preferences

  async get_preferences(**iqkwargs)

    Get the current MAM preferences.

    Takes all parameters from `iq.send()`.

    Return type:

      `tuple`[`Literal`[`'always'`, `'never'`, `'roster'`], `list`[`JID`], `list`[`JID`]]

    Returns:

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

  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`[`Iq`]

## 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()

    Get a usable set of JIDs the server always stores conversations for.

    Return type:

      `set`[`JID`]

  get_never()

    Get a usable set of JIDs the server never stores conversations for.

    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 the MAM policy to always archive for the specified JIDs.

    Parameters:

      value (`Iterable`[`JID`]) – List of JIDs.

  set_never(value)

    Set the MAM policy to never archive for the specified JIDs.

    Parameters:

      value (`Iterable`[`JID`]) – List of JIDs.

  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.