summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-12-02 19:36:20 +0100
committermathieui <mathieui@mathieui.net>2020-12-04 19:13:55 +0100
commit58c3579f74e2827c0be973cac9b0a0ae9a606a1e (patch)
treef7b665ca9293459168d66ea8e4d2373b06fb38d5
parente592a46c99888594bfb0bf71da99c88755912a37 (diff)
downloadslixmpp-58c3579f74e2827c0be973cac9b0a0ae9a606a1e.tar.gz
slixmpp-58c3579f74e2827c0be973cac9b0a0ae9a606a1e.tar.bz2
slixmpp-58c3579f74e2827c0be973cac9b0a0ae9a606a1e.tar.xz
slixmpp-58c3579f74e2827c0be973cac9b0a0ae9a606a1e.zip
XEP-0422: Message Fastening
-rw-r--r--slixmpp/plugins/__init__.py1
-rw-r--r--slixmpp/plugins/xep_0422/__init__.py13
-rw-r--r--slixmpp/plugins/xep_0422/fastening.py28
-rw-r--r--slixmpp/plugins/xep_0422/stanza.py42
4 files changed, 84 insertions, 0 deletions
diff --git a/slixmpp/plugins/__init__.py b/slixmpp/plugins/__init__.py
index f948ead6..dce69083 100644
--- a/slixmpp/plugins/__init__.py
+++ b/slixmpp/plugins/__init__.py
@@ -93,5 +93,6 @@ __all__ = [
'xep_0404', # MIX-Anon
'xep_0405', # MIX-PAM
'xep_0421', # Anonymous unique occupant identifiers for MUCs
+ 'xep_0422', # Message Fastening
'xep_0444', # Message Reactions
]
diff --git a/slixmpp/plugins/xep_0422/__init__.py b/slixmpp/plugins/xep_0422/__init__.py
new file mode 100644
index 00000000..9a1575c1
--- /dev/null
+++ b/slixmpp/plugins/xep_0422/__init__.py
@@ -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_0422.stanza import *
+from slixmpp.plugins.xep_0422.fastening import XEP_0422
+
+register_plugin(XEP_0422)
diff --git a/slixmpp/plugins/xep_0422/fastening.py b/slixmpp/plugins/xep_0422/fastening.py
new file mode 100644
index 00000000..68560e16
--- /dev/null
+++ b/slixmpp/plugins/xep_0422/fastening.py
@@ -0,0 +1,28 @@
+"""
+ 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 import BasePlugin
+from slixmpp.plugins.xep_0422 import stanza
+
+
+class XEP_0422(BasePlugin):
+ '''XEP-0422: Message Fastening'''
+
+ name = 'xep_0422'
+ description = 'Message Fastening'
+ dependencies = {'xep_0030'}
+ stanza = stanza
+ namespace = stanza.NS
+
+ def plugin_init(self) -> None:
+ stanza.register_plugins()
+
+ def session_bind(self, jid):
+ self.xmpp.plugin['xep_0030'].add_feature(feature=stanza.NS)
+
+ def plugin_end(self):
+ self.xmpp.plugin['xep_0030'].del_feature(feature=stanza.NS)
diff --git a/slixmpp/plugins/xep_0422/stanza.py b/slixmpp/plugins/xep_0422/stanza.py
new file mode 100644
index 00000000..a739809e
--- /dev/null
+++ b/slixmpp/plugins/xep_0422/stanza.py
@@ -0,0 +1,42 @@
+"""
+ 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 slixmpp.stanza import Message
+from slixmpp.xmlstream import (
+ ElementBase,
+ register_stanza_plugin,
+)
+
+
+NS = 'urn:xmpp:fasten:0'
+
+
+class ApplyTo(ElementBase):
+ namespace = NS
+ name = 'apply-to'
+ plugin_attrib = 'apply_to'
+ interfaces = {'id', 'shell'}
+
+ def set_shell(self, value: bool):
+ if value:
+ self.xml.attrib['shell'] = str(value).lower()
+ else:
+ if 'shell' in self.xml.attrib:
+ del self.xml.attrib['shell']
+
+
+class External(ElementBase):
+ namespace = NS
+ name = 'external'
+ plugin_attrib = 'external'
+ interfaces = {'name'}
+
+
+def register_plugins():
+ register_stanza_plugin(Message, ApplyTo)
+ register_stanza_plugin(ApplyTo, External)