XEP-0313: Message Archive Management¶
- class slixmpp.plugins.xep_0313.XEP_0313(xmpp, config=None)[source]¶
XEP-0313 Message Archive Management
- async get_configuration_commands(jid, **discokwargs)[source]¶
Get the list of MAM advanced configuration commands.
Changed in version 1.8.0.
- async iterate(jid=None, start=None, end=None, with_jid=None, ifrom=None, reverse=False, rsm=None, total=None)[source]¶
Iterate over each message of MAM query.
Added in version 1.8.0.
- retrieve(jid=None, start=None, end=None, with_jid=None, ifrom=None, reverse=False, timeout=None, callback=None, iterator=False, rsm=None)[source]¶
Send a MAM query and retrieve the results.
- Parameters:
start,end (datetime) – MAM query temporal boundaries
ifrom (
JID|None) – To change the from address of the queryreverse (
bool) – Get the results in reverse ordertimeout (
int|None) – IQ timeoutcallback (
Callable[[Iq],None] |None) – Custom callback for handling resultsiterator (
bool) – Use RSM and iterate over a paginated query
- Return type:
Awaitable[Iq]
Stanza elements¶
- class slixmpp.plugins.xep_0313.stanza.End(xml=None, parent=None)[source]¶
Metadata about the end of an archive.
<iq type='result' id='jui8921rr9'> <metadata xmlns='urn:xmpp:mam:2'> <start id='YWxwaGEg' timestamp='2008-08-22T21:09:04Z' /> <end id='b21lZ2Eg' timestamp='2020-04-20T14:34:21Z' /> </metadata> </iq>
- interfaces: ClassVar[set[str]] = {'id', 'timestamp'}¶
Available interfaces:
id: ID of the first message of the archivetimestamp(datetime): timestamp of the first message of the archive
- name: ClassVar[str] = 'end'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'urn:xmpp:mam:2'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'end'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- class slixmpp.plugins.xep_0313.stanza.Fin(xml=None, parent=None)[source]¶
A MAM fin element (end of query).
<iq type='result' id='juliet1'> <fin xmlns='urn:xmpp:mam:2'> <set xmlns='http://jabber.org/protocol/rsm'> <first index='0'>28482-98726-73623</first> <last>09af3-cc343-b409f</last> </set> </fin> </iq>
- interfaces: ClassVar[set[str]] = {'complete', 'results', 'stable'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attribvalue of any registered stanza plugins.
- name: ClassVar[str] = 'fin'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'urn:xmpp:mam:2'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'mam_fin'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- setup(xml=None)[source]¶
Initialize the stanza’s XML contents.
Will return
Trueif XML was generated according to the stanza’s definition instead of building a stanza object from an existing XML object.- Parameters:
xml – An existing XML object to use for the stanza’s content instead of generating new XML.
- class slixmpp.plugins.xep_0313.stanza.MAM(xml=None, parent=None)[source]¶
A MAM Query element.
<iq type='set' id='juliet1'> <query xmlns='urn:xmpp:mam:2'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>urn:xmpp:mam:2</value> </field> <field var='with'> <value>juliet@capulet.lit</value> </field> </x> </query> </iq>
- interfaces: ClassVar[set[str]] = {'after_id', 'before_id', 'end', 'flip_page', 'ids', 'queryid', 'results', 'start', 'with'}¶
Available interfaces:
queryid: The MAM query idstartandend: Temporal boundaries of the querywith: JID of the other entity the conversation is withafter_id: Fetch stanzas after this specific IDbefore_id: Fetch stanzas before this specific IDids: Fetch the stanzas matching those IDsresults: pseudo-interface used to accumulate MAM results during fetch, not relevant for the stanza itself.
- name: ClassVar[str] = 'query'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'urn:xmpp:mam:2'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'mam'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- setup(xml=None)[source]¶
Initialize the stanza’s XML contents.
Will return
Trueif XML was generated according to the stanza’s definition instead of building a stanza object from an existing XML object.- Parameters:
xml – An existing XML object to use for the stanza’s content instead of generating new XML.
- sub_interfaces: ClassVar[set[str]] = {'after_id', 'before_id', 'end', 'flip_page', 'ids', 'start', 'with'}¶
A subset of
interfaceswhich 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.
- class slixmpp.plugins.xep_0313.stanza.Metadata(xml=None, parent=None)[source]¶
Element containing archive metadata
<iq type='result' id='jui8921rr9'> <metadata xmlns='urn:xmpp:mam:2'> <start id='YWxwaGEg' timestamp='2008-08-22T21:09:04Z' /> <end id='b21lZ2Eg' timestamp='2020-04-20T14:34:21Z' /> </metadata> </iq>
- name: ClassVar[str] = 'metadata'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'urn:xmpp:mam:2'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'mam_metadata'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- class slixmpp.plugins.xep_0313.stanza.Result(xml=None, parent=None)[source]¶
A MAM result payload.
<message id='aeb213' to='juliet@capulet.lit/chamber'> <result xmlns='urn:xmpp:mam:2' queryid='f27' id='28482-98726-73623'> <forwarded xmlns='urn:xmpp:forward:0'> <delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/> <message xmlns='jabber:client' from="witch@shakespeare.lit" to="macbeth@shakespeare.lit"> <body>Hail to thee</body> </message> </forwarded> </result> </message>
- interfaces: ClassVar[set[str]] = {'id', 'queryid'}¶
Available interfaces:
queryid: MAM queryidid: ID of the result
- name: ClassVar[str] = 'result'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'urn:xmpp:mam:2'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'mam_result'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- class slixmpp.plugins.xep_0313.stanza.Start(xml=None, parent=None)[source]¶
Metadata about the start of an archive.
<iq type='result' id='jui8921rr9'> <metadata xmlns='urn:xmpp:mam:2'> <start id='YWxwaGEg' timestamp='2008-08-22T21:09:04Z' /> <end id='b21lZ2Eg' timestamp='2020-04-20T14:34:21Z' /> </metadata> </iq>
- interfaces: ClassVar[set[str]] = {'id', 'timestamp'}¶
Available interfaces:
id: ID of the first message of the archivetimestamp(datetime): timestamp of the first message of the archive
- name: ClassVar[str] = 'start'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'urn:xmpp:mam:2'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'start'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']