diff options
Diffstat (limited to 'slixmpp/plugins/xep_0335/stanza.py')
-rw-r--r-- | slixmpp/plugins/xep_0335/stanza.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/slixmpp/plugins/xep_0335/stanza.py b/slixmpp/plugins/xep_0335/stanza.py new file mode 100644 index 00000000..6d5ca5b5 --- /dev/null +++ b/slixmpp/plugins/xep_0335/stanza.py @@ -0,0 +1,28 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2018 Maxime “pep” Buquet + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +import json +from slixmpp.xmlstream import ElementBase + + +class JSON_Container(ElementBase): + name = 'json' + plugin_attrib = 'json' + namespace = 'urn:xmpp:json:0' + interfaces = {'value'} + + def get_value(self): + return json.loads(self.xml.text) + + def set_value(self, value): + if not isinstance(value, str): + value = json.dumps(value) + self.xml.text = value + + def del_value(self): + self.xml.text = '' |