Stop using deprecated aliases from slixmpp.
This commit is contained in:
parent
f252f66b50
commit
5a5c1fe992
6 changed files with 21 additions and 20 deletions
|
@ -249,14 +249,15 @@ def find_delayed_tag(message):
|
|||
:rtype: :py:class:`tuple`
|
||||
"""
|
||||
|
||||
delay_tag = message.find('{urn:xmpp:delay}delay')
|
||||
find_delay = message.xml.find
|
||||
delay_tag = find_delay('{urn:xmpp:delay}delay')
|
||||
if delay_tag is not None:
|
||||
delayed = True
|
||||
date = _datetime_tuple(delay_tag.attrib['stamp'])
|
||||
else:
|
||||
# We support the OLD and deprecated XEP: http://xmpp.org/extensions/xep-0091.html
|
||||
# But it sucks, please, Jabber servers, don't do this :(
|
||||
delay_tag = message.find('{jabber:x:delay}x')
|
||||
delay_tag = find_delay('{jabber:x:delay}x')
|
||||
if delay_tag is not None:
|
||||
delayed = True
|
||||
date = _datetime_tuple(delay_tag.attrib['stamp'])
|
||||
|
|
|
@ -928,7 +928,7 @@ class Core(object):
|
|||
Takes a stanza of the form <message type='error'><error/></message>
|
||||
and return a well formed string containing the error informations
|
||||
"""
|
||||
sender = stanza.attrib['from']
|
||||
sender = stanza['from']
|
||||
msg = stanza['error']['type']
|
||||
condition = stanza['error']['condition']
|
||||
code = stanza['error']['code']
|
||||
|
|
|
@ -146,7 +146,7 @@ class HandlerCore:
|
|||
if jid.bare in self.core.pending_invites:
|
||||
return
|
||||
# there are 2 'x' tags in the messages, making message['x'] useless
|
||||
invite = StanzaBase(self.core.xmpp, xml=message.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite'))
|
||||
invite = StanzaBase(self.core.xmpp, xml=message.xml.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite'))
|
||||
inviter = invite['from']
|
||||
reason = invite['reason']
|
||||
password = invite['password']
|
||||
|
@ -200,7 +200,7 @@ class HandlerCore:
|
|||
When receiving private message from a muc OR a normal message
|
||||
(from one of our contacts)
|
||||
"""
|
||||
if message.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite') != None:
|
||||
if message.xml.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite') != None:
|
||||
return
|
||||
if message['type'] == 'groupchat':
|
||||
return
|
||||
|
@ -1025,7 +1025,7 @@ class HandlerCore:
|
|||
"""
|
||||
room_from = message['from']
|
||||
tab = self.core.get_tab_by_name(room_from, tabs.MucTab)
|
||||
status_codes = set([s.attrib['code'] for s in message.findall('{%s}x/{%s}status' % (tabs.NS_MUC_USER, tabs.NS_MUC_USER))])
|
||||
status_codes = {s.attrib['code'] for s in message.xml.findall('{%s}x/{%s}status' % (tabs.NS_MUC_USER, tabs.NS_MUC_USER))}
|
||||
if '101' in status_codes:
|
||||
self.core.information('Your affiliation in the room %s changed' % room_from, 'Info')
|
||||
elif tab and status_codes:
|
||||
|
@ -1312,7 +1312,7 @@ class HandlerCore:
|
|||
status = iq['command']['status']
|
||||
xform = iq.xml.find('{http://jabber.org/protocol/commands}command/{jabber:x:data}x')
|
||||
if xform is not None:
|
||||
form = self.core.xmpp.plugin['xep_0004'].buildForm(xform)
|
||||
form = self.core.xmpp.plugin['xep_0004'].build_form(xform)
|
||||
else:
|
||||
form = None
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ def get_room_form(xmpp, room, callback):
|
|||
xform = result.xml.find('{http://jabber.org/protocol/muc#owner}query/{jabber:x:data}x')
|
||||
if xform is None:
|
||||
return callback(None)
|
||||
form = xmpp.plugin['xep_0004'].buildForm(xform)
|
||||
form = xmpp.plugin['xep_0004'].build_form(xform)
|
||||
return callback(form)
|
||||
|
||||
iq = xmpp.make_iq_get(ito=room)
|
||||
|
|
|
@ -189,7 +189,7 @@ def configure_room(xmpp, room, form):
|
|||
iq = xmpp.make_iq_set()
|
||||
iq['to'] = room
|
||||
query = ET.Element('{http://jabber.org/protocol/muc#owner}query')
|
||||
form = form.getXML('submit')
|
||||
form['type'] = 'submit'
|
||||
query.append(form)
|
||||
iq.append(query)
|
||||
iq.send()
|
||||
|
|
|
@ -1085,7 +1085,7 @@ class MucTab(ChatTab):
|
|||
from_room = presence['from'].bare
|
||||
xpath = '{%s}x/{%s}status' % (NS_MUC_USER, NS_MUC_USER)
|
||||
status_codes = set()
|
||||
for status_code in presence.findall(xpath):
|
||||
for status_code in presence.xml.findall(xpath):
|
||||
status_codes.add(status_code.attrib['code'])
|
||||
|
||||
# Check if it's not an error presence.
|
||||
|
@ -1280,8 +1280,8 @@ class MucTab(ChatTab):
|
|||
self.core.on_user_rejoined_private_conversation(self.name, from_nick)
|
||||
|
||||
def on_user_nick_change(self, presence, user, from_nick, from_room):
|
||||
new_nick = presence.find('{%s}x/{%s}item' % (NS_MUC_USER, NS_MUC_USER)
|
||||
).attrib['nick']
|
||||
new_nick = presence.xml.find('{%s}x/{%s}item' % (NS_MUC_USER, NS_MUC_USER)
|
||||
).attrib['nick']
|
||||
if user.nick == self.own_nick:
|
||||
self.own_nick = new_nick
|
||||
# also change our nick in all private discussions of this room
|
||||
|
@ -1315,10 +1315,10 @@ class MucTab(ChatTab):
|
|||
When someone is banned from a muc
|
||||
"""
|
||||
self.users.remove(user)
|
||||
by = presence.find('{%s}x/{%s}item/{%s}actor' %
|
||||
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
|
||||
reason = presence.find('{%s}x/{%s}item/{%s}reason' %
|
||||
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
|
||||
by = presence.xml.find('{%s}x/{%s}item/{%s}actor' %
|
||||
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
|
||||
reason = presence.xml.find('{%s}x/{%s}item/{%s}reason' %
|
||||
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
|
||||
by = by.attrib['jid'] if by is not None else None
|
||||
|
||||
info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
|
||||
|
@ -1383,10 +1383,10 @@ class MucTab(ChatTab):
|
|||
When someone is kicked from a muc
|
||||
"""
|
||||
self.users.remove(user)
|
||||
actor_elem = presence.find('{%s}x/{%s}item/{%s}actor' %
|
||||
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
|
||||
reason = presence.find('{%s}x/{%s}item/{%s}reason' %
|
||||
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
|
||||
actor_elem = presence.xml.find('{%s}x/{%s}item/{%s}actor' %
|
||||
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
|
||||
reason = presence.xml.find('{%s}x/{%s}item/{%s}reason' %
|
||||
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
|
||||
by = None
|
||||
info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
|
||||
char_kick = get_theme().CHAR_KICK
|
||||
|
|
Loading…
Reference in a new issue