fix(userbot): drop stale media sessions and survive download timeouts

This commit is contained in:
hh committed 2026-09-01 21:05:48 +02:00
1 parent cf277c56cf
commit 9c12628304
6 files changed
+83 -24

No files matched your search

@@ -1,9 +1,8 @@
from io import BytesIO
from pyrogram import Client
from pyrogram.types import Story
from userbot.modules.capture.context import CaptureContext
from userbot.modules.download import download_bytes
from userbot.modules.stories import repository
@@ -24,9 +23,8 @@ async def save_story(client: Client, capture: CaptureContext, story: Story) -> N
capture.pool, capture.account_id, peer_id, story.id
)
if not (stored or story.deleted or story.media is None):
buffer = await client.download_media(story, in_memory=True)
if isinstance(buffer, BytesIO):
data = buffer.getvalue()
data = await download_bytes(client, story)
if data is not None:
storage_key = capture.storage.put(data)
file_size = len(data)
downloaded = True