XEP-0421: add has_feature helper
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
cec34686fc
commit
07b1a4c1cd
2 changed files with 10 additions and 3 deletions
|
@ -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'}
|
||||
|
|
Loading…
Reference in a new issue