From d16e275a29d7679220c0d83fb5738b4d7d7ddbaf Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 15 Jun 2024 18:07:50 +0200 Subject: [PATCH] Add more global codes --- src/Main.php | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/Main.php b/src/Main.php index 3ccd1e6..ecd1675 100644 --- a/src/Main.php +++ b/src/Main.php @@ -199,12 +199,13 @@ final class Main } } - $allowed = ['SESSION_PASSWORD_NEEDED' => true, 'BOT_METHOD_INVALID' => true]; - $q = $this->pdo->prepare('SELECT error, method FROM errors'); $q->execute(); $r = $q->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP); - foreach ($r as $error => $methods) { + foreach (array_merge($r, self::GLOBAL_CODES) as $error => $methods) { + if (is_int($methods)) { + $methods = []; + } $anyok = false; foreach ($methods as $method) { if (RPCErrorException::isBad($error, 0, $method)) { @@ -218,7 +219,6 @@ final class Main if (!$anyok) { continue; } - $allowed[$error] = true; $q = $this->pdo->prepare('SELECT description FROM error_descriptions WHERE error=?'); $q->execute([$error]); @@ -239,19 +239,6 @@ final class Main } } - $q = $this->pdo->prepare('SELECT error FROM error_descriptions'); - $q->execute(); - $r = $q->fetchAll(PDO::FETCH_COLUMN); - foreach ($r as $error) { - if (!isset($allowed[$error])) { - $q = $this->pdo->prepare('DELETE FROM errors WHERE error=?'); - $q->execute([$error]); - $q = $this->pdo->prepare('DELETE FROM error_descriptions WHERE error=?'); - $q->execute([$error]); - echo 'Delete '.$error."\n"; - } - } - $r = $this->v2(); \file_put_contents('data/v2.json', \json_encode(['ok' => true, 'result' => $r])); [$r, $hr] = $this->v3();