XEP-0403: MIX-Presence

This commit is contained in:
mathieui 2020-11-30 21:24:20 +01:00
parent b62ea49de3
commit 350f85a8d1
4 changed files with 98 additions and 0 deletions

View file

@ -87,6 +87,7 @@ __all__ = [
'xep_0332', # HTTP Over XMPP Transport 'xep_0332', # HTTP Over XMPP Transport
'xep_0369', # MIX-CORE 'xep_0369', # MIX-CORE
'xep_0377', # Spam reporting 'xep_0377', # Spam reporting
'xep_0403', # MIX-Presence
'xep_0404', # MIX-Anon 'xep_0404', # MIX-Anon
'xep_0405', # MIX-PAM 'xep_0405', # MIX-PAM
'xep_0421', # Anonymous unique occupant identifiers for MUCs 'xep_0421', # Anonymous unique occupant identifiers for MUCs

View file

@ -0,0 +1,13 @@
"""
Slixmpp: The Slick XMPP Library
Copyright (C) 2020 Mathieu Pasquet <mathieui@mathieui.net>
This file is part of Slixmpp.
See the file LICENSE for copying permission.
"""
from slixmpp.plugins.base import register_plugin
from slixmpp.plugins.xep_0403.stanza import *
from slixmpp.plugins.xep_0403.mix_presence import XEP_0403
register_plugin(XEP_0403)

View file

@ -0,0 +1,47 @@
"""
Slixmpp: The Slick XMPP Library
Copyright (C) 2020 Mathieu Pasquet <mathieui@mathieui.net>
This file is part of Slixmpp.
See the file LICENSE for copying permission.
"""
from typing import (
Optional,
Set,
)
from slixmpp import JID, Iq
from slixmpp.exceptions import IqError, IqTimeout
from slixmpp.plugins import BasePlugin
from slixmpp.plugins.xep_0403 import stanza
from slixmpp.xmlstream.matcher import MatchXPath
from slixmpp.xmlstream.handler import Callback
NODES = [
'urn:xmpp:mix:nodes:presence'
]
class XEP_0403(BasePlugin):
'''XEP-0403: MIX-Presence'''
name = 'xep_0403'
description = 'MIX-Presence'
dependencies = {'xep_0369'}
stanza = stanza
namespace = stanza.NS
def plugin_init(self) -> None:
stanza.register_plugins()
self.xmpp.register_handler(
Callback(
'MIX Presence received',
MatchXPath('{%s}presence/{%s}mix' % (self.xmpp.default_ns, stanza.NS)),
self._handle_mix_presence,
)
)
def _handle_mix_presence(self, presence):
self.xmpp.event('mix_presence', presence)

View file

@ -0,0 +1,37 @@
"""
Slixmpp: The Slick XMPP Library
Copyright (C) 2020 Mathieu Pasquet <mathieui@mathieui.net>
This file is part of Slixmpp.
See the file LICENSE for copying permissio
"""
from xml.etree import ElementTree as ET
from slixmpp import JID
from slixmpp.stanza import Presence
from slixmpp.xmlstream import (
register_stanza_plugin,
ElementBase,
)
from slixmpp.plugins.xep_0060.stanza import (
Item,
EventItem,
)
NS = 'urn:xmpp:mix:presence:0'
class MIXPresence(ElementBase):
namespace = NS
name = 'mix'
plugin_attrib = 'mix'
interfaces = {'jid', 'nick'}
sub_interfaces = {'jid', 'nick'}
def register_plugins():
register_stanza_plugin(Presence, MIXPresence)
register_stanza_plugin(Item, Presence)
register_stanza_plugin(EventItem, Presence)