fix(core): support FLOOD_PREMIUM_WAIT_

This commit is contained in:
alina 🌸 2024-12-06 00:08:03 +03:00
parent 4a7479561b
commit 0c615869d2
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI

View file

@ -90,6 +90,7 @@ export function floodWaiter(options: FloodWaiterOptions): RpcCallMiddleware {
err.startsWith('FLOOD_WAIT_') err.startsWith('FLOOD_WAIT_')
|| err.startsWith('SLOWMODE_WAIT_') || err.startsWith('SLOWMODE_WAIT_')
|| err.startsWith('FLOOD_TEST_PHONE_WAIT_') || err.startsWith('FLOOD_TEST_PHONE_WAIT_')
|| err.startsWith('FLOOD_PREMIUM_WAIT_')
) { ) {
let seconds = Number(err.slice(err.lastIndexOf('_') + 1)) let seconds = Number(err.slice(err.lastIndexOf('_') + 1))
@ -113,7 +114,11 @@ export function floodWaiter(options: FloodWaiterOptions): RpcCallMiddleware {
const ms = seconds * 1000 const ms = seconds * 1000
if (ms <= floodSleepThreshold) { if (ms <= floodSleepThreshold) {
if (ctx.request._ !== 'upload.getFile') {
// upload.getFile often results in flood waits, so we don't want to spam the log
ctx.manager._log.warn('%s resulted in a flood wait, will retry in %d seconds', method, seconds) ctx.manager._log.warn('%s resulted in a flood wait, will retry in %d seconds', method, seconds)
}
await sleepWithAbort( await sleepWithAbort(
ms, ms,
combineAbortSignals(ctx.manager.params.stopSignal, ctx.params?.abortSignal), combineAbortSignals(ctx.manager.params.stopSignal, ctx.params?.abortSignal),