1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-12 09:59:41 +01:00
MadelineProto/src/RPCErrorException.php

227 lines
12 KiB
PHP
Raw Normal View History

2022-12-30 21:54:44 +01:00
<?php
declare(strict_types=1);
Merge alpha into master (async, huge bugfixes and more) (#546) * Implement async and lots of bugfixes * Implement more async * Implement async, implement bugfixes for the connection module, for the datacenter module, huge bugfixes, huge perfomance improvements, media DCs for https, advanced selecting, custom var_dump, totally rewritten IOLoop and response mechanism, promises, improvements to the TL parser, custom mb_substr * Apply fixes from StyleCI * Bugfixes * Apply fixes from StyleCI * Bugfixes, implement combined promises * Apply fixes from StyleCI * Support passing method arguments as callable * Starting to write async upload logic * Apply fixes from StyleCI * Start implementing async file upload * Apply fixes from StyleCI * bugfix * Apply fixes from StyleCI * Start rewriting connection module * Add PHP file docblocks for all classes * Start working on new async stream API * Finish writing stream API * More stream API fixes * Apply fixes from StyleCI * Rewrite DataCenter and Connection modules * Clean up stream API documentation * Fixes * Apply fixes from StyleCI * Add referenced parameter to get length of buffer to read in getReadBuffer API * Moved all MessageHandler code in the Connection module, added a PHP version warning in the phar * Start fixing reads * Fix all protocol stream wrappers * Apply fixes from StyleCI * Implement disconnection, and remove end function * Working async RPC * Implement async file upload * Bugfix * Method recall bugfixes * Bugfixes * Trait bugfixes * Fix FIFO buffer * Bugfixes and speedtests * Async logging * Implement websocket streams * Implement loop API, signal API, clean closing and start changing layer * Small magna, websocket and HTTP fixes * Clean up loop API * Improved stack traces, 2FA and async * Login fixes * Added instructions for manual verification * Small fixes * More app info improvements * More app info improvements * TL and 2FA fixes * Update to layer 89 * More bugfixes * Implement broken media reporting * Remove debug comments * PHP 7.2 backwards compatibility * Bugfixes * Async key generation * Some simplifications * Transport fixes * Cleanup * async API * Performance fixes * Fixes to async API * Bugfixes * Implement one-time async loop * Authorization and logging fixes * Update to layer 91 * 7to5 fix * Null coalesce conversion * Implement socks5 proxy * Implement HTTP proxy * Fixes to HTTP proxy * MTProxy and socks5 fixes * Disable PHP 5 conversion * Proxies have higher priority * Avoid error handling in vendor * Override composer dependencies * Fix travis build * Final composer fixes * Proxy logic fixes * Fix get_updates update handling * Do not use parallel file driver if not supported * Refactor loader and implement HTTP fixes * Suppress errors in loader * HTTP and authorization fixes * HTTP fixes * Improved peer management * Use HTTP protocol on altervista * Small bugfixes * Minor fixes * Docufix * Docufix * Legacy fixes * Fix message queue * Avoid updating if using MTProxy * Improve logs and examples * Trim final newlines while converting parse mode * Reimplement noResponse flag * Async combined event handler and APIFactory fixes * Actually return config * Case-insensitive methods * Bugfix * Apply fixes from StyleCI (#545) * MTProxy fixes * PHP 5 warning * Improved PHP 5 warning * Use <br> along with newlines in web logs * Update docs
2018-12-26 20:51:14 +01:00
/**
* RPCErrorException module.
*
* This file is part of MadelineProto.
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU General Public License along with MadelineProto.
* If not, see <http://www.gnu.org/licenses/>.
*
* @author Daniil Gentili <daniil@daniil.it>
2023-01-04 12:43:01 +01:00
* @copyright 2016-2023 Daniil Gentili <daniil@daniil.it>
Merge alpha into master (async, huge bugfixes and more) (#546) * Implement async and lots of bugfixes * Implement more async * Implement async, implement bugfixes for the connection module, for the datacenter module, huge bugfixes, huge perfomance improvements, media DCs for https, advanced selecting, custom var_dump, totally rewritten IOLoop and response mechanism, promises, improvements to the TL parser, custom mb_substr * Apply fixes from StyleCI * Bugfixes * Apply fixes from StyleCI * Bugfixes, implement combined promises * Apply fixes from StyleCI * Support passing method arguments as callable * Starting to write async upload logic * Apply fixes from StyleCI * Start implementing async file upload * Apply fixes from StyleCI * bugfix * Apply fixes from StyleCI * Start rewriting connection module * Add PHP file docblocks for all classes * Start working on new async stream API * Finish writing stream API * More stream API fixes * Apply fixes from StyleCI * Rewrite DataCenter and Connection modules * Clean up stream API documentation * Fixes * Apply fixes from StyleCI * Add referenced parameter to get length of buffer to read in getReadBuffer API * Moved all MessageHandler code in the Connection module, added a PHP version warning in the phar * Start fixing reads * Fix all protocol stream wrappers * Apply fixes from StyleCI * Implement disconnection, and remove end function * Working async RPC * Implement async file upload * Bugfix * Method recall bugfixes * Bugfixes * Trait bugfixes * Fix FIFO buffer * Bugfixes and speedtests * Async logging * Implement websocket streams * Implement loop API, signal API, clean closing and start changing layer * Small magna, websocket and HTTP fixes * Clean up loop API * Improved stack traces, 2FA and async * Login fixes * Added instructions for manual verification * Small fixes * More app info improvements * More app info improvements * TL and 2FA fixes * Update to layer 89 * More bugfixes * Implement broken media reporting * Remove debug comments * PHP 7.2 backwards compatibility * Bugfixes * Async key generation * Some simplifications * Transport fixes * Cleanup * async API * Performance fixes * Fixes to async API * Bugfixes * Implement one-time async loop * Authorization and logging fixes * Update to layer 91 * 7to5 fix * Null coalesce conversion * Implement socks5 proxy * Implement HTTP proxy * Fixes to HTTP proxy * MTProxy and socks5 fixes * Disable PHP 5 conversion * Proxies have higher priority * Avoid error handling in vendor * Override composer dependencies * Fix travis build * Final composer fixes * Proxy logic fixes * Fix get_updates update handling * Do not use parallel file driver if not supported * Refactor loader and implement HTTP fixes * Suppress errors in loader * HTTP and authorization fixes * HTTP fixes * Improved peer management * Use HTTP protocol on altervista * Small bugfixes * Minor fixes * Docufix * Docufix * Legacy fixes * Fix message queue * Avoid updating if using MTProxy * Improve logs and examples * Trim final newlines while converting parse mode * Reimplement noResponse flag * Async combined event handler and APIFactory fixes * Actually return config * Case-insensitive methods * Bugfix * Apply fixes from StyleCI (#545) * MTProxy fixes * PHP 5 warning * Improved PHP 5 warning * Use <br> along with newlines in web logs * Update docs
2018-12-26 20:51:14 +01:00
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
2019-10-31 15:07:35 +01:00
* @link https://docs.madelineproto.xyz MadelineProto documentation
Merge alpha into master (async, huge bugfixes and more) (#546) * Implement async and lots of bugfixes * Implement more async * Implement async, implement bugfixes for the connection module, for the datacenter module, huge bugfixes, huge perfomance improvements, media DCs for https, advanced selecting, custom var_dump, totally rewritten IOLoop and response mechanism, promises, improvements to the TL parser, custom mb_substr * Apply fixes from StyleCI * Bugfixes * Apply fixes from StyleCI * Bugfixes, implement combined promises * Apply fixes from StyleCI * Support passing method arguments as callable * Starting to write async upload logic * Apply fixes from StyleCI * Start implementing async file upload * Apply fixes from StyleCI * bugfix * Apply fixes from StyleCI * Start rewriting connection module * Add PHP file docblocks for all classes * Start working on new async stream API * Finish writing stream API * More stream API fixes * Apply fixes from StyleCI * Rewrite DataCenter and Connection modules * Clean up stream API documentation * Fixes * Apply fixes from StyleCI * Add referenced parameter to get length of buffer to read in getReadBuffer API * Moved all MessageHandler code in the Connection module, added a PHP version warning in the phar * Start fixing reads * Fix all protocol stream wrappers * Apply fixes from StyleCI * Implement disconnection, and remove end function * Working async RPC * Implement async file upload * Bugfix * Method recall bugfixes * Bugfixes * Trait bugfixes * Fix FIFO buffer * Bugfixes and speedtests * Async logging * Implement websocket streams * Implement loop API, signal API, clean closing and start changing layer * Small magna, websocket and HTTP fixes * Clean up loop API * Improved stack traces, 2FA and async * Login fixes * Added instructions for manual verification * Small fixes * More app info improvements * More app info improvements * TL and 2FA fixes * Update to layer 89 * More bugfixes * Implement broken media reporting * Remove debug comments * PHP 7.2 backwards compatibility * Bugfixes * Async key generation * Some simplifications * Transport fixes * Cleanup * async API * Performance fixes * Fixes to async API * Bugfixes * Implement one-time async loop * Authorization and logging fixes * Update to layer 91 * 7to5 fix * Null coalesce conversion * Implement socks5 proxy * Implement HTTP proxy * Fixes to HTTP proxy * MTProxy and socks5 fixes * Disable PHP 5 conversion * Proxies have higher priority * Avoid error handling in vendor * Override composer dependencies * Fix travis build * Final composer fixes * Proxy logic fixes * Fix get_updates update handling * Do not use parallel file driver if not supported * Refactor loader and implement HTTP fixes * Suppress errors in loader * HTTP and authorization fixes * HTTP fixes * Improved peer management * Use HTTP protocol on altervista * Small bugfixes * Minor fixes * Docufix * Docufix * Legacy fixes * Fix message queue * Avoid updating if using MTProxy * Improve logs and examples * Trim final newlines while converting parse mode * Reimplement noResponse flag * Async combined event handler and APIFactory fixes * Actually return config * Case-insensitive methods * Bugfix * Apply fixes from StyleCI (#545) * MTProxy fixes * PHP 5 warning * Improved PHP 5 warning * Use <br> along with newlines in web logs * Update docs
2018-12-26 20:51:14 +01:00
*/
2018-02-24 17:54:39 +01:00
namespace danog\MadelineProto;
2021-10-02 17:18:25 +02:00
use Amp\Http\Client\HttpClientBuilder;
use Amp\Http\Client\Request;
2022-12-30 19:21:36 +01:00
use Throwable;
use const PHP_EOL;
2023-01-03 22:07:58 +01:00
2022-12-30 19:21:36 +01:00
use const PHP_SAPI;
2021-10-02 17:18:25 +02:00
/**
* Indicates an error returned by Telegram's API.
*/
2023-01-29 19:20:42 +01:00
class RPCErrorException extends \Exception
{
use TL\PrettyException;
private bool $fetched = false;
2023-06-27 19:47:41 +02:00
/** @internal */
public static array $descriptions = ['RPC_MCGET_FAIL' => 'Telegram is having internal issues, please try again later.', 'RPC_CALL_FAIL' => 'Telegram is having internal issues, please try again later.', 'USER_PRIVACY_RESTRICTED' => "The user's privacy settings do not allow you to do this", 'CHANNEL_PRIVATE' => "You haven't joined this channel/supergroup", 'USER_IS_BOT' => "Bots can't send messages to other bots", 'BOT_METHOD_INVALID' => 'This method cannot be run by a bot', 'PHONE_CODE_EXPIRED' => 'The phone code you provided has expired, this may happen if it was sent to any chat on telegram (if the code is sent through a telegram chat (not the official account) to avoid it append or prepend to the code some chars)', 'USERNAME_INVALID' => 'The provided username is not valid', 'ACCESS_TOKEN_INVALID' => 'The provided token is not valid', 'ACTIVE_USER_REQUIRED' => 'The method is only available to already activated users', 'FIRSTNAME_INVALID' => 'The first name is invalid', 'LASTNAME_INVALID' => 'The last name is invalid', 'PHONE_NUMBER_INVALID' => 'The phone number is invalid', 'PHONE_CODE_HASH_EMPTY' => 'phone_code_hash is missing', 'PHONE_CODE_EMPTY' => 'phone_code is missing', 'API_ID_INVALID' => 'The api_id/api_hash combination is invalid', 'PHONE_NUMBER_OCCUPIED' => 'The phone number is already in use', 'PHONE_NUMBER_UNOCCUPIED' => 'The phone number is not yet being used', 'USERS_TOO_FEW' => 'Not enough users (to create a chat, for example)', 'USERS_TOO_MUCH' => 'The maximum number of users has been exceeded (to create a chat, for example)', 'TYPE_CONSTRUCTOR_INVALID' => 'The type constructor is invalid', 'FILE_PART_INVALID' => 'The file part number is invalid', 'FILE_PARTS_INVALID' => 'The number of file parts is invalid', 'MD5_CHECKSUM_INVALID' => 'The MD5 checksums do not match', 'PHOTO_INVALID_DIMENSIONS' => 'The photo dimensions are invalid', 'FIELD_NAME_INVALID' => 'The field with the name FIELD_NAME is invalid', 'FIELD_NAME_EMPTY' => 'The field with the name FIELD_NAME is missing', 'MSG_WAIT_FAILED' => 'A waiting call returned an error', 'USERNAME_NOT_OCCUPIED' => 'The provided username is not occupied', 'PHONE_NUMBER_BANNED' => 'The provided phone number is banned from telegram', 'AUTH_KEY_UNREGISTERED' => 'The authorization key has expired', 'INVITE_HASH_EXPIRED' => 'The invite link has expired', 'USER_DEACTIVATED' => 'The user was deactivated', 'USER_ALREADY_PARTICIPANT' => 'The user is already in the group', 'MESSAGE_ID_INVALID' => 'The provided message id is invalid', 'PEER_ID_INVALID' => 'The provided peer id is invalid', 'CHAT_ID_INVALID' => 'The provided chat id is invalid', 'MESSAGE_DELETE_FORBIDDEN' => "You can't delete one of the messages you tried to delete, most likely because it is a service message.", 'CHAT_ADMIN_REQUIRED' => 'You must be an admin in this chat to do this', -429 => 'Too many requests', 'PEER_FLOOD' => "You are spamreported, you can't do this"];
2023-06-27 19:47:41 +02:00
/** @internal */
public static array $errorMethodMap = [];
2023-03-23 18:40:49 +01:00
private static array $fetchedError = [];
private string $caller = '';
2023-01-28 16:39:03 +01:00
private ?string $localized = null;
2024-01-20 19:07:36 +01:00
private const BAD = [
'PEER_FLOOD' => true,
'USER_DEACTIVATED_BAN' => true,
'INPUT_METHOD_INVALID' => true,
'INPUT_FETCH_ERROR' => true,
'AUTH_KEY_UNREGISTERED' => true,
'SESSION_REVOKED' => true,
'USER_DEACTIVATED' => true,
'RPC_SEND_FAIL' => true,
'RPC_CALL_FAIL' => true,
'RPC_MCGET_FAIL' => true,
'INTERDC_5_CALL_ERROR' => true,
'INTERDC_4_CALL_ERROR' => true,
'INTERDC_3_CALL_ERROR' => true,
'INTERDC_2_CALL_ERROR' => true,
'INTERDC_1_CALL_ERROR' => true,
'INTERDC_5_CALL_RICH_ERROR' => true,
'INTERDC_4_CALL_RICH_ERROR' => true,
'INTERDC_3_CALL_RICH_ERROR' => true,
'INTERDC_2_CALL_RICH_ERROR' => true,
'INTERDC_1_CALL_RICH_ERROR' => true,
'AUTH_KEY_DUPLICATED' => true,
'CONNECTION_NOT_INITED' => true,
'LOCATION_NOT_AVAILABLE' => true,
'AUTH_KEY_INVALID' => true,
'LANG_CODE_EMPTY' => true,
'memory limit exit' => true,
'memory limit(?)' => true,
'INPUT_REQUEST_TOO_LONG' => true,
'SESSION_PASSWORD_NEEDED' => true,
'INPUT_FETCH_FAIL' => true,
'CONNECTION_SYSTEM_EMPTY' => true,
'FILE_WRITE_FAILED' => true,
'STORAGE_CHOOSE_VOLUME_FAILED' => true,
'xxx' => true,
'AES_DECRYPT_FAILED' => true,
'Timedout' => true,
'SEND_REACTION_RESULT1_INVALID' => true,
'BOT_POLLS_DISABLED' => true,
'TEMPNAM_FAILED' => true,
'MSG_WAIT_TIMEOUT' => true,
'MEMBER_CHAT_ADD_FAILED' => true,
'CHAT_FROM_CALL_CHANGED' => true,
'MTPROTO_CLUSTER_INVALID' => true,
'CONNECTION_DEVICE_MODEL_EMPTY' => true,
'AUTH_KEY_PERM_EMPTY' => true,
'UNKNOWN_METHOD' => true,
'ENCRYPTION_OCCUPY_FAILED' => true,
'ENCRYPTION_OCCUPY_ADMIN_FAILED' => true,
'CHAT_OCCUPY_USERNAME_FAILED' => true,
'REG_ID_GENERATE_FAILED' => true,
'CONNECTION_LANG_PACK_INVALID' => true,
'MSGID_DECREASE_RETRY' => true,
'API_CALL_ERROR' => true,
'STORAGE_CHECK_FAILED' => true,
'INPUT_LAYER_INVALID' => true,
'NEED_MEMBER_INVALID' => true,
'NEED_CHAT_INVALID' => true,
'HISTORY_GET_FAILED' => true,
'CHP_CALL_FAIL' => true,
'IMAGE_ENGINE_DOWN' => true,
'MSG_RANGE_UNSYNC' => true,
'PTS_CHANGE_EMPTY' => true,
'CONNECTION_SYSTEM_LANG_CODE_EMPTY' => true,
'WORKER_BUSY_TOO_LONG_RETRY' => true,
'WP_ID_GENERATE_FAILED' => true,
'ARR_CAS_FAILED' => true,
'CHANNEL_ADD_INVALID' => true,
'CHANNEL_ADMINS_INVALID' => true,
'CHAT_OCCUPY_LOC_FAILED' => true,
'GROUPED_ID_OCCUPY_FAILED' => true,
'GROUPED_ID_OCCUPY_FAULED' => true,
'LOG_WRAP_FAIL' => true,
'MEMBER_FETCH_FAILED' => true,
'MEMBER_OCCUPY_PRIMARY_LOC_FAILED' => true,
'MEMBER_NO_LOCATION' => true,
'MEMBER_OCCUPY_USERNAME_FAILED' => true,
'MT_SEND_QUEUE_TOO_LONG' => true,
'POSTPONED_TIMEOUT' => true,
'RPC_CONNECT_FAILED' => true,
'SHORTNAME_OCCUPY_FAILED' => true,
'STORE_INVALID_OBJECT_TYPE' => true,
'STORE_INVALID_SCALAR_TYPE' => true,
'TMSG_ADD_FAILED' => true,
'UNKNOWN_ERROR' => true,
'UPLOAD_NO_VOLUME' => true,
'USER_NOT_AVAILABLE' => true,
'VOLUME_LOC_NOT_FOUND' => true,
2024-02-05 20:53:53 +01:00
'FILE_WRITE_EMPTY' => true,
2024-01-20 19:07:36 +01:00
];
/** @internal */
public static function isBad(string $error, int $code, string $method): bool
2023-05-31 09:51:13 +02:00
{
2024-01-20 19:07:36 +01:00
return isset(self::BAD[$error])
2023-10-01 20:05:04 +02:00
|| str_contains($error, 'Received bad_msg_notification')
|| str_contains($error, 'FLOOD_WAIT_')
|| str_contains($error, '_MIGRATE_')
|| str_contains($error, 'INPUT_METHOD_INVALID')
|| str_contains($error, 'INPUT_CONSTRUCTOR_INVALID')
2024-01-20 19:07:36 +01:00
|| str_contains($error, 'INPUT_FETCH_ERROR_')
2023-10-01 20:05:04 +02:00
|| str_contains($error, 'https://telegram.org/dl')
|| str_starts_with($error, 'Received bad_msg_notification')
|| str_starts_with($error, 'No workers running')
|| str_starts_with($error, 'All workers are busy. Active_queries ')
2024-01-20 19:07:36 +01:00
|| preg_match('/FILE_PART_\d*_MISSING/', $error)
2024-01-20 19:41:56 +01:00
|| !preg_match('/^[a-zA-Z0-9\._]+$/', $method)
2024-01-20 19:07:36 +01:00
|| ($error === 'Timeout' && !\in_array(strtolower($method), ['messages.getbotcallbackanswer', 'messages.getinlinebotresults'], true))
|| ($error === 'BOT_MISSING' && \in_array($method, ['stickers.changeStickerPosition', 'stickers.createStickerSet', 'messages.uploadMedia'], true));
2023-05-31 09:51:13 +02:00
}
public static function localizeMessage($method, int $code, string $error): string
2017-11-10 16:35:57 +01:00
{
2019-06-30 15:12:43 +02:00
if (!$method || !$code || !$error) {
return $error;
}
2023-10-01 20:05:04 +02:00
$error = preg_replace('/\\d+$/', 'X', $error);
2019-06-30 15:12:43 +02:00
$description = self::$descriptions[$error] ?? '';
2023-10-03 21:01:45 +02:00
if ((!isset(self::$errorMethodMap[$code][$method][$error]) || !isset(self::$descriptions[$error]))
2024-01-20 19:07:36 +01:00
&& !self::isBad($error, $code, $method)
2023-03-23 18:40:49 +01:00
) {
2023-11-23 20:50:50 +01:00
try {
$res = json_decode(
(
HttpClientBuilder::buildDefault()
2024-06-09 19:38:16 +02:00
->request(new Request('https://report-rpc-error.madelineproto.xyz/?method='.$method.'&code='.$code.'&error='.$error))
2023-11-23 20:50:50 +01:00
)->getBody()->buffer(),
true,
);
if (isset($res['ok']) && $res['ok'] && isset($res['result']) && \is_string($res['result'])) {
$description = $res['result'];
self::$descriptions[$error] = $description;
self::$errorMethodMap[$code][$method][$error] = $error;
2021-10-02 17:18:25 +02:00
}
2023-11-23 20:50:50 +01:00
self::$fetchedError[$error] = true;
} catch (Throwable) {
}
2017-11-10 16:19:58 +01:00
}
2019-06-30 15:12:43 +02:00
if (!$description) {
return $error;
}
return $description;
2017-11-10 16:19:58 +01:00
}
2023-01-11 18:47:27 +01:00
public function __toString(): string
2017-07-26 08:31:15 +02:00
{
2023-01-24 12:45:55 +01:00
Magic::start(light: true);
2020-07-11 20:01:54 +02:00
$this->localized ??= self::localizeMessage($this->caller, $this->code, $this->message);
2023-10-01 20:05:04 +02:00
$result = sprintf(Lang::$current_lang['rpc_tg_error'], $this->localized." ({$this->code})", $this->rpc, $this->file, $this->line.PHP_EOL, Magic::$revision.PHP_EOL.PHP_EOL).PHP_EOL.$this->getTLTrace().PHP_EOL;
2020-07-09 20:53:01 +02:00
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
2023-10-01 20:05:04 +02:00
$result = str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
Merge alpha into master (async, huge bugfixes and more) (#546) * Implement async and lots of bugfixes * Implement more async * Implement async, implement bugfixes for the connection module, for the datacenter module, huge bugfixes, huge perfomance improvements, media DCs for https, advanced selecting, custom var_dump, totally rewritten IOLoop and response mechanism, promises, improvements to the TL parser, custom mb_substr * Apply fixes from StyleCI * Bugfixes * Apply fixes from StyleCI * Bugfixes, implement combined promises * Apply fixes from StyleCI * Support passing method arguments as callable * Starting to write async upload logic * Apply fixes from StyleCI * Start implementing async file upload * Apply fixes from StyleCI * bugfix * Apply fixes from StyleCI * Start rewriting connection module * Add PHP file docblocks for all classes * Start working on new async stream API * Finish writing stream API * More stream API fixes * Apply fixes from StyleCI * Rewrite DataCenter and Connection modules * Clean up stream API documentation * Fixes * Apply fixes from StyleCI * Add referenced parameter to get length of buffer to read in getReadBuffer API * Moved all MessageHandler code in the Connection module, added a PHP version warning in the phar * Start fixing reads * Fix all protocol stream wrappers * Apply fixes from StyleCI * Implement disconnection, and remove end function * Working async RPC * Implement async file upload * Bugfix * Method recall bugfixes * Bugfixes * Trait bugfixes * Fix FIFO buffer * Bugfixes and speedtests * Async logging * Implement websocket streams * Implement loop API, signal API, clean closing and start changing layer * Small magna, websocket and HTTP fixes * Clean up loop API * Improved stack traces, 2FA and async * Login fixes * Added instructions for manual verification * Small fixes * More app info improvements * More app info improvements * TL and 2FA fixes * Update to layer 89 * More bugfixes * Implement broken media reporting * Remove debug comments * PHP 7.2 backwards compatibility * Bugfixes * Async key generation * Some simplifications * Transport fixes * Cleanup * async API * Performance fixes * Fixes to async API * Bugfixes * Implement one-time async loop * Authorization and logging fixes * Update to layer 91 * 7to5 fix * Null coalesce conversion * Implement socks5 proxy * Implement HTTP proxy * Fixes to HTTP proxy * MTProxy and socks5 fixes * Disable PHP 5 conversion * Proxies have higher priority * Avoid error handling in vendor * Override composer dependencies * Fix travis build * Final composer fixes * Proxy logic fixes * Fix get_updates update handling * Do not use parallel file driver if not supported * Refactor loader and implement HTTP fixes * Suppress errors in loader * HTTP and authorization fixes * HTTP fixes * Improved peer management * Use HTTP protocol on altervista * Small bugfixes * Minor fixes * Docufix * Docufix * Legacy fixes * Fix message queue * Avoid updating if using MTProxy * Improve logs and examples * Trim final newlines while converting parse mode * Reimplement noResponse flag * Async combined event handler and APIFactory fixes * Actually return config * Case-insensitive methods * Bugfix * Apply fixes from StyleCI (#545) * MTProxy fixes * PHP 5 warning * Improved PHP 5 warning * Use <br> along with newlines in web logs * Update docs
2018-12-26 20:51:14 +01:00
}
return $result;
2017-07-26 08:31:15 +02:00
}
2020-07-11 20:01:54 +02:00
/**
2020-07-12 01:27:26 +02:00
* Get localized error name.
2020-07-11 20:01:54 +02:00
*/
public function getLocalization(): string
{
$this->localized ??= self::localizeMessage($this->caller, $this->code, $this->message);
return $this->localized;
}
2024-06-15 15:36:14 +02:00
public function __construct(
/** @var string RPC error */
public readonly string $rpc,
2024-06-15 15:36:14 +02:00
int $code,
string $caller,
?Exception $previous = null
) {
parent::__construct($rpc, $code, $previous);
2024-06-15 15:36:14 +02:00
$this->prettifyTL($caller);
$this->caller = $caller;
foreach ($this->getTrace() as $level) {
if (isset($level['function']) && $level['function'] === 'methodCall') {
$this->line = $level['line'];
$this->file = $level['file'];
2017-04-27 11:59:18 +02:00
}
}
2022-02-24 19:57:24 +01:00
$this->getLocalization();
2017-04-21 21:24:07 +02:00
}
2018-02-24 17:54:39 +01:00
}