diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2020-05-29 17:27:51 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2020-05-29 17:27:51 +0200 |
commit | 3b3eed544ef9a37b0a4036299f7fdc230733dc0b (patch) | |
tree | 8d0cfcb2dab9e375e68cb6fd7f7987ad676ee94c | |
parent | 03ee9bc4cc8d9ed92cd9c70fa6227d4c0355da73 (diff) | |
download | slixmpp-3b3eed544ef9a37b0a4036299f7fdc230733dc0b.tar.gz slixmpp-3b3eed544ef9a37b0a4036299f7fdc230733dc0b.tar.bz2 slixmpp-3b3eed544ef9a37b0a4036299f7fdc230733dc0b.tar.xz slixmpp-3b3eed544ef9a37b0a4036299f7fdc230733dc0b.zip |
XEP-0045: Add stanza.NS* consts
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r-- | slixmpp/plugins/xep_0045/stanza.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/slixmpp/plugins/xep_0045/stanza.py b/slixmpp/plugins/xep_0045/stanza.py index 265be83a..7d52f53a 100644 --- a/slixmpp/plugins/xep_0045/stanza.py +++ b/slixmpp/plugins/xep_0045/stanza.py @@ -13,31 +13,36 @@ from slixmpp.xmlstream import ElementBase, ET, JID log = logging.getLogger(__name__) +NS = 'http://jabber.org/protocol/muc' +NS_USER = 'http://jabber.org/protocol/muc#user' +NS_ADMIN = 'http://jabber.org/protocol/muc#admin' +NS_OWNER = 'http://jabber.org/protocol/muc#owner' + class MUCPresence(ElementBase): name = 'x' - namespace = 'http://jabber.org/protocol/muc#user' + namespace = NS_USER plugin_attrib = 'muc' interfaces = {'affiliation', 'role', 'jid', 'nick', 'room'} affiliations = {'', } roles = {'', } def get_item_attr(self, attr, default): - item = self.xml.find('{http://jabber.org/protocol/muc#user}item') + item = self.xml.find('{{{NS_USER}}}item') if item is None: return default return item.get(attr) def set_item_attr(self, attr, value): - item = self.xml.find('{http://jabber.org/protocol/muc#user}item') + item = self.xml.find(f'{{{NS_USER}}}item') if item is None: - item = ET.Element('{http://jabber.org/protocol/muc#user}item') + item = ET.Element(f'{{{NS_USER}}}item') self.xml.append(item) item.attrib[attr] = value return item def del_item_attr(self, attr): - item = self.xml.find('{http://jabber.org/protocol/muc#user}item') + item = self.xml.find('{{{NS_USER}}}item') if item is not None and attr in item.attrib: del item.attrib[attr] |