Process self-produced updates like any other

This commit is contained in:
Lonami Exo 2022-01-23 13:20:35 +01:00
parent 1f40372235
commit f1a517dee6
2 changed files with 17 additions and 0 deletions

View File

@ -771,3 +771,5 @@ sequential_updates is gone
connection type is gone
raise_last_call_error is now the default rather than ValueError
self-produced updates like getmessage now also trigger a handler

View File

@ -603,6 +603,7 @@ class MTProtoSender:
if not state.future.cancelled():
state.future.set_exception(e)
else:
self._store_own_updates(result)
if not state.future.cancelled():
state.future.set_result(result)
@ -646,6 +647,20 @@ class MTProtoSender:
)
self._last_update_warn = now
def _store_own_updates(self, obj, *, _update_ids=frozenset((
_tl.UpdateShortMessage.CONSTRUCTOR_ID,
_tl.UpdateShortChatMessage.CONSTRUCTOR_ID,
_tl.UpdateShort.CONSTRUCTOR_ID,
_tl.UpdatesCombined.CONSTRUCTOR_ID,
_tl.Updates.CONSTRUCTOR_ID,
_tl.UpdateShortSentMessage.CONSTRUCTOR_ID,
))):
try:
if obj.CONSTRUCTOR_ID in _update_ids:
self._updates_queue.put_nowait(obj)
except AttributeError:
pass
async def _handle_pong(self, message):
"""
Handles pong results, which don't come inside a ``rpc_result``