1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 10:38:59 +01:00

Avoid errors if rpc.pwrtelegram.xyz is down

This commit is contained in:
Daniil Gentili 2021-12-07 16:10:48 +01:00
parent 395fa7772f
commit 0facd404ec
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -45,17 +45,20 @@ class RPCErrorException extends \Exception
$description = self::$descriptions[$error] ?? '';
if (!isset(self::$errorMethodMap[$code][$method][$error]) || !isset(self::$descriptions[$error]) || $code === 500) {
Tools::callFork((function () use ($method, $code, $error) {
$res = \json_decode(
yield
(yield HttpClientBuilder::buildDefault()
->request(new Request('https://rpc.pwrtelegram.xyz/?method='.$method.'&code='.$code.'&error='.$error))
)->getBody()->buffer(),
true
);
if (isset($res['ok']) && $res['ok'] && isset($res['result'])) {
$description = $res['result'];
RPCErrorException::$descriptions[$error] = $description;
RPCErrorException::$errorMethodMap[$code][$method][$error] = $error;
try {
$res = \json_decode(
yield
(yield HttpClientBuilder::buildDefault()
->request(new Request('https://rpc.pwrtelegram.xyz/?method='.$method.'&code='.$code.'&error='.$error))
)->getBody()->buffer(),
true
);
if (isset($res['ok']) && $res['ok'] && isset($res['result'])) {
$description = $res['result'];
RPCErrorException::$descriptions[$error] = $description;
RPCErrorException::$errorMethodMap[$code][$method][$error] = $error;
}
} catch (\Throwable $e) {
}
})());
}