I am new to Pyrogram and I try to make subsctiption bot
I want to send messages as soon as any satisfy my filters, but every time I send more than 3 messages in a row I get FloodWait error. There is no problem in catching that exception, but it is always getting bigger
15 -> 60 -> 333 -> 417 seconds
How can I avoid it? Sleeping for some seconds after every message doesn't help. And I didn't find anything about exact estimated waiting time in docs
for user in subs_arr:
try:
app.send_message(user, msg)
time.sleep(10)
except pyrogram.errors.exceptions.flood_420.FloodWait as wait_err:
wait_err = str(wait_err)
time.sleep(wait_err.x)
After some research I found that there is no way to avoid FloodWait :D
But I had totally wrong understanding of time.sleep. I used Pyrogram for that bot, bot I didn't need async component of that Nevertheless bot requires asynchronous sleep and I had problems with reworking it this way. Finally I came up with that solution (now sleep usually is <=60 second)
try:
await app.send_message(user, msg)
await asyncio.sleep(3)
except pyrogram.errors.exceptions.flood_420.FloodWait as wait_err:
await asyncio.sleep(wait_err.x)
except TimeoutError:
continue
except pyrogram.errors.exceptions.bad_request_400.UsernameNotOccupied:
continue
Hope it'll help somebody or even somebody will advice me better way of doing this