Commit 07b1a4c1 authored by Maxime Buquet's avatar Maxime Buquet

XEP-0421: add has_feature helper

Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent cec34686
......@@ -6,7 +6,7 @@
See the file LICENSE for copying permission.
"""
from slixmpp import Message
from slixmpp import JID, Message
from slixmpp.plugins import BasePlugin
from slixmpp.xmlstream import register_stanza_plugin
from slixmpp.plugins.xep_0421 import stanza
......@@ -18,9 +18,13 @@ class XEP_0421(BasePlugin):
name = 'xep_0421'
description = 'Anonymous unique occupant identifiers for MUCs'
dependencies = {'xep_0045'}
dependencies = {'xep_0030', 'xep_0045'}
stanza = stanza
def plugin_init(self) -> None:
# XXX: This should be MucMessage. Someday..
register_stanza_plugin(Message, OccupantId)
async def has_feature(self, jid: JID) -> bool:
info = await self.xmpp['xep_0030'].get_info(jid)
return self.stanza.NS in info.get_features()
......@@ -9,6 +9,9 @@
from slixmpp.xmlstream import ElementBase
NS = 'urn:xmpp:occupant-id:0'
class OccupantId(ElementBase):
'''
An Occupant-id tag.
......@@ -33,5 +36,5 @@ class OccupantId(ElementBase):
'''
name = 'occupant-id'
namespace = 'urn:xmpp:occupant-id:0'
namespace = NS
interface = {'id'}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment