XEP-0462: PubSub Type Filtering¶
- class slixmpp.plugins.xep_0462.XEP_0462(xmpp, config=None)[source]¶
XEP-0462: PubSub Type Filtering
This plugin makes it possible to filter pubsub items based on their types in disco#items queries.
Registering the plugin sets the disco feature, and registers stanza plugins.
- dependencies: ClassVar[set[str]] = {'xep_0004', 'xep_0030'}¶
Some plugins may depend on others in order to function properly. Any plugin names included in
dependencieswill be initialized as needed if this plugin is enabled.
- description: str = 'XEP-0462: PubSub Type Filtering'¶
A longer name for the plugin, describing its purpose. For example, a plugin for XEP-0030 would use ‘Service Discovery’ as its description value.
- name: str = 'xep_0462'¶
A short name for the plugin based on the implemented specification. For example, a plugin for XEP-0030 would use ‘xep_0030’.
- stanza = <module 'slixmpp.plugins.xep_0462.stanza' from '/build/reproducible-path/slixmpp-1.14.1/slixmpp/plugins/xep_0462/stanza.py'>¶
Stanza elements¶
Usage:
>>> from slixmpp import Iq
>>> register_stanza_plugin(Iq, DiscoItems) # automatically done when loading
>>> register_plugin() # the XEP_0462 plugin
>>> iq = Iq()
>>> iq["disco_items"]["filter"]["included_types"] = ["type1", "type2"]
>>> iq.pretty_print()
<iq xmlns="jabber:client" id="0">
<query xmlns="http://jabber.org/protocol/disco#items">
<filter xmlns="urn:xmpp:pubsub-filter:0">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>urn:xmpp:pubsub-filter:0</value>
</field>
<field var="included-types">
<value>type1</value>
<value>type2</value>
</field>
</x>
</filter>
</query>
</iq>
>>> iq["disco_items"]["filter"]["included_types"]
['type1', 'type2']
And similarly, an “excluded_types” interface is present.
- class slixmpp.plugins.xep_0462.stanza.Filter(xml=None, parent=None)[source]¶
-
- interfaces: ClassVar[set[str]] = {'excluded_types', 'included_types'}¶
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] = 'filter'¶
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:pubsub-filter:0'¶
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] = 'filter'¶
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']