XEP-0313: Message Archive Management¶
- class slixmpp.plugins.xep_0313.XEP_0313(xmpp, config=None)[source]¶
XEP-0313 Message Archive Management
- dependencies: ClassVar[Set[str]] = {'xep_0004', 'xep_0030', 'xep_0050', 'xep_0059', 'xep_0297'}¶
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-0313: Message Archive Management'¶
A longer name for the plugin, describing its purpose. For example, a plugin for XEP-0030 would use ‘Service Discovery’ as its description value.
- get_archive_metadata(jid=None, **iqkwargs)[source]¶
Get the archive metadata from a JID.
- Parameters:
jid (
Optional
[JID
]) – JID to get the metadata from.- Return type:
Future
- async get_configuration_commands(jid, **discokwargs)[source]¶
Get the list of MAM advanced configuration commands.
Changed in version 1.8.0.
- Parameters:
jid (
Optional
[JID
]) – JID to get the commands from.- Return type:
Future
- 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.
- Parameters:
jid (
Optional
[JID
]) – Entity holding the MAM recordsstart (
Optional
[datetime
]) – MAM query start timeend (
Optional
[datetime
]) – MAM query end timewith_jid (
Optional
[JID
]) – Filter results on this JIDifrom (
Optional
[JID
]) – To change the from address of the queryreverse (
bool
) – Get the results in reverse orderrsm (
Optional
[Dict
[str
,Any
]]) – RSM custom optionstotal (
Optional
[int
]) – A number of messages received after which the query should stop.
- Return type:
AsyncGenerator
- name: str = 'xep_0313'¶
A short name for the plugin based on the implemented specification. For example, a plugin for XEP-0030 would use ‘xep_0030’.
- 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:
jid (JID) – Entity holding the MAM records
start,end (datetime) – MAM query temporal boundaries
with_jid (JID) – Filter results on this JID
ifrom (JID) – To change the from address of the query
reverse (bool) – Get the results in reverse order
timeout (int) – IQ timeout
callback (func) – Custom callback for handling results
iterator (bool) – Use RSM and iterate over a paginated query
rsm (dict) – RSM custom options
- Return type:
Awaitable
Stanza elements¶
- 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>
- name: ClassVar[str] = 'query'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object 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:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'mam'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- interfaces: ClassVar[Set[str]] = {'after_id', 'before_id', 'end', 'flip_page', 'ids', 'queryid', 'results', 'start', 'with'}¶
Available interfaces:
queryid
: The MAM query idstart
andend
: 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.
- sub_interfaces: ClassVar[Set[str]] = {'after_id', 'before_id', 'end', 'flip_page', 'ids', 'start', 'with'}¶
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.
- setup(xml=None)[source]¶
Initialize the stanza’s XML contents.
Will return
True
if 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.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>
- name: ClassVar[str] = 'fin'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object 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:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'mam_fin'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- 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_attrib
value of any registered stanza plugins.
- setup(xml=None)[source]¶
Initialize the stanza’s XML contents.
Will return
True
if 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.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>
- name: ClassVar[str] = 'result'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object 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:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'mam_result'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- interfaces: ClassVar[Set[str]] = {'id', 'queryid'}¶
Available interfaces:
queryid
: MAM queryidid
: ID of the result
- 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
ElementBase
object 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:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'mam_metadata'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value 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>
- name: ClassVar[str] = 'start'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object 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:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'start'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- 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
- 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>
- name: ClassVar[str] = 'end'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object 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:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'end'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- 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