From 55e1d2f15fc9c5747562ff7d30a2ff9a595ff9d1 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 25 Jul 2023 19:06:31 +0200 Subject: [PATCH] Update localization --- src/EventHandler/AbstractMessage.php | 4 ++-- src/EventHandler/Message.php | 6 +++--- src/Ipc/EventHandlerProxy.php | 6 ++++-- src/Lang.php | 9 +++++++++ src/MTProtoTools/PasswordCalculator.php | 2 +- src/TL/Types/Button.php | 15 +++------------ src/Wrappers/Login.php | 11 ++++++++++- 7 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/EventHandler/AbstractMessage.php b/src/EventHandler/AbstractMessage.php index c4813207e..2164b5bcd 100644 --- a/src/EventHandler/AbstractMessage.php +++ b/src/EventHandler/AbstractMessage.php @@ -104,8 +104,8 @@ abstract class AbstractMessage extends Update implements SimpleFilters return $this->replyToMsgId !== null; } - private readonly ?self $replyCache; - private bool $replyCached = false; + protected readonly ?self $replyCache; + protected bool $replyCached = false; /** * Get replied-to message. * diff --git a/src/EventHandler/Message.php b/src/EventHandler/Message.php index 50da7038a..44c6b55f1 100644 --- a/src/EventHandler/Message.php +++ b/src/EventHandler/Message.php @@ -137,9 +137,9 @@ abstract class Message extends AbstractMessage } } - private readonly string $html; - private readonly string $htmlTelegram; - private readonly ?array $entities; + protected readonly string $html; + protected readonly string $htmlTelegram; + protected readonly ?array $entities; /** * Get an HTML version of the message. * diff --git a/src/Ipc/EventHandlerProxy.php b/src/Ipc/EventHandlerProxy.php index 10965eabc..9e6ca7b0e 100644 --- a/src/Ipc/EventHandlerProxy.php +++ b/src/Ipc/EventHandlerProxy.php @@ -2,14 +2,16 @@ namespace danog\MadelineProto\Ipc; +use danog\MadelineProto\MTProto; + /** * Plugin event handler proxy object, for use through the IPC API. */ final class EventHandlerProxy extends IpcCapable { public function __construct( - private readonly ?string $__plugin, - Client $API + protected readonly ?string $__plugin, + MTProto $API ) { parent::__construct($API); } diff --git a/src/Lang.php b/src/Lang.php index 233959f9e..da22c7fdb 100644 --- a/src/Lang.php +++ b/src/Lang.php @@ -73,6 +73,7 @@ If you intentionally deleted this account, ignore this message.', 'call_error_3' => 'نەتوانرا پەیوەندی %s بدۆزرێتەوە و تەواو بکات', 'cli_need_dl.php_link' => 'Please specify a download script URL when using getDownloadLink via CLI!', 'constructor_not_found' => 'Constructor نەدۆزرایەوە بۆ جۆری: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'Could not convert object of type %s', 'deserialization_error' => 'هەڵەیەک لە کاتی ڕیزبەندیکردندا ڕوویدا', 'dl.php_check_logs_make_sure_session_running' => 'Either the associated MadelineProto EventHandler bot or the MadelineProto IPC server are offline, please check logs and make sure at least one of them is running!', @@ -235,6 +236,7 @@ If you intentionally deleted this account, ignore this message.', 'call_error_3' => 'Could not find and complete call %s', 'cli_need_dl.php_link' => 'Please specify a download script URL when using getDownloadLink via CLI!', 'constructor_not_found' => 'Constructor not found for type: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'Could not convert object of type %s', 'deserialization_error' => 'An error occurred on deserialization', 'dl.php_check_logs_make_sure_session_running' => 'Either the associated MadelineProto EventHandler bot or the MadelineProto IPC server are offline, please check logs and make sure at least one of them is running!', @@ -397,6 +399,7 @@ If you intentionally deleted this account, ignore this message.', 'call_error_3' => 'نمیتوان تماس %s را یافت و کامل کرد', 'cli_need_dl.php_link' => 'لطفا هنگام استفاده از getDownloadLink روی CLI (محیط ترمینال)، لینک اسکریپت دانلود را مشخص کنید!', 'constructor_not_found' => 'سازنده برای این نوع پیدا نشد: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'نمیتوان مقدار آبجکت تایپ %s را تبدیل کرد', 'deserialization_error' => 'مشکلی در سریال‌زدایی پیش آمد', 'dl.php_check_logs_make_sure_session_running' => 'هم ربات ایونت‌هندلر مدلین‌پروتو مرتبط و هم سرور IPC مدلین‌پروتو آفلاین هستند، لطفا لاگ‌ها را بررسی کنید و مطمئن شوید حداقل یکی از آنها در حال اجراست!', @@ -559,6 +562,7 @@ If you intentionally deleted this account, ignore this message.', 'call_error_3' => 'Impossible de trouver et de terminer l\'appel %s', 'cli_need_dl.php_link' => 'Please specify a download script URL when using getDownloadLink via CLI!', 'constructor_not_found' => 'Constructor not found for type: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'Could not convert object of type %s', 'deserialization_error' => 'Une erreur s\'est produite lors de la désérialisation', 'dl.php_check_logs_make_sure_session_running' => 'Either the associated MadelineProto EventHandler bot or the MadelineProto IPC server are offline, please check logs and make sure at least one of them is running!', @@ -721,6 +725,7 @@ If you intentionally deleted this account, ignore this message.', 'call_error_3' => 'לא ניתן היה למצוא ולהשלים את השיחה %s', 'cli_need_dl.php_link' => 'Please specify a download script URL when using getDownloadLink via CLI!', 'constructor_not_found' => 'הבנאי לא נמצא לסוג: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'Could not convert object of type %s', 'deserialization_error' => 'אירעה שגיאה בעת דה-סידריאליזציה', 'dl.php_check_logs_make_sure_session_running' => 'Either the associated MadelineProto EventHandler bot or the MadelineProto IPC server are offline, please check logs and make sure at least one of them is running!', @@ -883,6 +888,7 @@ Ignorare questo messaggio se la sessione è stata resettata intenzionalmente.', 'call_error_3' => 'Impossibile trovare e completare la chiamata %s', 'cli_need_dl.php_link' => 'È necessario specificare l\'URL dello script di scaricamente per usare getDownloadLink via CLI!', 'constructor_not_found' => 'Costruttore non trovato per tipo: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'Non è stato possibile convertire l\'oggetto di tipo %s', 'deserialization_error' => 'C\'è stato un errore durante la deserializzazione', 'dl.php_check_logs_make_sure_session_running' => 'Sia l\'event handler associato al bot che il server IPC della sessione sono offline, controllare i log e assicurarsi che almeno uno dei due sia online!', @@ -1045,6 +1051,7 @@ If you intentionally deleted this account, ignore this message.', 'call_error_3' => 'Could not find and complete call %s', 'cli_need_dl.php_link' => 'Please specify a download script URL when using getDownloadLink via CLI!', 'constructor_not_found' => 'Constructor not found for type: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'Could not convert object of type %s', 'deserialization_error' => 'An error occurred on deserialization', 'dl.php_check_logs_make_sure_session_running' => 'Either the associated MadelineProto EventHandler bot or the MadelineProto IPC server are offline, please check logs and make sure at least one of them is running!', @@ -1207,6 +1214,7 @@ If you intentionally deleted this account, ignore this message.', 'call_error_3' => '%s qo‘ng‘irog‘ini topib bo‘lmadi', 'cli_need_dl.php_link' => 'Please specify a download script URL when using getDownloadLink via CLI!', 'constructor_not_found' => 'Ushbu tur uchun konstruktor topilmadi: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'Could not convert object of type %s', 'deserialization_error' => 'Seriyadan chiqarishda xatolik yuz berdi', 'dl.php_check_logs_make_sure_session_running' => 'Either the associated MadelineProto EventHandler bot or the MadelineProto IPC server are offline, please check logs and make sure at least one of them is running!', @@ -1371,6 +1379,7 @@ If you intentionally deleted this account, ignore this message.', 'call_error_3' => 'Could not find and complete call %s', 'cli_need_dl.php_link' => 'Please specify a download script URL when using getDownloadLink via CLI!', 'constructor_not_found' => 'Constructor not found for type: ', + 'could_not_connect_to_MadelineProto' => 'Could not connect to MadelineProto, please enable proc_open or disable webserver path rewrites to fix!', 'could_not_convert_object' => 'Could not convert object of type %s', 'deserialization_error' => 'An error occurred on deserialization', 'dl.php_check_logs_make_sure_session_running' => 'Either the associated MadelineProto EventHandler bot or the MadelineProto IPC server are offline, please check logs and make sure at least one of them is running!', diff --git a/src/MTProtoTools/PasswordCalculator.php b/src/MTProtoTools/PasswordCalculator.php index b44ef6376..89ec6a4bb 100644 --- a/src/MTProtoTools/PasswordCalculator.php +++ b/src/MTProtoTools/PasswordCalculator.php @@ -192,7 +192,7 @@ final class PasswordCalculator $g_x = $g->powMod($x, $p); $k = new BigInteger(\hash('sha256', $pForHash.$gForHash, true), 256); $kg_x = $k->multiply($g_x)->powMod(Magic::$one, $p); - $a = new BigInteger(Tools::random(2048 / 8), 256); + $a = new BigInteger(Tools::random(256), 256); $A = $g->powMod($a, $p); Crypt::checkG($A, $p); $AForHash = \str_pad($A->toBytes(), 256, \chr(0), STR_PAD_LEFT); diff --git a/src/TL/Types/Button.php b/src/TL/Types/Button.php index ae9dc0ba0..4c41abd7f 100644 --- a/src/TL/Types/Button.php +++ b/src/TL/Types/Button.php @@ -39,16 +39,16 @@ final class Button extends IpcCapable implements JsonSerializable, ArrayAccess * * @var array */ - private array $button = []; + protected array $button = []; /** * Message ID. */ - private int $id; + protected int $id; /** * Peer ID. * */ - private array|int $peer; + protected array|int $peer; /** * Constructor function. * @@ -95,15 +95,6 @@ final class Button extends IpcCapable implements JsonSerializable, ArrayAccess return $this->getClient()->clickInternal($donotwait, 'messages.getBotCallbackAnswer', ['peer' => $this->peer, 'msg_id' => $this->id, 'game' => true]); } } - /** - * Get debug info. - */ - public function __debugInfo(): array - { - $res = \get_object_vars($this); - unset($res['API']); - return $res; - } /** * Serialize button. */ diff --git a/src/Wrappers/Login.php b/src/Wrappers/Login.php index e5db7e5c1..9005614e8 100644 --- a/src/Wrappers/Login.php +++ b/src/Wrappers/Login.php @@ -308,7 +308,16 @@ trait Login throw new Exception(Lang::$current_lang['2fa_uncalled']); } $this->logger->logger(Lang::$current_lang['login_user'], Logger::NOTICE); - return $this->processAuthorization($this->methodCallAsyncRead('auth.checkPassword', ['password' => $password])); + try { + $res = $this->methodCallAsyncRead('auth.checkPassword', ['password' => $password]); + } catch (RPCErrorException $e) { + if ($e->rpc === 'PASSWORD_HASH_INVALID') { + $res = $this->methodCallAsyncRead('auth.checkPassword', ['password' => $password]); + } else { + throw $e; + } + } + return $this->processAuthorization($res); } private function processAuthorization(array $authorization): array {