Search code examples
pyrogram

Flood not handled in Pyrogram


I'm using a function to handle progress for sending video, that edit message like loader to show download remaining so when file size is large I faced with flood exception

await app.send_video(
   chat_id=message.chat.id,
   video=file_location,
   progress=send_media_progress,
   progress_args=[client, message.chat.id, loader_message.message_id] )

send video by above code

async def send_media_progress(current, total, *args):
client, chat_id, message_id = args[0], args[1], args[2]
if f"{current * 100 / total:.1f}" == "100.0":
    await client.edit_message_text(
        chat_id=chat_id,
        message_id=message_id,
        text="sending..."
    )
    return
await client.edit_message_text(
    chat_id=chat_id,
    message_id=message_id,
    text=f"upload: {current * 100 / total:.1f}%"
)

and handle progress by this method, I put both codes into 'try except' but it doesn't solve my problem

how can solve it? any idea?


Solution

  • Solved by putting progress code to try except FloodWait and async sleep by e.x