Skip to content

Commit

Permalink
pyrofork: Add recover_gaps parameter to client
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
user authored and wulan17 committed May 30, 2024
1 parent 6757a23 commit 1548bb7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pyrogram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ class Client(Methods):
Set the maximum amount of concurrent transmissions (uploads & downloads).
A value that is too high may result in network related issues.
Defaults to 1.
recover_gaps (``bool``, *optional*):
Pass True to fetching updates that arrived while the client was offline.
Defaults to False.
"""

APP_VERSION = f"Pyrogram {__version__}"
Expand Down Expand Up @@ -247,7 +251,8 @@ def __init__(
takeout: bool = None,
sleep_threshold: int = Session.SLEEP_THRESHOLD,
hide_password: bool = False,
max_concurrent_transmissions: int = MAX_CONCURRENT_TRANSMISSIONS
max_concurrent_transmissions: int = MAX_CONCURRENT_TRANSMISSIONS,
recover_gaps: bool = False
):
super().__init__()

Expand Down Expand Up @@ -278,6 +283,7 @@ def __init__(
self.sleep_threshold = sleep_threshold
self.hide_password = hide_password
self.max_concurrent_transmissions = max_concurrent_transmissions
self.recover_gaps = recover_gaps

self.executor = ThreadPoolExecutor(self.workers, thread_name_prefix="Handler")

Expand Down Expand Up @@ -653,7 +659,7 @@ async def handle_updates(self, updates):
else:
if diff.other_updates: # The other_updates list can be empty
self.dispatcher.updates_queue.put_nowait((diff.other_updates[0], {}, {}))
elif isinstance(updates, raw.types.updates.State):
elif isinstance(updates, raw.types.updates.State) and self.recover_gaps:
local_pts = await self.storage.pts()
date = await self.storage.date()

Expand Down

0 comments on commit 1548bb7

Please sign in to comment.