1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-23 10:11:13 +01:00
This commit is contained in:
Daniil Gentili 2023-10-04 22:44:11 +02:00
parent d69ecf91d0
commit 744fa46820
2 changed files with 8 additions and 6 deletions

View File

@ -34,6 +34,7 @@ use danog\MadelineProto\Tools;
use Error;
use Revolt\EventLoop;
use function Amp\delay;
use function substr;
/**
@ -104,7 +105,7 @@ final class ReadLoop extends Loop
$this->connection->reconnect();
} elseif ($error === -429) {
$this->API->logger("Got -429 from DC {$this->datacenter}", Logger::WARNING);
Tools::sleep(3);
delay(3);
$this->connection->reconnect();
} else {
$this->connection->reconnect();

View File

@ -58,6 +58,7 @@ use Webmozart\Assert\Assert;
use const LOCK_EX;
use function Amp\async;
use function Amp\delay;
use function Amp\File\deleteFile;
use function Amp\File\getSize;
use function Amp\File\openFile;
@ -1171,8 +1172,7 @@ trait Files
} else {
$basic_param = ['file_token' => $messageMedia['file_token'], 'floodWaitLimit' => 0, 'cancellation' => $cancellation];
}
//$x = 0;
while (true) {
do {
$cancellation?->throwIfRequested();
try {
$res = $this->methodCallAsyncRead(
@ -1184,18 +1184,18 @@ trait Files
} catch (FileRedirect $e) {
$datacenter = $e->dc;
} catch (FloodWaitError $e) {
Tools::sleep(1);
continue;
delay(1, cancellation: $cancellation);
} catch (RPCErrorException $e) {
switch ($e->rpc) {
case 'FILE_TOKEN_INVALID':
$cdn = false;
$datacenter = $this->authorized_dc;
continue 3;
default:
throw $e;
}
}
}
} while (true);
$cancellation?->throwIfRequested();
if ($res['_'] === 'upload.fileCdnRedirect') {
@ -1222,6 +1222,7 @@ trait Files
case 'FILE_TOKEN_INVALID':
case 'REQUEST_TOKEN_INVALID':
$cdn = false;
$datacenter = $this->authorized_dc;
continue 2;
default:
throw $e;