mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-22 13:06:37 +00:00
Fix catch_up pts loading and remember pts per update
This commit is contained in:
parent
73742633bd
commit
fadc343821
@ -139,7 +139,7 @@ class UpdateMethods(UserMethods):
|
|||||||
if all(self._new_pts_date):
|
if all(self._new_pts_date):
|
||||||
pts, date = self._new_pts_date
|
pts, date = self._new_pts_date
|
||||||
elif all(self._old_pts_date):
|
elif all(self._old_pts_date):
|
||||||
pts, date = self._new_pts_date
|
pts, date = self._old_pts_date
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -223,6 +223,7 @@ class UpdateMethods(UserMethods):
|
|||||||
self._update_pts_date(update)
|
self._update_pts_date(update)
|
||||||
|
|
||||||
def _process_update(self, update, entities=None):
|
def _process_update(self, update, entities=None):
|
||||||
|
update._pts_date = self._new_pts_date
|
||||||
update._entities = entities or {}
|
update._entities = entities or {}
|
||||||
if self._updates_queue is None:
|
if self._updates_queue is None:
|
||||||
self._loop.create_task(self._dispatch_update(update))
|
self._loop.create_task(self._dispatch_update(update))
|
||||||
@ -413,16 +414,14 @@ class EventBuilderDict:
|
|||||||
Calls :tl:`updates.getDifference`, which fills the entities cache
|
Calls :tl:`updates.getDifference`, which fills the entities cache
|
||||||
(always done by `__call__`) and lets us know about the full entities.
|
(always done by `__call__`) and lets us know about the full entities.
|
||||||
"""
|
"""
|
||||||
pts = getattr(self.update, 'pts', None)
|
# Fetch since the last known pts/date before this update arrived,
|
||||||
|
# in order to fetch this update at full.
|
||||||
|
pts, date = self.update._pts_date
|
||||||
if not pts:
|
if not pts:
|
||||||
return
|
return
|
||||||
|
|
||||||
date = getattr(self.update, 'date', None)
|
|
||||||
if date:
|
|
||||||
# Get the difference from one second ago to now
|
|
||||||
date -= datetime.timedelta(seconds=1)
|
|
||||||
else:
|
|
||||||
# No date known, 1 is the earliest date that works
|
# No date known, 1 is the earliest date that works
|
||||||
|
if not date:
|
||||||
date = 1
|
date = 1
|
||||||
|
|
||||||
self.client._log[__name__].debug('Getting difference for entities')
|
self.client._log[__name__].debug('Getting difference for entities')
|
||||||
|
Loading…
Reference in New Issue
Block a user