Add file PyProject;
Support display of a single pubsub node item; Update document README; Modularize code;
This commit is contained in:
parent
37aa7e8f40
commit
5e495579c2
32 changed files with 2431 additions and 2059 deletions
58
jabbercard/xmpp/xep_0045.py
Normal file
58
jabbercard/xmpp/xep_0045.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from asyncio import TimeoutError
|
||||
from datetime import datetime
|
||||
from slixmpp.exceptions import IqError, IqTimeout, PresenceError
|
||||
|
||||
class XmppXep0045:
|
||||
|
||||
async def get_room_information(self, jid, alias, maxchars=None, maxstanzas=None, seconds=None):
|
||||
#logger.info('Joining groupchat\nJID : {}\n'.format(jid))
|
||||
#jid_from = str(self.boundjid) if self.is_component else None
|
||||
if not maxchars: maxchars = 1000
|
||||
if not maxstanzas: maxstanzas = 50
|
||||
if not seconds: seconds = 864000
|
||||
try:
|
||||
error = False
|
||||
condition = text = ''
|
||||
#since = datetime.fromtimestamp(time.time()-seconds)
|
||||
iq = await self['xep_0045'].join_muc_wait(
|
||||
jid,
|
||||
alias,
|
||||
#maxchars=maxchars,
|
||||
maxstanzas=maxstanzas,
|
||||
#password=None,
|
||||
#presence_options = {"pfrom" : jid_from},
|
||||
#seconds=seconds,
|
||||
#since=since,
|
||||
timeout=10
|
||||
)
|
||||
except TimeoutError as e:
|
||||
#raise HTTPException(status_code=504, detail='request-timeout-reached')
|
||||
error = True
|
||||
iq = e
|
||||
condition = 'Request timeout reached'
|
||||
text = str(e)
|
||||
except (IqError, IqTimeout, PresenceError) as e:
|
||||
error = True
|
||||
iq = e
|
||||
condition = e.iq['error']['condition']
|
||||
text = e.iq['error']['text']
|
||||
result = {
|
||||
'error' : error,
|
||||
'condition' : condition,
|
||||
'text' : text,
|
||||
'iq' : iq}
|
||||
return result
|
||||
|
||||
async def get_room_data(self, jid_bare):
|
||||
return await self['xep_0045'].get_room_config(jid_bare)
|
||||
|
||||
async def get_room_participants(self, jid_bare):
|
||||
return await self['xep_0045'].get_roster(jid_bare)
|
||||
|
||||
|
||||
# NOTE: "Item not found", yet is a group chat
|
||||
# That is, JID has no vcard
|
||||
# messaging-off@conference.movim.eu
|
Loading…
Add table
Add a link
Reference in a new issue