f65be8b5c8
Add http proxy support. Add more functionality to handle bookmarks. Split into more modules. Remove callback function initdb. Tasked status messages are broken.
43 lines
No EOL
1.2 KiB
Python
43 lines
No EOL
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from slixfeed.datetime import current_time
|
|
from slixmpp.exceptions import IqTimeout
|
|
import logging
|
|
|
|
async def jid_type(self, jid):
|
|
"""
|
|
Check whether a JID is of MUC.
|
|
|
|
Parameters
|
|
----------
|
|
jid : str
|
|
Jabber ID.
|
|
|
|
Returns
|
|
-------
|
|
str
|
|
"chat" or "groupchat.
|
|
"""
|
|
try:
|
|
iqresult = await self["xep_0030"].get_info(jid=jid)
|
|
features = iqresult["disco_info"]["features"]
|
|
# identity = iqresult['disco_info']['identities']
|
|
# if 'account' in indentity:
|
|
# if 'conference' in indentity:
|
|
if 'http://jabber.org/protocol/muc' in features:
|
|
return "groupchat"
|
|
# TODO elif <feature var='jabber:iq:gateway'/>
|
|
# NOTE Is it needed? We do not interact with gateways or services
|
|
else:
|
|
return "chat"
|
|
# TODO Test whether this exception is realized
|
|
except IqTimeout as e:
|
|
messages = [
|
|
("Timeout IQ"),
|
|
("IQ Stanza:", e),
|
|
("Jabber ID:", jid)
|
|
]
|
|
for message in messages:
|
|
print(current_time(), message)
|
|
logging.error(current_time(), message) |