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 id message
2FA_CONFIRM_WAIT_X A wait of {value} seconds is required because this account is active and protected by a 2FA password 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_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 FLOOD_WAIT_X A wait of {value} seconds is required
PREMIUM_SUB_ACTIVE_UNTIL_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 ( from pyrogram.errors import (
SessionPasswordNeeded, SessionPasswordNeeded,
VolumeLocNotFound, ChannelPrivate, VolumeLocNotFound, ChannelPrivate,
BadRequest, AuthBytesInvalid BadRequest, AuthBytesInvalid,
FloodWait, FloodPremiumWait
) )
from pyrogram.handlers.handler import Handler from pyrogram.handlers.handler import Handler
from pyrogram.methods import Methods from pyrogram.methods import Methods
@ -863,7 +864,7 @@ class Client(Methods):
if isinstance(e, asyncio.CancelledError): if isinstance(e, asyncio.CancelledError):
raise e raise e
if isinstance(e, pyrogram.errors.FloodWait): if isinstance(e, (FloodWait, FloodPremiumWait)):
raise e raise e
return None return None
@ -1097,7 +1098,7 @@ class Client(Methods):
await cdn_session.stop() await cdn_session.stop()
except pyrogram.StopTransmission: except pyrogram.StopTransmission:
raise raise
except pyrogram.errors.FloodWait: except (FloodWait, FloodPremiumWait):
raise raise
except Exception as e: except Exception as e:
log.exception(e) log.exception(e)

View File

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