XEP-0030: Service Discovery#
- class slixmpp.plugins.xep_0030.XEP_0030(xmpp, config=None)[source]#
XEP-0030: Service Discovery
Service discovery in XMPP allows entities to discover information about other agents in the network, such as the feature sets supported by a client, or signposts to other, related entities.
Also see <http://www.xmpp.org/extensions/xep-0030.html>.
The XEP-0030 plugin works using a hierarchy of dynamic node handlers, ranging from global handlers to specific JID+node handlers. The default set of handlers operate in a static manner, storing disco information in memory. However, custom handlers may use any available backend storage mechanism desired, such as SQLite or Redis.
Node handler hierarchy:
JID
Node
Level
None
None
Global
Given
None
All nodes for the JID
None
Given
Node on self.xmpp.boundjid
Given
Given
A single node
Stream Handlers:
Disco Info -- Any Iq stanze that includes a query with the namespace http://jabber.org/protocol/disco#info. Disco Items -- Any Iq stanze that includes a query with the namespace http://jabber.org/protocol/disco#items.
Events:
disco_info – Received a disco#info Iq query result.
disco_items – Received a disco#items Iq query result.
Attributes:
- Variables
static – Object containing the default set of static node handlers.
- add_feature(feature, node=None, jid=None)[source]#
Add a feature to a JID/node combination.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
feature (
str
) – The namespace of the supported feature.node (
Optional
[str
]) – The node to modify.jid (
Optional
[JID
]) – The JID to modify.
- Return type
Future
- add_identity(category='', itype='', name='', node=None, jid=None, lang=None)[source]#
Add a new identity to the given JID/node combination.
Each identity must be unique in terms of all four identity components: category, type, name, and language.
Multiple, identical category/type pairs are allowed only if the xml:lang values are different. Likewise, multiple category/type/xml:lang pairs are allowed so long as the names are different. A category and type is always required.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
category (
str
) – The identity’s category.itype (
str
) – The identity’s type.name (
str
) – Optional name for the identity.lang (
Optional
[str
]) – Optional two-letter language code.node (
Optional
[str
]) – The node to modify.jid (
Optional
[JID
]) – The JID to modify.
- Return type
Future
- add_item(jid='', name='', node=None, subnode='', ijid=None)[source]#
Add a new item element to the given JID/node combination.
Each item is required to have a JID, but may also specify a node value to reference non-addressable entities.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
str
) – The JID for the item.name (
str
) – Optional name for the item.node (
Optional
[str
]) – The node to modify.subnode (
str
) – Optional node for the item.ijid (
Optional
[JID
]) – The JID to modify.
- Return type
Future
- del_feature(jid=None, node=None, **kwargs)[source]#
Remove a feature from a given JID/node combination.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – The JID to modify.node (
Optional
[str
]) – The node to modify.feature – The feature’s namespace.
- Return type
Future
- del_features(jid=None, node=None, **kwargs)[source]#
Remove all features from a JID/node combination.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – The JID to modify.node (
Optional
[str
]) – The node to modify.
- Return type
Future
- del_identities(jid=None, node=None, **kwargs)[source]#
Remove all identities for a JID/node combination.
If a language is specified, only identities using that language will be removed.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – The JID to modify.node (
Optional
[str
]) – The node to modify.lang – Optional. If given, only remove identities using this xml:lang value.
- Return type
Future
- del_identity(jid=None, node=None, **kwargs)[source]#
Remove an identity from the given JID/node combination.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – The JID to modify.node (
Optional
[str
]) – The node to modify.category – The identity’s category.
itype – The identity’s type value.
name – Optional, human readable name for the identity.
lang – Optional, the identity’s xml:lang value.
- Return type
Future
- del_item(jid=None, node=None, **kwargs)[source]#
Remove a single item from the given JID/node combination.
- Parameters
jid (
Optional
[JID
]) – The JID to modify.node (
Optional
[str
]) – The node to modify.ijid – The item’s JID.
inode – The item’s node.
- Return type
Future
- del_items(jid=None, node=None, **kwargs)[source]#
Remove all items from the given JID/node combination.
Changed in version 1.8.0: This function now returns a Future.
Arguments: :type jid:
Optional
[JID
] :param jid: The JID to modify. :type node:Optional
[str
] :param node: Optional node to modify.- Return type
Future
- del_node_handler(htype, jid, node)[source]#
Remove a handler type for a JID and node combination.
The next handler in the hierarchy will be used if one exists. If removing the global handler, make sure that other handlers exist to process existing nodes.
Node handler hierarchy:
JID
Node
Level
None
None
Global
Given
None
All nodes for the JID
None
Given
Node on self.xmpp.boundjid
Given
Given
A single node
- Parameters
htype (
str
) – The type of handler to remove.jid (
Optional
[JID
]) – The JID from which to remove the handler.node (
Optional
[str
]) – The node from which to remove the handler.
- async get_info(jid=None, node=None, local=None, cached=None, **kwargs)[source]#
Retrieve the disco#info results from a given JID/node combination.
Info may be retrieved from both local resources and remote agents; the local parameter indicates if the information should be gathered by executing the local node handlers, or if a disco#info stanza must be generated and sent.
If requesting items from a local JID/node, then only a DiscoInfo stanza will be returned. Otherwise, an Iq stanza will be returned.
Changed in version 1.8.0: This function is now a coroutine.
- Parameters
jid (
Optional
[JID
]) – Request info from this JID.node (
Optional
[str
]) – The particular node to query.local (
Optional
[bool
]) – If true, then the query is for a JID/node combination handled by this Slixmpp instance and no stanzas need to be sent. Otherwise, a disco stanza must be sent to the remote JID to retrieve the info.cached (
Optional
[bool
]) – If true, then look for the disco info data from the local cache system. If no results are found, send the query as usual. The self.use_cache setting must be set to true for this option to be useful. If set to false, then the cache will be skipped, even if a result has already been cached. Defaults to false.
- Return type
- async get_info_from_domain(domain=None, timeout=None, cached=True, callback=None)[source]#
Fetch disco#info of specified domain and one disco#items level below
- async get_items(jid=None, node=None, local=False, ifrom=None, **kwargs)[source]#
Retrieve the disco#items results from a given JID/node combination.
Items may be retrieved from both local resources and remote agents; the local parameter indicates if the items should be gathered by executing the local node handlers, or if a disco#items stanza must be generated and sent.
If requesting items from a local JID/node, then only a DiscoItems stanza will be returned. Otherwise, an Iq stanza will be returned.
Changed in version 1.8.0: This function is now a coroutine.
- Parameters
jid (
Optional
[JID
]) – Request info from this JID.node (
Optional
[str
]) – The particular node to query.local (
bool
) – If true, then the query is for a JID/node combination handled by this Slixmpp instance and no stanzas need to be sent. Otherwise, a disco stanza must be sent to the remove JID to retrieve the items.iterator – If True, return a result set iterator using the XEP-0059 plugin, if the plugin is loaded. Otherwise the parameter is ignored.
- Return type
- has_identity(jid=None, node=None, category=None, itype=None, lang=None, local=False, cached=True, ifrom=None)[source]#
Check if a JID provides a given identity.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – Request info from this JID.node (
Optional
[str
]) – The particular node to query.category (
Optional
[str
]) – The category of the identity to check.itype (
Optional
[str
]) – The type of the identity to check.lang (
Optional
[str
]) – The language of the identity to check.local (
bool
) – If true, then the query is for a JID/node combination handled by this Slixmpp instance and no stanzas need to be sent. Otherwise, a disco stanza must be sent to the remove JID to retrieve the info.cached (
bool
) – If true, then look for the disco info data from the local cache system. If no results are found, send the query as usual. The self.use_cache setting must be set to true for this option to be useful. If set to false, then the cache will be skipped, even if a result has already been cached. Defaults to false.
- Returns True
The identity is provided
- Returns False
The identity is not listed
- Returns None
Nothing could be found due to a timeout
- Return type
Future
- restore_defaults(jid=None, node=None, handlers=None)[source]#
Change all or some of a node’s handlers to the default handlers. Useful for manually overriding the contents of a node that would otherwise be handled by a JID level or global level dynamic handler.
The default is to use the built-in static handlers, but that may be changed by modifying self.default_handlers.
- Parameters
jid (
Optional
[JID
]) – The JID owning the node to modify.node (
Optional
[str
]) – The node to change to using static handlers.handlers (
Optional
[List
[Callable
]]) – Optional list of handlers to change to the default version. If provided, only these handlers will be changed. Otherwise, all handlers will use the default version.
- set_features(jid=None, node=None, **kwargs)[source]#
Add or replace the set of supported features for a JID/node combination.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – The JID to modify.node (
Optional
[str
]) – The node to modify.features – The new set of supported features.
- Return type
Future
- set_identities(jid=None, node=None, **kwargs)[source]#
Add or replace all identities for the given JID/node combination.
The identities must be in a set where each identity is a tuple of the form: (category, type, lang, name)
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – The JID to modify.node (
Optional
[str
]) – The node to modify.identities – A set of identities in tuple form.
lang – Optional, xml:lang value.
- Return type
Future
- set_info(jid=None, node=None, info=None)[source]#
Set the disco#info data for a JID/node based on an existing disco#info stanza.
Changed in version 1.8.0: This function now returns a Future.
- Return type
Future
- set_items(jid=None, node=None, **kwargs)[source]#
Set or replace all items for the specified JID/node combination.
The given items must be in a list or set where each item is a tuple of the form: (jid, node, name).
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – The JID to modify.node (
Optional
[str
]) – Optional node to modify.items – A series of items in tuple format.
- Return type
Future
- set_node_handler(htype, jid=None, node=None, handler=None)[source]#
Add a node handler for the given hierarchy level and handler type.
Node handlers are ordered in a hierarchy where the most specific handler is executed. Thus, a fallback, global handler can be used for the majority of cases with a few node specific handler that override the global behavior.
Node handler hierarchy:
JID
Node
Level
None
None
Global
Given
None
All nodes for the JID
None
Given
Node on self.xmpp.boundjid
Given
Given
A single node
Handler types:
get_info get_items set_identities set_features set_items del_items del_identities del_identity del_feature del_features del_item add_identity add_feature add_item
- Parameters
htype (
str
) – The operation provided by the handler.jid (
Optional
[JID
]) – The JID the handler applies to. May be narrowed further if a node is given.node (
Optional
[str
]) – The particular node the handler is for. If no JID is given, then the self.xmpp.boundjid.full is assumed.handler (
Optional
[Callable
]) – The handler function to use.
- supports(jid=None, node=None, feature=None, local=False, cached=True, ifrom=None)[source]#
Check if a JID supports a given feature.
Changed in version 1.8.0: This function now returns a Future.
- Parameters
jid (
Optional
[JID
]) – Request info from this JID.node (
Optional
[str
]) – The particular node to query.feature (
Optional
[str
]) – The name of the feature to check.local (
bool
) – If true, then the query is for a JID/node combination handled by this Slixmpp instance and no stanzas need to be sent. Otherwise, a disco stanza must be sent to the remove JID to retrieve the info.cached (
bool
) – If true, then look for the disco info data from the local cache system. If no results are found, send the query as usual. The self.use_cache setting must be set to true for this option to be useful. If set to false, then the cache will be skipped, even if a result has already been cached. Defaults to false.
- Returns True
The feature is supported
- Returns False
The feature is not listed as supported
- Returns None
Nothing could be found due to a timeout
- Return type
Future
Internal API Methods#
All api
operations supported by the 0030 plugin are implemented as part of
the StaticDisco
class which implement an in-memory cache for disco
info and items.
- class slixmpp.plugins.xep_0030.static.StaticDisco(xmpp, disco)[source]#
While components will likely require fully dynamic handling of service discovery information, most clients and simple bots only need to manage a few disco nodes that will remain mostly static.
StaticDisco provides a set of node handlers that will store static sets of disco info and items in memory.
- Variables
nodes – A dictionary mapping (JID, node) tuples to a dict containing a disco#info and a disco#items stanza.
xmpp – The main Slixmpp object.
disco – The instance of the XEP-0030 plugin.
- async supports(jid, node, ifrom, data)[source]#
Check if a JID supports a given feature.
The data parameter may provide:
- Parameters
feature – The feature to check for support.
local – If true, then the query is for a JID/node combination handled by this Slixmpp instance and no stanzas need to be sent. Otherwise, a disco stanza must be sent to the remove JID to retrieve the info.
cached – If true, then look for the disco info data from the local cache system. If no results are found, send the query as usual. The self.use_cache setting must be set to true for this option to be useful. If set to false, then the cache will be skipped, even if a result has already been cached. Defaults to false.
- Return type
Optional
[bool
]
- async has_identity(jid, node, ifrom, data)[source]#
Check if a JID has a given identity.
The data parameter may provide:
- Parameters
category – The category of the identity to check.
itype – The type of the identity to check.
lang – The language of the identity to check.
local – If true, then the query is for a JID/node combination handled by this Slixmpp instance and no stanzas need to be sent. Otherwise, a disco stanza must be sent to the remove JID to retrieve the info.
cached – If true, then look for the disco info data from the local cache system. If no results are found, send the query as usual. The self.use_cache setting must be set to true for this option to be useful. If set to false, then the cache will be skipped, even if a result has already been cached. Defaults to false.
- Return type
Optional
[bool
]
- get_info(jid, node, ifrom, data)[source]#
Return the stored info data for the requested JID/node combination.
The data parameter is not used.
- Return type
Optional
[DiscoInfo
]
- set_info(jid, node, ifrom, data)[source]#
Set the entire info stanza for a JID/node at once.
The data parameter is a disco#info substanza.
- del_info(jid, node, ifrom, data)[source]#
Reset the info stanza for a given JID/node combination.
The data parameter is not used.
- get_items(jid, node, ifrom, data)[source]#
Return the stored items data for the requested JID/node combination.
The data parameter is not used.
- Return type
Optional
[DiscoItems
]
- set_items(jid, node, ifrom, data)[source]#
Replace the stored items data for a JID/node combination.
- The data parameter may provide:
items – A set of items in tuple format.
- del_items(jid, node, ifrom, data)[source]#
Reset the items stanza for a given JID/node combination.
The data parameter is not used.
- add_identity(jid, node, ifrom, data)[source]#
Add a new identity to the JID/node combination.
The data parameter may provide:
- Parameters
category – The general category to which the agent belongs.
itype – A more specific designation with the category.
name – Optional human readable name for this identity.
lang – Optional standard xml:lang value.
- set_identities(jid, node, ifrom, data)[source]#
Add or replace all identities for a JID/node combination.
The data parameter should include:
- Parameters
identities – A list of identities in tuple form: (category, type, name, lang)
- del_identity(jid, node, ifrom, data)[source]#
Remove an identity from a JID/node combination.
The data parameter may provide:
- Parameters
category – The general category to which the agent belonged.
itype – A more specific designation with the category.
name – Optional human readable name for this identity.
lang – Optional, standard xml:lang value.
- del_identities(jid, node, ifrom, data)[source]#
Remove all identities from a JID/node combination.
The data parameter is not used.
- add_feature(jid, node, ifrom, data)[source]#
Add a feature to a JID/node combination.
The data parameter should include:
- Parameters
feature – The namespace of the supported feature.
- set_features(jid, node, ifrom, data)[source]#
Add or replace all features for a JID/node combination.
The data parameter should include:
- Parameters
features – The new set of supported features.
- del_feature(jid, node, ifrom, data)[source]#
Remove a feature from a JID/node combination.
The data parameter should include:
- Parameters
feature – The namespace of the removed feature.
- del_features(jid, node, ifrom, data)[source]#
Remove all features from a JID/node combination.
The data parameter is not used.
- add_item(jid, node, ifrom, data)[source]#
Add an item to a JID/node combination.
The data parameter may include:
- Parameters
ijid – The JID for the item.
inode – Optional additional information to reference non-addressable items.
name – Optional human readable name for the item.
- del_item(jid, node, ifrom, data)[source]#
Remove an item from a JID/node combination.
The data parameter may include:
- Parameters
ijid – JID of the item to remove.
inode – Optional extra identifying information.
Stanza elements#
- class slixmpp.plugins.xep_0030.stanza.info.DiscoInfo(xml=None, parent=None)[source]#
XMPP allows for users and agents to find the identities and features supported by other entities in the XMPP network through service discovery, or “disco”. In particular, the “disco#info” query type for <iq> stanzas is used to request the list of identities and features offered by a JID.
An identity is a combination of a category and type, such as the ‘client’ category with a type of ‘pc’ to indicate the agent is a human operated client with a GUI, or a category of ‘gateway’ with a type of ‘aim’ to identify the agent as a gateway for the legacy AIM protocol. See XMPP Registrar Disco Categories for a full list of accepted category and type combinations.
Features are simply a set of the namespaces that identify the supported features. For example, a client that supports service discovery will include the feature
http://jabber.org/protocol/disco#info
.Since clients and components may operate in several roles at once, identity and feature information may be grouped into “nodes”. If one were to write all of the identities and features used by a client, then node names would be like section headings.
Example disco#info stanza:
<iq type="get"> <query xmlns="http://jabber.org/protocol/disco#info" /> </iq> <iq type="result"> <query xmlns="http://jabber.org/protocol/disco#info"> <identity category="client" type="bot" name="Slixmpp Bot" /> <feature var="http://jabber.org/protocol/disco#info" /> <feature var="jabber:x:data" /> <feature var="urn:xmpp:ping" /> </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 = 'http://jabber.org/protocol/disco#info'#
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] = 'disco_info'#
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]] = {'features', 'identities', 'node'}#
Stanza interfaces:
node
: The name of the node to either query or return the info fromidentities
: A set of 4-tuples, where each tuple contains the category, type, xml:lang and name of an identityfeatures
: A set of namespaces for features
- setup(xml=None)[source]#
Populate the stanza object using an optional XML object.
Overrides ElementBase.setup
Caches identity and feature information.
- Parameters
xml (
Optional
[ElementTree
]) – Use an existing XML object for the stanza’s values.
- add_identity(category, itype, name=None, lang=None)[source]#
Add a new identity element. Each identity must be unique in terms of all four identity components.
Multiple, identical category/type pairs are allowed only if the xml:lang values are different. Likewise, multiple category/type/xml:lang pairs are allowed so long as the names are different. In any case, a category and type are required.
- Parameters
category (
str
) – The general category to which the agent belongs.itype (
str
) – A more specific designation with the category.name (
Optional
[str
]) – Optional human readable name for this identity.lang (
Optional
[str
]) – Optional standard xml:lang value.
- Return type
bool
- del_identity(category, itype, name=None, lang=None)[source]#
Remove a given identity.
- Parameters
category (
str
) – The general category to which the agent belonged.itype (
str
) – A more specific designation with the category.name – Optional human readable name for this identity.
lang (
Optional
[str
]) – Optional, standard xml:lang value.
- Return type
bool
- get_identities(lang=None, dedupe=True)[source]#
Return a set of all identities in tuple form as so:
(category, type, lang, name)
If a language was specified, only return identities using that language.
- Parameters
lang (
Optional
[str
]) – Optional, standard xml:lang value.dedupe (
bool
) – If True, de-duplicate identities, otherwise return a list of all identities.
- Return type
Iterable
[Tuple
[str
,str
,Optional
[str
],Optional
[str
]]]
- set_identities(identities, lang=None)[source]#
Add or replace all identities. The identities must be a in set where each identity is a tuple of the form:
(category, type, lang, name)
If a language is specifified, any identities using that language will be removed to be replaced with the given identities.
Note
An identity’s language will not be changed regardless of the value of lang.
- Parameters
identities (
Iterable
[Tuple
[str
,str
,Optional
[str
],Optional
[str
]]]) – A set of identities in tuple form.lang (
Optional
[str
]) – Optional, standard xml:lang value.
- del_identities(lang=None)[source]#
Remove all identities. If a language was specified, only remove identities using that language.
- Parameters
lang (
Optional
[str
]) – Optional, standard xml:lang value.
- add_feature(feature)[source]#
Add a single, new feature.
- Parameters
feature (
str
) – The namespace of the supported feature.- Return type
bool
- del_feature(feature)[source]#
Remove a single feature.
- Parameters
feature (
str
) – The namespace of the removed feature.- Return type
bool
- get_features(dedupe=True)[source]#
Return the set of all supported features.
- Return type
Iterable
[str
]
- class slixmpp.plugins.xep_0030.stanza.items.DiscoItem(xml=None, parent=None)[source]#
- name: ClassVar[str] = 'item'#
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object for<message />
would usename = 'message'
.
- namespace: str = 'http://jabber.org/protocol/disco#items'#
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] = 'item'#
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]] = {'jid', 'name', 'node'}#
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.
- plugins: Dict[Tuple[str, Optional[str]], ElementBase]#
An ordered dictionary of plugin stanzas, mapped by their
plugin_attrib
value.
- xml: ET.Element#
The underlying XML object for the stanza. It is a standard
xml.etree.ElementTree
object.
- iterables: List[ElementBase]#
A list of child stanzas whose class is included in
plugin_iterables
.
- tag: str#
The name of the tag for the stanza’s root element. It is the same as calling
tag_name()
and is formatted as'{namespace}elementname'
.
- parent: Optional[ReferenceType[ElementBase]]#
A
weakref.weakref
to the parent stanza, if there is one. If not, thenparent
isNone
.
- class slixmpp.plugins.xep_0030.stanza.items.DiscoItems(xml=None, parent=None)[source]#
Example disco#items stanzas:
<iq type="get"> <query xmlns="http://jabber.org/protocol/disco#items" /> </iq> <iq type="result"> <query xmlns="http://jabber.org/protocol/disco#items"> <item jid="chat.example.com" node="xmppdev" name="XMPP Dev" /> <item jid="chat.example.com" node="slixdev" name="Slixmpp Dev" /> </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 = 'http://jabber.org/protocol/disco#items'#
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] = 'disco_items'#
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]] = {'items', 'node'}#
Stanza Interface:
node
: The name of the node to either query or return info from.items
: A list of 3-tuples, where each tuple contains the JID, node, and name of an item.
- setup(xml=None)[source]#
Populate the stanza object using an optional XML object.
Overrides ElementBase.setup
Caches item information.
- Parameters
xml (
Optional
[ElementTree
]) – Use an existing XML object for the stanza’s values.
- add_item(jid, node=None, name=None)[source]#
Add a new item element. Each item is required to have a JID, but may also specify a node value to reference non-addressable entitities.
- Parameters
jid (
JID
) – The JID for the item.node (
Optional
[str
]) – Optional additional information to reference non-addressable items.name (
Optional
[str
]) – Optional human readable name for the item.
- del_item(jid, node=None)[source]#
Remove a single item.
- Parameters
jid (
JID
) – JID of the item to remove.node (
Optional
[str
]) – Optional extra identifying information.
- Return type
bool
- set_items(items)[source]#
Set or replace all items. The given items must be in a list or set where each item is a tuple of the form:
(jid, node, name)
- Parameters
items (
Iterable
[DiscoItem
]) – A series of items in tuple format.
- plugin_attrib_map: ClassVar[Dict[str, Type[ElementBase]]] = {'item': <class 'slixmpp.plugins.xep_0030.stanza.items.DiscoItem'>}#
A mapping of the
plugin_attrib
values of registered plugins to their respective classes.
- plugin_iterables: ClassVar[Set[Type[ElementBase]]] = {<class 'slixmpp.plugins.xep_0030.stanza.items.DiscoItem'>}#
The set of stanza classes that can be iterated over using the ‘substanzas’ interface. Classes are added to this set when registering a plugin with
iterable=True
:register_stanza_plugin(DiscoInfo, DiscoItem, iterable=True)
New in version 1.0-Beta5.
- plugin_overrides: ClassVar[Dict[str, str]] = {}#
A map of interface operations to the overriding functions. For example, after overriding the
set
operation for the interfacebody
,plugin_overrides
would be:{'set_body': <some function>}
- plugin_tag_map: ClassVar[Dict[str, Type[ElementBase]]] = {'{http://jabber.org/protocol/disco#items}item': <class 'slixmpp.plugins.xep_0030.stanza.items.DiscoItem'>}#
A mapping of root element tag names (in
'{namespace}elementname'
format) to the plugin classes responsible for them.