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 dependencies will 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]
get_excluded_types()[source]
Return type:

list[str]

get_included_types()[source]
Return type:

list[str]

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_attrib value of any registered stanza plugins.

name: ClassVar[str] = 'filter'

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:pubsub-filter:0'

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] = 'filter'

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_excluded_types(types)[source]
Return type:

None

set_included_types(types)[source]
Return type:

None

slixmpp.plugins.xep_0462.stanza.register_plugin()[source]