1
0
mirror of https://github.com/danog/telerpc.git synced 2024-11-30 04:38:57 +01:00
This commit is contained in:
Daniil Gentili 2023-04-18 22:03:14 +02:00
parent afcf8e8928
commit 7b2f28a5c0

View File

@ -117,7 +117,8 @@ final class Main
$q = $this->pdo->prepare('SELECT method, code, error FROM errors');
$q->execute();
$r = [];
$q->fetchAll(PDO::FETCH_FUNC, function ($method, $code, $error) use (&$r, $core) {
$bot_only = [];
$q->fetchAll(PDO::FETCH_FUNC, function ($method, $code, $error) use (&$r, &$bot_only, $core) {
if ($core && ($error === 'UPDATE_APP_TO_LOGIN' || $error === 'UPDATE_APP_REQUIRED')) {
return;
}
@ -126,6 +127,9 @@ final class Main
if (!\in_array($method, $r[$code][$error] ?? [])) {
$r[$code][$error][] = $method;
}
if (\in_array($error, ['USER_BOT_REQUIRED', 'USER_BOT_INVALID']) && !\in_array($method, $bot_only)) {
$bot_only[] = $method;
}
});
$hr = [];
$q = $this->pdo->prepare('SELECT error, description FROM error_descriptions');
@ -144,7 +148,7 @@ final class Main
$hr['FLOOD_WAIT_%d'] = 'Please wait %d seconds before repeating the action.';
return [$r, $hr];
return [$r, $hr, $bot_only];
}
private function bot(): array
@ -162,6 +166,7 @@ final class Main
{
$this->connect();
$bot_only = [];
$q = $this->pdo->prepare('SELECT error, method FROM errors');
$q->execute();
$r = $q->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP);
@ -251,8 +256,8 @@ final class Main
\file_put_contents('data/bot.json', \json_encode(['ok' => true, 'result' => $bot]));
\file_put_contents('data/botdiff.json', \json_encode(['ok' => true, 'result' => $bot], JSON_PRETTY_PRINT));
[$r, $hr] = $this->v4(true);
\file_put_contents('data/core.json', \json_encode(['errors' => $r, 'descriptions' => $hr, 'user_only' => $bot]));
[$r, $hr, $bot_only] = $this->v4(true);
\file_put_contents('data/core.json', \json_encode(['errors' => $r, 'descriptions' => $hr, 'user_only' => $bot, 'bot_only' => $bot_only]));
}
public function run(): void