Handle FloodPremiumWait error

Closes KurimuzonAkuma/pyrogram#64
This commit is contained in:
KurimuzonAkuma 2024-05-24 13:18:36 +03:00
parent 823192a393
commit 0d2bd64871
3 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,6 @@
id message
2FA_CONFIRM_WAIT_X A wait of {value} seconds is required because this account is active and protected by a 2FA password
FLOOD_PREMIUM_WAIT_X A wait of {value} seconds is required
FLOOD_TEST_PHONE_WAIT_X A wait of {value} seconds is required in the test servers
FLOOD_WAIT_X A wait of {value} seconds is required
PREMIUM_SUB_ACTIVE_UNTIL_X A wait of {value} seconds is required

1 id message
2 2FA_CONFIRM_WAIT_X A wait of {value} seconds is required because this account is active and protected by a 2FA password
3 FLOOD_PREMIUM_WAIT_X A wait of {value} seconds is required
4 FLOOD_TEST_PHONE_WAIT_X A wait of {value} seconds is required in the test servers
5 FLOOD_WAIT_X A wait of {value} seconds is required
6 PREMIUM_SUB_ACTIVE_UNTIL_X A wait of {value} seconds is required

View File

@ -44,7 +44,8 @@ from pyrogram.errors import CDNFileHashMismatch
from pyrogram.errors import (
SessionPasswordNeeded,
VolumeLocNotFound, ChannelPrivate,
BadRequest, AuthBytesInvalid
BadRequest, AuthBytesInvalid,
FloodWait, FloodPremiumWait
)
from pyrogram.handlers.handler import Handler
from pyrogram.methods import Methods
@ -863,7 +864,7 @@ class Client(Methods):
if isinstance(e, asyncio.CancelledError):
raise e
if isinstance(e, pyrogram.errors.FloodWait):
if isinstance(e, (FloodWait, FloodPremiumWait)):
raise e
return None
@ -1097,7 +1098,7 @@ class Client(Methods):
await cdn_session.stop()
except pyrogram.StopTransmission:
raise
except pyrogram.errors.FloodWait:
except (FloodWait, FloodPremiumWait):
raise
except Exception as e:
log.exception(e)

View File

@ -28,7 +28,7 @@ from pyrogram import raw
from pyrogram.connection import Connection
from pyrogram.crypto import mtproto
from pyrogram.errors import (
RPCError, InternalServerError, AuthKeyDuplicated, FloodWait, ServiceUnavailable, BadMsgNotification,
RPCError, InternalServerError, AuthKeyDuplicated, FloodWait, FloodPremiumWait, ServiceUnavailable, BadMsgNotification,
SecurityCheckMismatch
)
from pyrogram.raw.all import layer
@ -397,7 +397,7 @@ class Session:
while True:
try:
return await self.send(query, timeout=timeout)
except FloodWait as e:
except (FloodWait, FloodPremiumWait) as e:
amount = e.value
if amount > sleep_threshold >= 0: