From 3b3eed544ef9a37b0a4036299f7fdc230733dc0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Fri, 29 May 2020 17:27:51 +0200 Subject: XEP-0045: Add stanza.NS* consts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- slixmpp/plugins/xep_0045/stanza.py | 15 ++++++++++----- 1 file 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] -- cgit v1.2.3