-2

I have made a telegram bot using pyrogram to upload a large video and the the progress bar is shown, however the progress bar is repeatedly edited message with new values.

This error message is shown frequently:

Waiting for 3 seconds before continuing (required by "messages.EditMessage")

I am trying to skip this error by try except block

try:
    await msg.edit(text=current_message)
except:
    pass

but this is not working, the error message still shows up!

What to do?

petezurich
  • 9,280
  • 9
  • 43
  • 57
ADITYA DAS
  • 340
  • 2
  • 6

1 Answers1

0

The error message you get is Pyrogram handling the FloodWait error from Telegram itself. You can set the sleep_threshold when defining Client() to 0, so you get the actual error you can except yourself. Pyrogram will automatically re-try, whereas you would have to re-implement that again, if you don't want something to go missing in-between.

Alternatively, don't update your Progress Bar as quickly, and increase your increment size. Instead of updating on every single 1% progress, do something like

if progress % 5 == 0:
    msg.edit("Progress: {}", format=progress)

This if statement calculates the modulo of your progress, and only updates when it is cleanly divisible by 5. The % operator returns the remainder when dividing your progress.

Also; Pyrograms Documentation about Errors: https://docs.pyrogram.org/api/errors/

ColinShark
  • 1,047
  • 2
  • 10
  • 18