diff --git a/slixmpp/plugins/__init__.py b/slixmpp/plugins/__init__.py index 206ac5a7..8c220242 100644 --- a/slixmpp/plugins/__init__.py +++ b/slixmpp/plugins/__init__.py @@ -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 diff --git a/slixmpp/plugins/xep_0402/__init__.py b/slixmpp/plugins/xep_0402/__init__.py new file mode 100644 index 00000000..e698cb92 --- /dev/null +++ b/slixmpp/plugins/xep_0402/__init__.py @@ -0,0 +1,6 @@ +from slixmpp.plugins.base import register_plugin + +from . import stanza +from .bookmarks import XEP_0402 + +register_plugin(XEP_0402) diff --git a/slixmpp/plugins/xep_0402/bookmarks.py b/slixmpp/plugins/xep_0402/bookmarks.py new file mode 100644 index 00000000..6635d365 --- /dev/null +++ b/slixmpp/plugins/xep_0402/bookmarks.py @@ -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() diff --git a/slixmpp/plugins/xep_0402/stanza.py b/slixmpp/plugins/xep_0402/stanza.py new file mode 100644 index 00000000..896ff863 --- /dev/null +++ b/slixmpp/plugins/xep_0402/stanza.py @@ -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)