Skip to content
Back to top
View this page

# XEP-0462: PubSub Type Filtering

XEP-0462 on xmpp.org

class slixmpp.plugins.xep_0462.XEP_0462(xmpp, config=None)

  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.

  stanza = <module 'slixmpp.plugins.xep_0462.stanza' from '/build/slixmpp-QRhfpR/slixmpp-1.17.0/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)
  get_excluded_types()
    Return type:

      `list`[`str`]

  get_included_types()
    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)
    Return type:

      `None`

  set_included_types(types)
    Return type:

      `None`

slixmpp.plugins.xep_0462.stanza.register_plugin()