[SVN] all comments in code now in English; Sofia ♥ Fuck you with this barbarian language in code comments! (no, no fuck please) [FIX] monkey-patched telethon library to fix updates receiving in some sessions (fix github issue #686; commit b20aa0ccc91b3d767c26702f3611c44772d87f5a) [FIX] fixed "normal" quotation, such as `> text`, in previous releases it was intended to be message id to reply [FIX] now processing bots in contact list, in roster with `b` prefix [FIX] fixed message editing and deleting in supergroups [FIX] now removing old telegram session from database when initiating a new one for current JID [FIX] fixed group creating; group, supergroup, channels creating is now OK and tested [FIX] fixed processing bot in roster; now it does not crashes gateway [UPD] default status update interval is now 30 [UPD] slighly (and finally) changed behaviour of presences: `Last seen recently` = `dnd (do not disturb)`, because user that enabled this privacy settings does not want you to disturb `Last seen a long time ago` = `xa (extended away)`, because it is 'long' away 'Last seen at %date%` = `away`, because user just got away [ADD] basic interaction with bots (now only with text commands)
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
from sleekxmpp.plugins.xep_0054 import XEP_0054
|
|
from sleekxmpp import Iq
|
|
from sleekxmpp.exceptions import XMPPError
|
|
|
|
from telethon.update_state import UpdateState
|
|
|
|
def patched_handle_get_vcard(self, iq):
|
|
if iq['type'] == 'result':
|
|
self.api['set_vcard'](jid=iq['from'], args=iq['vcard_temp'])
|
|
return
|
|
elif iq['type'] == 'get':
|
|
vcard = self.api['get_vcard'](iq['to'].bare)
|
|
if isinstance(vcard, Iq):
|
|
vcard.send()
|
|
else:
|
|
iq = iq.reply()
|
|
iq.append(vcard)
|
|
iq.send()
|
|
elif iq['type'] == 'set':
|
|
raise XMPPError('service-unavailable')
|
|
|
|
def patched_stop_workers(self):
|
|
"""
|
|
Waits for all the worker threads to stop.
|
|
"""
|
|
# Put dummy ``None`` objects so that they don't need to timeout.
|
|
n = self._workers
|
|
self._workers = None
|
|
if n:
|
|
with self._updates_lock:
|
|
for _ in range(n):
|
|
self._updates.put(None)
|
|
|
|
for t in self._worker_threads:
|
|
t.join()
|
|
|
|
self._worker_threads.clear()
|
|
self._workers = n
|
|
|
|
|
|
# hey i'm baboon
|
|
XEP_0054._handle_get_vcard = patched_handle_get_vcard
|
|
UpdateState.stop_workers = patched_stop_workers
|