30 lines
851 B
Python
30 lines
851 B
Python
|
#!/usr/bin/python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
from asyncio import TimeoutError
|
||
|
from slixmpp.exceptions import IqError, IqTimeout, PresenceError
|
||
|
|
||
|
class XmppXep0054:
|
||
|
|
||
|
async def get_vcard_data(self, jid_bare):
|
||
|
try:
|
||
|
error = False
|
||
|
condition = text = ''
|
||
|
iq = await self['xep_0054'].get_vcard(jid_bare)
|
||
|
except (IqError, IqTimeout) as e:
|
||
|
error = True
|
||
|
condition = e.iq['error']['condition']
|
||
|
text = e.iq['error']['text']
|
||
|
if not text:
|
||
|
if condition:
|
||
|
text = 'Could not retrieve vCard'
|
||
|
else:
|
||
|
text = 'Unknown Error'
|
||
|
iq = ''
|
||
|
result = {
|
||
|
'error' : error,
|
||
|
'condition' : condition,
|
||
|
'text' : text,
|
||
|
'iq' : iq}
|
||
|
return result
|