Add support for XEP0402 (PEP Native bookmarks)

This commit is contained in:
Nicolas Cedilnik 2023-04-03 05:47:46 +02:00
parent bc2cebae6c
commit 8f77bd4ee5
4 changed files with 51 additions and 0 deletions

View file

@ -102,6 +102,7 @@ PLUGINS = [
'xep_0380', # Explicit Message Encryption
'xep_0382', # Spoiler Messages
'xep_0394', # Message Markup
'xep_0402', # PEP Native Bookmarks
'xep_0403', # MIX-Presence
'xep_0404', # MIX-Anon
'xep_0405', # MIX-PAM

View file

@ -0,0 +1,6 @@
from slixmpp.plugins.base import register_plugin
from . import stanza
from .bookmarks import XEP_0402
register_plugin(XEP_0402)

View file

@ -0,0 +1,18 @@
from slixmpp.plugins import BasePlugin
from . import stanza
class XEP_0402(BasePlugin):
"""
XEP-0402: PEP Native bookmarks
"""
name = "xep_0402"
description = "XEP-0402: PEP Native bookmarks"
dependencies = {"xep_0402"}
stanza = stanza
def plugin_init(self):
stanza.register_plugin()

View file

@ -0,0 +1,26 @@
from slixmpp import register_stanza_plugin
from slixmpp.plugins.xep_0060.stanza import Item
from slixmpp.xmlstream import ElementBase
NS = "urn:xmpp:bookmarks:1"
class Conference(ElementBase):
namespace = NS
name = "conference"
plugin_attrib = "conference"
interfaces = {"name", "autojoin", "nick"}
sub_interfaces = {"nick"}
def set_autojoin(self, v: bool):
self._set_attr('autojoin', "true" if v else "false")
def get_autojoin(self):
v = self._get_attr('autojoin', '')
if not v:
return False
return v == "1" or v.lower() == "true"
def register_plugin():
register_stanza_plugin(Item, Conference)