From 4fcfe1ccd2ab98bdc87aefc62eeb5881cb1dc1e7 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 1 Oct 2020 18:02:54 +0200 Subject: [PATCH] Update to layer 117 --- docs | 2 +- examples/bot.php | 1 + schemas | 2 +- src/danog/MadelineProto/InternalDoc.php | 159 ++++++++++++++++-- src/danog/MadelineProto/Ipc/Server.php | 6 +- .../MadelineProto/Loop/Update/FeedLoop.php | 11 +- src/danog/MadelineProto/MTProto.php | 2 +- .../MadelineProto/MTProtoTools/Files.php | 2 +- .../MTProtoTools/MinDatabase.php | 6 +- .../MTProtoTools/PeerHandler.php | 12 +- .../MTProtoTools/UpdateHandler.php | 10 +- src/danog/MadelineProto/Settings/TLSchema.php | 8 +- .../MadelineProto/TL/Conversion/BotAPI.php | 2 +- src/danog/MadelineProto/TL/Conversion/TD.php | 4 +- src/danog/MadelineProto/TL/TL.php | 4 +- src/danog/MadelineProto/TL/Types/Button.php | 7 +- ...L_telegram_v117.tl => TL_telegram_v119.tl} | 83 ++++++--- src/danog/MadelineProto/Tools.php | 23 +++ tools/build_docs.php | 6 +- tools/build_docs/layerUpgrade.php | 7 +- tools/build_docs/schemas.php | 2 +- 21 files changed, 277 insertions(+), 82 deletions(-) rename src/danog/MadelineProto/{TL_telegram_v117.tl => TL_telegram_v119.tl} (94%) diff --git a/docs b/docs index 57562236a..960031580 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 57562236aade5d13a01c18a2290aa647686eebd5 +Subproject commit 9600315809337a79a88c7d878c7ce4ca16e29603 diff --git a/examples/bot.php b/examples/bot.php index 9c622fbac..24f70816b 100755 --- a/examples/bot.php +++ b/examples/bot.php @@ -79,6 +79,7 @@ class MyEventHandler extends EventHandler if ($update['message']['_'] === 'messageEmpty' || $update['message']['out'] ?? false) { return; } + $res = \json_encode($update, JSON_PRETTY_PRINT); yield $this->messages->sendMessage(['peer' => $update, 'message' => "$res", 'reply_to_msg_id' => isset($update['message']['id']) ? $update['message']['id'] : null, 'parse_mode' => 'HTML']); if (isset($update['message']['media']) && $update['message']['media']['_'] !== 'messageMediaGame') { diff --git a/schemas b/schemas index a878ff054..8fd40f0a4 160000 --- a/schemas +++ b/schemas @@ -1 +1 @@ -Subproject commit a878ff05408129b97eed651a0a5ab5bb66ebe1d0 +Subproject commit 8fd40f0a4170769465e4943e4a5da37bd58f7e88 diff --git a/src/danog/MadelineProto/InternalDoc.php b/src/danog/MadelineProto/InternalDoc.php index e6a1e2091..e53c5a72a 100644 --- a/src/danog/MadelineProto/InternalDoc.php +++ b/src/danog/MadelineProto/InternalDoc.php @@ -1157,7 +1157,7 @@ interface contacts * Adds the user to the blacklist. * * Parameters: - * * `InputUser` **id** - User ID + * * `InputPeer` **id** - * * @param array $params Parameters * @@ -1169,7 +1169,7 @@ interface contacts * Deletes the user from the blacklist. * * Parameters: - * * `InputUser` **id** - User ID + * * `InputPeer` **id** - * * @param array $params Parameters * @@ -1319,6 +1319,21 @@ interface contacts * @return Updates */ public function getLocated($params); + + /** + * + * + * Parameters: + * * `boolean` **delete_message** - Optional: + * * `boolean` **delete_history** - Optional: + * * `boolean` **report_spam** - Optional: + * * `int` **msg_id** -. + * + * @param array $params Parameters + * + * @return Updates + */ + public function blockFromReplies($params); } interface messages @@ -1379,6 +1394,7 @@ interface messages * * `InputPeer` **peer** - User or chat, histories with which are searched, or [(inputPeerEmpty)](https://docs.madelineproto.xyz/API_docs/constructors/inputPeerEmpty.html) constructor for global search * * `string` **q** - Text search request * * `InputUser` **from_id** - Optional: Only return messages sent by the specified user ID + * * `int` **top_msg_id** - Optional: * * `MessagesFilter` **filter** - Filter to return only specified message types * * `int` **min_date** - If a positive value was transferred, only messages with a sending date bigger than the transferred one will be returned * * `int` **max_date** - If a positive value was transferred, only messages with a sending date smaller than the transferred one will be returned @@ -1452,8 +1468,9 @@ interface messages * Sends a current user typing event (see [SendMessageAction](https://docs.madelineproto.xyz/API_docs/types/SendMessageAction.html) for all event types) to a conversation partner or group. * * Parameters: - * * `InputPeer` **peer** - Target user or group - * * `SendMessageAction` **action** - Type of action
Parameter added in [Layer 17](https://core.telegram.org/api/layers#layer-17). + * * `InputPeer` **peer** - Target user or group + * * `int` **top_msg_id** - Optional: + * * `SendMessageAction` **action** - Type of action
Parameter added in [Layer 17](https://core.telegram.org/api/layers#layer-17). * * @param array $params Parameters * @@ -1510,7 +1527,6 @@ interface messages * * `boolean` **silent** - Optional: Whether to send messages silently (no notification will be triggered on the destination clients) * * `boolean` **background** - Optional: Whether to send the message in background * * `boolean` **with_my_score** - Optional: When forwarding games, whether to include your score in the game - * * `boolean` **grouped** - Optional: Whether the specified messages represent an album (grouped media) * * `InputPeer` **from_peer** - Source of messages * * `[int]` **id** - IDs of messages * * `InputPeer` **to_peer** - Destination peer @@ -1732,6 +1748,7 @@ interface messages * Sends a text message to a secret chat. * * Parameters: + * * `boolean` **silent** - Optional: * * `InputEncryptedChat` **peer** - Secret chat ID * * `DecryptedMessage` **message** - * @@ -1745,6 +1762,7 @@ interface messages * Sends a message with a file attachment to a secret chat. * * Parameters: + * * `boolean` **silent** - Optional: * * `InputEncryptedChat` **peer** - Secret chat ID * * `DecryptedMessage` **message** - * * `InputEncryptedFile` **file** - File attachment for the secret chat @@ -1939,7 +1957,7 @@ interface messages * * @param array $params Parameters * - * @return of int[] + * @return messages.MessageViews */ public function getMessagesViews($params); @@ -1973,12 +1991,15 @@ interface messages * Search for messages and peers globally. * * Parameters: - * * `int` **folder_id** - Optional: [Peer folder ID, for more info click here](https://core.telegram.org/api/folders#peer-folders) - * * `string` **q** - Query - * * `int` **offset_rate** - Initially 0, then set to the [`next_rate` parameter of messages.messagesSlice](https://docs.madelineproto.xyz/API_docs/constructors/messages.messagesSlice.html) - * * `InputPeer` **offset_peer** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) - * * `int` **offset_id** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) - * * `int` **limit** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) + * * `int` **folder_id** - Optional: [Peer folder ID, for more info click here](https://core.telegram.org/api/folders#peer-folders) + * * `string` **q** - Query + * * `MessagesFilter` **filter** - + * * `int` **min_date** - + * * `int` **max_date** - + * * `int` **offset_rate** - Initially 0, then set to the [`next_rate` parameter of messages.messagesSlice](https://docs.madelineproto.xyz/API_docs/constructors/messages.messagesSlice.html) + * * `InputPeer` **offset_peer** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) + * * `int` **offset_id** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) + * * `int` **limit** - [Offsets for pagination, for more info click here](https://core.telegram.org/api/offsets) * * @param array $params Parameters * @@ -2145,10 +2166,11 @@ interface messages * Press an inline callback button and get a callback answer from the bot. * * Parameters: - * * `boolean` **game** - Optional: Whether this is a "play game" button - * * `InputPeer` **peer** - Where was the inline keyboard sent - * * `int` **msg_id** - ID of the Message with the inline keyboard - * * `bytes` **data** - Optional: Callback data + * * `boolean` **game** - Optional: Whether this is a "play game" button + * * `InputPeer` **peer** - Where was the inline keyboard sent + * * `int` **msg_id** - ID of the Message with the inline keyboard + * * `bytes` **data** - Optional: Callback data + * * `InputCheckPasswordSRP` **password** - Optional: * * @param array $params Parameters * @@ -2980,6 +3002,53 @@ interface messages * @return messages.FeaturedStickers */ public function getOldFeaturedStickers($params); + + /** + * + * + * Parameters: + * * `InputPeer` **peer** - + * * `int` **msg_id** - + * * `int` **offset_id** - + * * `int` **offset_date** - + * * `int` **add_offset** - + * * `int` **limit** - + * * `int` **max_id** - + * * `int` **min_id** - + * * `[int]` **hash** - Optional:. + * + * @param array $params Parameters + * + * @return messages.Messages + */ + public function getReplies($params); + + /** + * + * + * Parameters: + * * `InputPeer` **peer** - + * * `int` **msg_id** -. + * + * @param array $params Parameters + * + * @return messages.DiscussionMessage + */ + public function getDiscussionMessage($params); + + /** + * + * + * Parameters: + * * `InputPeer` **peer** - + * * `int` **msg_id** - + * * `int` **read_max_id** -. + * + * @param array $params Parameters + * + * @return bool + */ + public function readDiscussion($params); } interface updates @@ -3406,6 +3475,19 @@ interface help * @return bool */ public function dismissSuggestion($params); + + /** + * + * + * Parameters: + * * `string` **lang_code** - + * * `[int]` **hash** - Optional:. + * + * @param array $params Parameters + * + * @return help.CountriesList + */ + public function getCountriesList($params); } interface channels @@ -3666,9 +3748,10 @@ interface channels * Get link and embed info of a message in a [channel/supergroup](https://core.telegram.org/api/channel). * * Parameters: + * * `boolean` **grouped** - Optional: + * * `boolean` **thread** - Optional: * * `InputChannel` **channel** - Channel * * `int` **id** - Message ID - * * `Bool` **grouped** - Whether to include other grouped media (for albums) * * @param array $params Parameters * @@ -4327,6 +4410,37 @@ interface stats * @return stats.MegagroupStats */ public function getMegagroupStats($params); + + /** + * + * + * Parameters: + * * `InputChannel` **channel** - + * * `int` **msg_id** - + * * `int` **offset_rate** - + * * `InputPeer` **offset_peer** - + * * `int` **offset_id** - + * * `int` **limit** -. + * + * @param array $params Parameters + * + * @return messages.Messages + */ + public function getMessagePublicForwards($params); + + /** + * + * + * Parameters: + * * `boolean` **dark** - Optional: + * * `InputChannel` **channel** - + * * `int` **msg_id** -. + * + * @param array $params Parameters + * + * @return stats.MessageStats + */ + public function getMessageStats($params); } class InternalDoc extends APIFactory @@ -5797,6 +5911,17 @@ class InternalDoc extends APIFactory { return $this->API->secretChatStatus($chat); } + /** + * Serialize all instances. + * + * CALLED ONLY ON SHUTDOWN. + * + * @return void + */ + public function serializeAll(): void + { + \danog\MadelineProto\MTProto::serializeAll(); + } /** * Set update handling callback. * diff --git a/src/danog/MadelineProto/Ipc/Server.php b/src/danog/MadelineProto/Ipc/Server.php index dfeb6c079..70472cf8b 100644 --- a/src/danog/MadelineProto/Ipc/Server.php +++ b/src/danog/MadelineProto/Ipc/Server.php @@ -197,7 +197,11 @@ class Server extends SignalLoop $payload[1] = $this->callback->unwrap($wrapper); } $result = $this->API->{$payload[0]}(...$payload[1]); - $result = $result instanceof \Generator ? yield from $result : yield $result; + $result = $result instanceof \Generator + ? yield from $result + : ($result instanceof Promise + ? yield $result + : $result); } catch (\Throwable $e) { $this->API->logger("Got error while calling IPC method: $e", Logger::ERROR); $result = new ExitFailure($e); diff --git a/src/danog/MadelineProto/Loop/Update/FeedLoop.php b/src/danog/MadelineProto/Loop/Update/FeedLoop.php index ea7992b9f..657d0028d 100644 --- a/src/danog/MadelineProto/Loop/Update/FeedLoop.php +++ b/src/danog/MadelineProto/Loop/Update/FeedLoop.php @@ -141,7 +141,7 @@ class FeedLoop extends ResumableSignalLoop $this->incomingUpdates = []; continue; } - if (isset($update['message']['id'], $update['message']['to_id']) && !\in_array($update['_'], ['updateEditMessage', 'updateEditChannelMessage', 'updateMessageID'])) { + if (isset($update['message']['id'], $update['message']['peer_id']) && !\in_array($update['_'], ['updateEditMessage', 'updateEditChannelMessage', 'updateMessageID'])) { if (!$this->API->checkMsgId($update['message'])) { $logger('MSGID duplicate'); continue; @@ -171,7 +171,7 @@ class FeedLoop extends ResumableSignalLoop switch ($update['_']) { case 'updateNewChannelMessage': case 'updateEditChannelMessage': - $channelId = isset($update['message']['to_id']['channel_id']) ? $update['message']['to_id']['channel_id'] : self::GENERIC; + $channelId = isset($update['message']['peer_id']['channel_id']) ? $update['message']['peer_id']['channel_id'] : self::GENERIC; if (!$channelId) { return false; } @@ -207,13 +207,14 @@ class FeedLoop extends ResumableSignalLoop $from = false; $via_bot = false; $entities = false; - if ($update['message']['_'] !== 'messageEmpty' && (($from = isset($update['message']['from_id']) && !(yield from $this->API->peerIsset($update['message']['from_id']))) || ($to = !(yield from $this->API->peerIsset($update['message']['to_id']))) || ($via_bot = isset($update['message']['via_bot_id']) && !(yield from $this->API->peerIsset($update['message']['via_bot_id']))) || ($entities = isset($update['message']['entities']) && !(yield from $this->API->entitiesPeerIsset($update['message']['entities']))))) { + if ($update['message']['_'] !== 'messageEmpty' && (($from = isset($update['message']['from_id']) && !(yield from $this->API->peerIsset($update['message']['from_id']))) || ($to = !(yield from $this->API->peerIsset($update['message']['peer_id']))) || ($via_bot = isset($update['message']['via_bot_id']) && !(yield from $this->API->peerIsset($update['message']['via_bot_id']))) || ($entities = isset($update['message']['entities']) && !(yield from $this->API->entitiesPeerIsset($update['message']['entities']))))) { $log = ''; if ($from) { - $log .= "from_id {$update['message']['from_id']}, "; + $from_id = $this->API->getId($update['message']['from_id']); + $log .= "from_id {$from_id}, "; } if ($to) { - $log .= 'to_id '.\json_encode($update['message']['to_id']).', '; + $log .= 'peer_id '.\json_encode($update['message']['peer_id']).', '; } if ($via_bot) { $log .= "via_bot {$update['message']['via_bot_id']}, "; diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 8b7f7dd38..9f82177fe 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -166,7 +166,7 @@ class MTProto extends AsyncConstruct implements TLCallback */ const SECRET_READY = 2; const GETUPDATES_HANDLER = 'getUpdates'; - const TD_PARAMS_CONVERSION = ['updateNewMessage' => ['_' => 'updateNewMessage', 'disable_notification' => ['message', 'silent'], 'message' => ['message']], 'message' => ['_' => 'message', 'id' => ['id'], 'sender_user_id' => ['from_id'], 'chat_id' => ['to_id', 'choose_chat_id_from_botapi'], 'send_state' => ['choose_incoming_or_sent'], 'can_be_edited' => ['choose_can_edit'], 'can_be_deleted' => ['choose_can_delete'], 'is_post' => ['post'], 'date' => ['date'], 'edit_date' => ['edit_date'], 'forward_info' => ['fwd_info', 'choose_forward_info'], 'reply_to_message_id' => ['reply_to_msg_id'], 'ttl' => ['choose_ttl'], 'ttl_expires_in' => ['choose_ttl_expires_in'], 'via_bot_user_id' => ['via_bot_id'], 'views' => ['views'], 'content' => ['choose_message_content'], 'reply_markup' => ['reply_markup']], 'messages.sendMessage' => ['chat_id' => ['peer'], 'reply_to_message_id' => ['reply_to_msg_id'], 'disable_notification' => ['silent'], 'from_background' => ['background'], 'input_message_content' => ['choose_message_content'], 'reply_markup' => ['reply_markup']]]; + const TD_PARAMS_CONVERSION = ['updateNewMessage' => ['_' => 'updateNewMessage', 'disable_notification' => ['message', 'silent'], 'message' => ['message']], 'message' => ['_' => 'message', 'id' => ['id'], 'sender_user_id' => ['from_id'], 'chat_id' => ['peer_id', 'choose_chat_id_from_botapi'], 'send_state' => ['choose_incoming_or_sent'], 'can_be_edited' => ['choose_can_edit'], 'can_be_deleted' => ['choose_can_delete'], 'is_post' => ['post'], 'date' => ['date'], 'edit_date' => ['edit_date'], 'forward_info' => ['fwd_info', 'choose_forward_info'], 'reply_to_message_id' => ['reply_to_msg_id'], 'ttl' => ['choose_ttl'], 'ttl_expires_in' => ['choose_ttl_expires_in'], 'via_bot_user_id' => ['via_bot_id'], 'views' => ['views'], 'content' => ['choose_message_content'], 'reply_markup' => ['reply_markup']], 'messages.sendMessage' => ['chat_id' => ['peer'], 'reply_to_message_id' => ['reply_to_msg_id'], 'disable_notification' => ['silent'], 'from_background' => ['background'], 'input_message_content' => ['choose_message_content'], 'reply_markup' => ['reply_markup']]]; const TD_REVERSE = ['sendMessage' => 'messages.sendMessage']; const TD_IGNORE = ['updateMessageID']; const BOTAPI_PARAMS_CONVERSION = ['disable_web_page_preview' => 'no_webpage', 'disable_notification' => 'silent', 'reply_to_message_id' => 'reply_to_msg_id', 'chat_id' => 'peer', 'text' => 'message']; diff --git a/src/danog/MadelineProto/MTProtoTools/Files.php b/src/danog/MadelineProto/MTProtoTools/Files.php index 4733c40eb..0a69818df 100644 --- a/src/danog/MadelineProto/MTProtoTools/Files.php +++ b/src/danog/MadelineProto/MTProtoTools/Files.php @@ -633,7 +633,7 @@ trait Files } $res['MessageMedia'] = $messageMedia; $messageMedia = $messageMedia['photo']; - $size = \end($messageMedia['sizes']); + $size = Tools::maxSize($messageMedia['sizes']); $res = \array_merge($res, yield from $this->getDownloadInfo($size)); $res['InputFileLocation'] = ['_' => 'inputPhotoFileLocation', 'thumb_size' => $res['thumb_size'] ?? 'x', 'dc_id' => $messageMedia['dc_id'], 'access_hash' => $messageMedia['access_hash'], 'id' => $messageMedia['id'], 'file_reference' => yield from $this->referenceDatabase->getReference(ReferenceDatabase::PHOTO_LOCATION, $messageMedia)]; return $res; diff --git a/src/danog/MadelineProto/MTProtoTools/MinDatabase.php b/src/danog/MadelineProto/MTProtoTools/MinDatabase.php index bdde393c9..315761285 100644 --- a/src/danog/MadelineProto/MTProtoTools/MinDatabase.php +++ b/src/danog/MadelineProto/MTProtoTools/MinDatabase.php @@ -119,7 +119,7 @@ class MinDatabase implements TLCallback switch ($location['_']) { case 'messageFwdHeader': if (isset($location['from_id'])) { - $peers[$location['from_id']] = true; + $peers[$this->API->getId($location['from_id'])] = true; } if (isset($location['channel_id'])) { $peers[$this->API->toSupergroup($location['channel_id'])] = true; @@ -132,9 +132,9 @@ class MinDatabase implements TLCallback } break; case 'message': - $peers[$this->API->getId($location['to_id'])] = true; + $peers[$this->API->getId($location['peer_id'])] = true; if (isset($location['from_id'])) { - $peers[$location['from_id']] = true; + $peers[$this->API->getId($location['from_id'])] = true; } break; default: diff --git a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php index ce1f28918..1ef3a5639 100644 --- a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php @@ -24,6 +24,7 @@ use danog\Decoder\FileId; use danog\Decoder\PhotoSizeSource\PhotoSizeSourceDialogPhoto; use danog\MadelineProto\Db\DbArray; use danog\MadelineProto\Settings; +use danog\MadelineProto\Tools; use const danog\Decoder\PROFILE_PHOTO; @@ -381,10 +382,13 @@ trait PeerHandler return $this->toSupergroup($id['channel_id']); case 'message': case 'messageService': - if (!isset($id['from_id']) || $id['to_id']['_'] !== 'peerUser' || $id['to_id']['user_id'] !== $this->authorization['user']['id']) { - return $this->getId($id['to_id']); + if (!isset($id['from_id']) + || $id['peer_id']['_'] !== 'peerUser' + || $id['peer_id']['user_id'] !== $this->authorization['user']['id'] + ) { + return $this->getId($id['peer_id']); } - return $id['from_id']; + return $this->getId($id['from_id']); case 'updateChannelReadMessagesContents': case 'updateChannelAvailableMessages': case 'updateChannel': @@ -875,7 +879,7 @@ trait PeerHandler $photo = []; foreach ([ 'small' => $res['photo']['sizes'][0], - 'big' => \end($res['photo']['sizes']), + 'big' => Tools::maxSize($res['photo']['sizes']), ] as $type => $size) { $fileId = new FileId; $fileId->setId($res['photo']['id'] ?? 0); diff --git a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php index 61b41d29f..e2e1e29e7 100644 --- a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php @@ -130,11 +130,11 @@ trait UpdateHandler */ public function checkMsgId(array $message): bool { - if (!isset($message['to_id'])) { + if (!isset($message['peer_id'])) { return true; } try { - $peer_id = $this->getId($message['to_id']); + $peer_id = $this->getId($message['peer_id']); } catch (\danog\MadelineProto\Exception $e) { return true; } catch (\danog\MadelineProto\RPCErrorException $e) { @@ -258,9 +258,9 @@ trait UpdateHandler } $message = $updates; $message['_'] = 'message'; - $message['from_id'] = $from_id; try { - $message['to_id'] = (yield from $this->getInfo($to_id))['Peer']; + $message['from_id'] = (yield from $this->getInfo($from_id))['Peer']; + $message['peer_id'] = (yield from $this->getInfo($to_id))['Peer']; } catch (\danog\MadelineProto\Exception $e) { $this->logger->logger('Still did not get user in database, postponing update', \danog\MadelineProto\Logger::ERROR); //$this->pending_updates[] = $updates; @@ -409,7 +409,7 @@ trait UpdateHandler if (isset($update['message']['_']) && $update['message']['_'] === 'messageEmpty') { return; } - if (isset($update['message']['from_id']) && $update['message']['from_id'] === $this->authorization['user']['id']) { + if (isset($update['message']['from_id']['user_id']) && $update['message']['from_id']['user_id'] === $this->authorization['user']['id']) { $update['message']['out'] = true; } // First save to array, then once the feed loop signals resumal of loop, resume and handle diff --git a/src/danog/MadelineProto/Settings/TLSchema.php b/src/danog/MadelineProto/Settings/TLSchema.php index 2a17c334f..53958df35 100644 --- a/src/danog/MadelineProto/Settings/TLSchema.php +++ b/src/danog/MadelineProto/Settings/TLSchema.php @@ -9,7 +9,7 @@ class TLSchema extends SettingsAbstract /** * TL layer version. */ - protected int $layer = 117; + protected int $layer = 119; /** * MTProto schema path. */ @@ -17,7 +17,7 @@ class TLSchema extends SettingsAbstract /** * API schema path. */ - protected string $APISchema = __DIR__.'/../TL_telegram_v117.tl'; + protected string $APISchema = __DIR__.'/../TL_telegram_v119.tl'; /** * Secret schema path. */ @@ -53,8 +53,8 @@ class TLSchema extends SettingsAbstract */ public function __wakeup() { - if (!\file_exists($this->APISchema) // Scheme was upgraded - && $this->APISchema !== __DIR__.'/../TL_mtproto_v117.tl' // Session path has changed + if (!\file_exists($this->APISchema) // Scheme was upgraded + || $this->APISchema !== __DIR__.'/../TL_telegram_v119.tl' // Session path has changed ) { $new = new self; $this->setAPISchema($new->getAPISchema()); diff --git a/src/danog/MadelineProto/TL/Conversion/BotAPI.php b/src/danog/MadelineProto/TL/Conversion/BotAPI.php index ca489bcae..0aec9a779 100644 --- a/src/danog/MadelineProto/TL/Conversion/BotAPI.php +++ b/src/danog/MadelineProto/TL/Conversion/BotAPI.php @@ -221,7 +221,7 @@ trait BotAPI if (isset($data['from_id'])) { $newd['from'] = (yield from $this->getPwrChat($data['from_id'])); } - $newd['chat'] = (yield from $this->getPwrChat($data['to_id'])); + $newd['chat'] = (yield from $this->getPwrChat($data['peer_id'])); if (isset($data['entities'])) { $newd['entities'] = (yield from $this->MTProtoToBotAPI($data['entities'])); } diff --git a/src/danog/MadelineProto/TL/Conversion/TD.php b/src/danog/MadelineProto/TL/Conversion/TD.php index 7366c8b35..b9dcc7064 100644 --- a/src/danog/MadelineProto/TL/Conversion/TD.php +++ b/src/danog/MadelineProto/TL/Conversion/TD.php @@ -122,7 +122,7 @@ trait TD } else { switch (\end($mtproto)) { case 'choose_chat_id_from_botapi': - $newparams[$td] = (yield from $this->getInfo($params[$mtproto[0]]))['bot_api_id'] == $this->authorization['user']['id'] ? $params['from_id'] : (yield from $this->getInfo($params[$mtproto[0]])['bot_api_id']); + $newparams[$td] = (yield from $this->getInfo($params[$mtproto[0]]))['bot_api_id'] == $this->authorization['user']['id'] ? $this->getId($params['from_id']) : (yield from $this->getInfo($params[$mtproto[0]])['bot_api_id']); break; case 'choose_incoming_or_sent': $newparams[$td] = ['_' => $params['out'] ? 'messageIsSuccessfullySent' : 'messageIsIncoming']; @@ -144,7 +144,7 @@ trait TD $newparams[$td]['channel_post'] = $params['fwd_from']['channel_post']; } if (isset($params['fwd_from']['from_id'])) { - $newparams[$td]['sender_user_id'] = $params['fwd_from']['from_id']; + $newparams[$td]['sender_user_id'] = $this->getId($params['fwd_from']['from_id']); } } else { $newparams[$td] = null; diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index 75553a5ea..6d27d284c 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -143,12 +143,12 @@ class TL $this->tdConstructors = new TLConstructors(); $this->tdMethods = new TLMethods(); $this->tdDescriptions = ['types' => [], 'constructors' => [], 'methods' => []]; - foreach ([ + foreach (\array_filter([ 'api' => $files->getAPISchema(), 'mtproto' => $files->getMTProtoSchema(), 'secret' => $files->getSecretSchema(), ...$files->getOther() - ] as $scheme_type => $file) { + ]) as $scheme_type => $file) { $this->API->logger->logger(\sprintf(\danog\MadelineProto\Lang::$current_lang['file_parsing'], \basename($file)), \danog\MadelineProto\Logger::VERBOSE); $filec = \file_get_contents(Tools::absolute($file)); $TL_dict = \json_decode($filec, true); diff --git a/src/danog/MadelineProto/TL/Types/Button.php b/src/danog/MadelineProto/TL/Types/Button.php index e312b2325..54c446627 100644 --- a/src/danog/MadelineProto/TL/Types/Button.php +++ b/src/danog/MadelineProto/TL/Types/Button.php @@ -52,7 +52,12 @@ class Button implements \JsonSerializable, \ArrayAccess public function __construct(MTProto $API, array $message, array $button) { $this->button = $button; - $this->peer = $message['to_id'] === ['_' => 'peerUser', 'user_id' => $API->authorization['user']['id']] ? $message['from_id'] : $message['to_id']; + $this->peer = $message['peer_id'] === [ + '_' => 'peerUser', + 'user_id' => $API->authorization['user']['id'] + ] + ? $message['from_id'] + : $message['peer_id']; $this->id = $message['id']; $this->API = $API; } diff --git a/src/danog/MadelineProto/TL_telegram_v117.tl b/src/danog/MadelineProto/TL_telegram_v119.tl similarity index 94% rename from src/danog/MadelineProto/TL_telegram_v117.tl rename to src/danog/MadelineProto/TL_telegram_v119.tl index efe1a79fa..ce2e3b0b7 100644 --- a/src/danog/MadelineProto/TL_telegram_v117.tl +++ b/src/danog/MadelineProto/TL_telegram_v119.tl @@ -128,7 +128,7 @@ channel#d31a961e flags:# creator:flags.0?true left:flags.2?true broadcast:flags. channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat; chatFull#1b7c9db3 flags:# can_set_username:flags.7?true has_scheduled:flags.8?true id:int about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int = ChatFull; -channelFull#f0e6672a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int = ChatFull; +channelFull#f0e6672a flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true id:int about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?int migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?int location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int = ChatFull; chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant; chatParticipantCreator#da13538a user_id:int = ChatParticipant; @@ -141,8 +141,8 @@ chatPhotoEmpty#37c1011c = ChatPhoto; chatPhoto#d20b9f3c flags:# has_video:flags.0?true photo_small:FileLocation photo_big:FileLocation dc_id:int = ChatPhoto; messageEmpty#83e5de54 id:int = Message; -message#452c0e65 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true id:int from_id:flags.8?int to_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to_msg_id:flags.3?int date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long restriction_reason:flags.22?Vector = Message; -messageService#9e19a1f6 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?int to_id:Peer reply_to_msg_id:flags.3?int date:int action:MessageAction = Message; +message#58ae39c9 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long restriction_reason:flags.22?Vector = Message; +messageService#286fa604 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction = Message; messageMediaEmpty#3ded6320 = MessageMedia; messageMediaPhoto#695150d7 flags:# photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia; @@ -192,6 +192,7 @@ photoSizeEmpty#e17e23c type:string = PhotoSize; photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize; photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; photoStrippedSize#e0b0bc2e type:string bytes:bytes = PhotoSize; +photoSizeProgressive#5aa86a51 type:string location:FileLocation w:int h:int sizes:Vector = PhotoSize; geoPointEmpty#1117dd5f = GeoPoint; geoPoint#296f104 long:double lat:double access_hash:long = GeoPoint; @@ -231,8 +232,6 @@ contact#f911c994 user_id:int mutual:Bool = Contact; importedContact#d0028438 user_id:int client_id:long = ImportedContact; -contactBlocked#561bc879 user_id:int date:int = ContactBlocked; - contactStatus#d3680c61 user_id:int status:UserStatus = ContactStatus; contacts.contactsNotModified#b74ba9d2 = contacts.Contacts; @@ -240,8 +239,8 @@ contacts.contacts#eae87e42 contacts:Vector saved_count:int users:Vector contacts.importedContacts#77d01c3b imported:Vector popular_invites:Vector retry_contacts:Vector users:Vector = contacts.ImportedContacts; -contacts.blocked#1c138d15 blocked:Vector users:Vector = contacts.Blocked; -contacts.blockedSlice#900802a1 count:int blocked:Vector users:Vector = contacts.Blocked; +contacts.blocked#ade1591 blocked:Vector chats:Vector users:Vector = contacts.Blocked; +contacts.blockedSlice#e1664194 count:int blocked:Vector chats:Vector users:Vector = contacts.Blocked; messages.dialogs#15ba6c40 dialogs:Vector messages:Vector chats:Vector users:Vector = messages.Dialogs; messages.dialogsSlice#71e094f3 count:int dialogs:Vector messages:Vector chats:Vector users:Vector = messages.Dialogs; @@ -292,7 +291,6 @@ updateEncryptedMessagesRead#38fe25b7 chat_id:int max_date:int date:int = Update; updateChatParticipantAdd#ea4b0e5c chat_id:int user_id:int inviter_id:int date:int version:int = Update; updateChatParticipantDelete#6e5f8c22 chat_id:int user_id:int version:int = Update; updateDcOptions#8e5e9873 dc_options:Vector = Update; -updateUserBlocked#80ece81a user_id:int blocked:Bool = Update; updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings = Update; updateServiceNotification#ebe46819 flags:# popup:flags.0?true inbox_date:flags.1?int type:string message:string media:MessageMedia entities:Vector = Update; updatePrivacy#ee3b272a key:PrivacyKey rules:Vector = Update; @@ -358,6 +356,11 @@ updateDialogFilterOrder#a5d72105 order:Vector = Update; updateDialogFilters#3504914f = Update; updatePhoneCallSignalingData#2661bf09 phone_call_id:long data:bytes = Update; updateChannelParticipant#65d2b464 flags:# channel_id:int date:int user_id:int prev_participant:flags.0?ChannelParticipant new_participant:flags.1?ChannelParticipant qts:int = Update; +updateChannelMessageForwards#6e8a84df channel_id:int id:int forwards:int = Update; +updateReadChannelDiscussionInbox#1cc7de54 flags:# channel_id:int top_msg_id:int read_max_id:int broadcast_id:flags.0?int broadcast_post:flags.0?int = Update; +updateReadChannelDiscussionOutbox#4638a26c channel_id:int top_msg_id:int read_max_id:int = Update; +updatePeerBlocked#246a4b22 peer_id:Peer blocked:Bool = Update; +updateChannelUserTyping#ff2abe9f flags:# channel_id:int top_msg_id:flags.0?int user_id:int action:SendMessageAction = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -367,8 +370,8 @@ updates.differenceSlice#a8fb1981 new_messages:Vector new_encrypted_mess updates.differenceTooLong#4afe8f6d pts:int = updates.Difference; updatesTooLong#e317af7e = Updates; -updateShortMessage#914fbf11 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true id:int user_id:int message:string pts:int pts_count:int date:int fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to_msg_id:flags.3?int entities:flags.7?Vector = Updates; -updateShortChatMessage#16812688 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true id:int from_id:int chat_id:int message:string pts:int pts_count:int date:int fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to_msg_id:flags.3?int entities:flags.7?Vector = Updates; +updateShortMessage#2296d2c8 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true id:int user_id:int message:string pts:int pts_count:int date:int fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to:flags.3?MessageReplyHeader entities:flags.7?Vector = Updates; +updateShortChatMessage#402d5dbb flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true id:int from_id:int chat_id:int message:string pts:int pts_count:int date:int fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to:flags.3?MessageReplyHeader entities:flags.7?Vector = Updates; updateShort#78d4dec1 update:Update date:int = Updates; updatesCombined#725b04c3 updates:Vector users:Vector chats:Vector date:int seq_start:int seq:int = Updates; updates#74ae4240 updates:Vector users:Vector chats:Vector date:int seq:int = Updates; @@ -547,7 +550,7 @@ botInfo#98e81d3a user_id:int description:string commands:Vector = Bo keyboardButton#a2fa4880 text:string = KeyboardButton; keyboardButtonUrl#258aff05 text:string url:string = KeyboardButton; -keyboardButtonCallback#683a5e46 text:string data:bytes = KeyboardButton; +keyboardButtonCallback#35bbdb6b flags:# requires_password:flags.0?true text:string data:bytes = KeyboardButton; keyboardButtonRequestPhone#b16a6c29 text:string = KeyboardButton; keyboardButtonRequestGeoLocation#fc796b3f text:string = KeyboardButton; keyboardButtonSwitchInline#568a748 flags:# same_peer:flags.0?true text:string query:string = KeyboardButton; @@ -601,7 +604,7 @@ channelMessagesFilter#cd77d957 flags:# exclude_new_messages:flags.1?true ranges: channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant; channelParticipantSelf#a3289a6d user_id:int inviter_id:int date:int = ChannelParticipant; -channelParticipantCreator#808d15a4 flags:# user_id:int rank:flags.0?string = ChannelParticipant; +channelParticipantCreator#447dca4b flags:# user_id:int admin_rights:ChatAdminRights rank:flags.0?string = ChannelParticipant; channelParticipantAdmin#ccbebbaf flags:# can_edit:flags.0?true self:flags.1?true user_id:int inviter_id:flags.1?int promoted_by:int date:int admin_rights:ChatAdminRights rank:flags.2?string = ChannelParticipant; channelParticipantBanned#1c0facaf flags:# left:flags.0?true user_id:int kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant; @@ -648,7 +651,7 @@ messages.botResults#947ca848 flags:# gallery:flags.0?true query_id:long next_off exportedMessageLink#5dab1af4 link:string html:string = ExportedMessageLink; -messageFwdHeader#353a686b flags:# from_id:flags.0?int from_name:flags.5?string date:int channel_id:flags.1?int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int psa_type:flags.6?string = MessageFwdHeader; +messageFwdHeader#5f777dce flags:# from_id:flags.0?Peer from_name:flags.5?string date:int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int psa_type:flags.6?string = MessageFwdHeader; auth.codeTypeSms#72a3158c = auth.CodeType; auth.codeTypeCall#741cd3e3 = auth.CodeType; @@ -1029,7 +1032,7 @@ chatOnlines#f041e250 onlines:int = ChatOnlines; statsURL#47a971e0 url:string = StatsURL; -chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true = ChatAdminRights; +chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true = ChatAdminRights; chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true until_date:int = ChatBannedRights; @@ -1150,6 +1153,27 @@ stats.megagroupStats#ef7ff916 period:StatsDateRangeDays members:StatsAbsValueAnd globalPrivacySettings#bea2f424 flags:# archive_and_mute_new_noncontact_peers:flags.0?Bool = GlobalPrivacySettings; +help.countryCode#4203c5ef flags:# country_code:string prefixes:flags.0?Vector patterns:flags.1?Vector = help.CountryCode; + +help.country#c3878e23 flags:# hidden:flags.0?true iso2:string default_name:string name:flags.1?string country_codes:Vector = help.Country; + +help.countriesListNotModified#93cc1f32 = help.CountriesList; +help.countriesList#87d0759e countries:Vector hash:int = help.CountriesList; + +messageViews#455b853d flags:# views:flags.0?int forwards:flags.1?int replies:flags.2?MessageReplies = MessageViews; + +messages.messageViews#b6c4f543 views:Vector chats:Vector users:Vector = messages.MessageViews; + +stats.messageStats#8999f295 views_graph:StatsGraph = stats.MessageStats; + +messages.discussionMessage#f5dd8f9d flags:# messages:Vector max_id:flags.0?int read_inbox_max_id:flags.1?int read_outbox_max_id:flags.2?int chats:Vector users:Vector = messages.DiscussionMessage; + +messageReplyHeader#a6d57763 flags:# reply_to_msg_id:int reply_to_peer_id:flags.0?Peer reply_to_top_id:flags.1?int = MessageReplyHeader; + +messageReplies#4128faac flags:# comments:flags.0?true replies:int replies_pts:int recent_repliers:flags.1?Vector channel_id:flags.0?int max_id:flags.2?int read_max_id:flags.3?int = MessageReplies; + +peerBlocked#e8fd8014 peer_id:Peer date:int = PeerBlocked; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1257,8 +1281,8 @@ contacts.getContacts#c023849f hash:int = contacts.Contacts; contacts.importContacts#2c800be5 contacts:Vector = contacts.ImportedContacts; contacts.deleteContacts#96a0e00 id:Vector = Updates; contacts.deleteByPhones#1013fd9e phones:Vector = Bool; -contacts.block#332b49fc id:InputUser = Bool; -contacts.unblock#e54100bd id:InputUser = Bool; +contacts.block#68cc1411 id:InputPeer = Bool; +contacts.unblock#bea65d50 id:InputPeer = Bool; contacts.getBlocked#f57c350f offset:int limit:int = contacts.Blocked; contacts.search#11f812d8 q:string limit:int = contacts.Found; contacts.resolveUsername#f93ccba3 username:string = contacts.ResolvedPeer; @@ -1270,19 +1294,20 @@ contacts.toggleTopPeers#8514bdda enabled:Bool = Bool; contacts.addContact#e8f463d0 flags:# add_phone_privacy_exception:flags.0?true id:InputUser first_name:string last_name:string phone:string = Updates; contacts.acceptContact#f831a20f id:InputUser = Updates; contacts.getLocated#d348bc44 flags:# background:flags.1?true geo_point:InputGeoPoint self_expires:flags.0?int = Updates; +contacts.blockFromReplies#29a8962c flags:# delete_message:flags.0?true delete_history:flags.1?true report_spam:flags.2?true msg_id:int = Updates; messages.getMessages#63c66506 id:Vector = messages.Messages; messages.getDialogs#a0ee3b73 flags:# exclude_pinned:flags.0?true folder_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:int = messages.Dialogs; messages.getHistory#dcbb8260 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; -messages.search#8614ef68 flags:# peer:InputPeer q:string from_id:flags.0?InputUser filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; +messages.search#4e17810b flags:# peer:InputPeer q:string from_id:flags.0?InputUser top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages; messages.deleteHistory#1c015b09 flags:# just_clear:flags.0?true revoke:flags.1?true peer:InputPeer max_id:int = messages.AffectedHistory; messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector = messages.AffectedMessages; messages.receivedMessages#5a954c0 max_id:int = Vector; -messages.setTyping#a3825e50 peer:InputPeer action:SendMessageAction = Bool; +messages.setTyping#58943ee2 flags:# peer:InputPeer top_msg_id:flags.0?int action:SendMessageAction = Bool; messages.sendMessage#520c3870 flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int = Updates; messages.sendMedia#3491eba9 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int = Updates; -messages.forwardMessages#d9fee60e flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true grouped:flags.9?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer schedule_date:flags.10?int = Updates; +messages.forwardMessages#d9fee60e flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer schedule_date:flags.10?int = Updates; messages.reportSpam#cf1592db peer:InputPeer = Bool; messages.getPeerSettings#3672e09c peer:InputPeer = PeerSettings; messages.report#bd82b658 peer:InputPeer id:Vector reason:ReportReason = Bool; @@ -1299,8 +1324,8 @@ messages.acceptEncryption#3dbc0415 peer:InputEncryptedChat g_b:bytes key_fingerp messages.discardEncryption#edd923c5 chat_id:int = Bool; messages.setEncryptedTyping#791451ed peer:InputEncryptedChat typing:Bool = Bool; messages.readEncryptedHistory#7f4b690a peer:InputEncryptedChat max_date:int = Bool; -messages.sendEncrypted#a9776773 peer:InputEncryptedChat random_id:long data:bytes = messages.SentEncryptedMessage; -messages.sendEncryptedFile#9a901b66 peer:InputEncryptedChat random_id:long data:bytes file:InputEncryptedFile = messages.SentEncryptedMessage; +messages.sendEncrypted#44fa7a15 flags:# silent:flags.0?true peer:InputEncryptedChat random_id:long data:bytes = messages.SentEncryptedMessage; +messages.sendEncryptedFile#5559481d flags:# silent:flags.0?true peer:InputEncryptedChat random_id:long data:bytes file:InputEncryptedFile = messages.SentEncryptedMessage; messages.sendEncryptedService#32d439a4 peer:InputEncryptedChat random_id:long data:bytes = messages.SentEncryptedMessage; messages.receivedQueue#55a5bb66 max_qts:int = Vector; messages.reportEncryptedSpam#4b0c8c0f peer:InputEncryptedChat = Bool; @@ -1315,10 +1340,10 @@ messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet messages.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = messages.StickerSetInstallResult; messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool; messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_param:string = Updates; -messages.getMessagesViews#c4c8a55d peer:InputPeer id:Vector increment:Bool = Vector; +messages.getMessagesViews#5784d3e1 peer:InputPeer id:Vector increment:Bool = messages.MessageViews; messages.editChatAdmin#a9e69f2e chat_id:int user_id:InputUser is_admin:Bool = Bool; messages.migrateChat#15a3b8e3 chat_id:int = Updates; -messages.searchGlobal#bf7225a4 flags:# folder_id:flags.0?int q:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; +messages.searchGlobal#4bc6589a flags:# folder_id:flags.0?int q:string filter:MessagesFilter min_date:int max_date:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; messages.reorderStickerSets#78337739 flags:# masks:flags.0?true order:Vector = Bool; messages.getDocumentByHash#338e2464 sha256:bytes size:int mime_type:string = Document; messages.getSavedGifs#83bf3d52 hash:int = messages.SavedGifs; @@ -1329,7 +1354,7 @@ messages.sendInlineBotResult#220815b0 flags:# silent:flags.5?true background:fla messages.getMessageEditData#fda68d36 peer:InputPeer id:int = messages.MessageEditData; messages.editMessage#48f71778 flags:# no_webpage:flags.1?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.15?int = Updates; messages.editInlineBotMessage#83557dba flags:# no_webpage:flags.1?true id:InputBotInlineMessageID message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector = Bool; -messages.getBotCallbackAnswer#810a9fec flags:# game:flags.1?true peer:InputPeer msg_id:int data:flags.0?bytes = messages.BotCallbackAnswer; +messages.getBotCallbackAnswer#9342ca07 flags:# game:flags.1?true peer:InputPeer msg_id:int data:flags.0?bytes password:flags.2?InputCheckPasswordSRP = messages.BotCallbackAnswer; messages.setBotCallbackAnswer#d58f130a flags:# alert:flags.1?true query_id:long message:flags.0?string url:flags.2?string cache_time:int = Bool; messages.getPeerDialogs#e470bcfd peers:Vector = messages.PeerDialogs; messages.saveDraft#bc39e14b flags:# no_webpage:flags.1?true reply_to_msg_id:flags.0?int peer:InputPeer message:string entities:flags.3?Vector = Bool; @@ -1394,6 +1419,9 @@ messages.getSuggestedDialogFilters#a29cd42c = Vector; messages.updateDialogFilter#1ad4a04a flags:# id:int filter:flags.0?DialogFilter = Bool; messages.updateDialogFiltersOrder#c563c1e4 order:Vector = Bool; messages.getOldFeaturedStickers#5fe7025b offset:int limit:int hash:int = messages.FeaturedStickers; +messages.getReplies#24b581ba peer:InputPeer msg_id:int offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; +messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage; +messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -1434,6 +1462,7 @@ help.editUserInfo#66b91b70 user_id:InputUser message:string entities:Vector = messages.AffectedMessages; @@ -1454,7 +1483,7 @@ channels.joinChannel#24b524c5 channel:InputChannel = Updates; channels.leaveChannel#f836aa95 channel:InputChannel = Updates; channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector = Updates; channels.deleteChannel#c0111fe3 channel:InputChannel = Updates; -channels.exportMessageLink#ceb77163 channel:InputChannel id:int grouped:Bool = ExportedMessageLink; +channels.exportMessageLink#e63fadeb flags:# grouped:flags.0?true thread:flags.1?true channel:InputChannel id:int = ExportedMessageLink; channels.toggleSignatures#1f69b606 channel:InputChannel enabled:Bool = Updates; channels.getAdminedPublicChannels#f8b036af flags:# by_location:flags.0?true check_limit:flags.1?true = messages.Chats; channels.editBanned#72796912 channel:InputChannel user_id:InputUser banned_rights:ChatBannedRights = Updates; @@ -1511,5 +1540,7 @@ folders.deleteFolder#1c295881 folder_id:int = Updates; stats.getBroadcastStats#ab42441a flags:# dark:flags.0?true channel:InputChannel = stats.BroadcastStats; stats.loadAsyncGraph#621d5fa0 flags:# token:string x:flags.0?long = StatsGraph; stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel = stats.MegagroupStats; +stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; +stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; -// LAYER 117 +// LAYER 119 diff --git a/src/danog/MadelineProto/Tools.php b/src/danog/MadelineProto/Tools.php index d537b7176..dde4329a1 100644 --- a/src/danog/MadelineProto/Tools.php +++ b/src/danog/MadelineProto/Tools.php @@ -839,6 +839,29 @@ abstract class Tools extends StrTools $header[165] = $stripped[2]; return $header.\substr($stripped, 3).$footer; } + /** + * Get maximum photo size. + * + * @internal + * + * @param array $sizes + * @return array + */ + public static function maxSize(array $sizes): array + { + $maxPixels = 0; + $max = null; + foreach ($sizes as $size) { + if (isset($size['w'], $size['h'])) { + $curPixels = $size['w'] * $size['h']; + if ($curPixels > $maxPixels) { + $maxPixels = $curPixels; + $max = $size; + } + } + } + return $max; + } /** * Get final element of array. * diff --git a/tools/build_docs.php b/tools/build_docs.php index ee36b53e9..6875645a5 100755 --- a/tools/build_docs.php +++ b/tools/build_docs.php @@ -40,10 +40,10 @@ $logger->logger('Upgrading layer...', Logger::NOTICE); $layer = maxLayer($schemas); layerUpgrade($layer); -$logger->logger('Initing docs...', Logger::NOTICE); +$logger->logger("Initing docs (layer $layer)...", Logger::NOTICE); $docs = [ [ - 'tl_schema' => ['mtproto' => "$d/schemas/TL_mtproto_v1.tl"], + 'tl_schema' => ['mtproto' => "$d/schemas/TL_mtproto_v1.tl", 'telegram' => '', 'secret' => ''], 'title' => 'MadelineProto API documentation (mtproto)', 'description' => 'MadelineProto API documentation (mtproto)', 'output_dir' => "$d/docs/docs/MTProto_docs", @@ -51,7 +51,7 @@ $docs = [ 'readme' => false, ], [ - 'tl_schema' => ['telegram' => "$d/schemas/TL_telegram_v$layer.tl", 'secret' => "$d/schemas/TL_secret.tl", 'td' => "$d/schemas/TL_td.tl"], + 'tl_schema' => ['mtproto' => '', 'telegram' => "$d/schemas/TL_telegram_v$layer.tl", 'secret' => "$d/schemas/TL_secret.tl", 'td' => "$d/schemas/TL_td.tl"], 'title' => "MadelineProto API documentation (layer $layer)", 'description' => "MadelineProto API documentation (layer $layer)", 'output_dir' => "$d/docs/docs/API_docs", diff --git a/tools/build_docs/layerUpgrade.php b/tools/build_docs/layerUpgrade.php index 0a63d7236..a903f6feb 100644 --- a/tools/build_docs/layerUpgrade.php +++ b/tools/build_docs/layerUpgrade.php @@ -29,13 +29,14 @@ function layerUpgrade(int $layer): void $doc = \str_replace( [ "layer = $prevLayer", - "TL_telegram_$prevLayer", + "TL_telegram_v$prevLayer", ], [ "layer = $layer", - "TL_telegram_$layer", + "TL_telegram_v$layer", ], $doc ); - \file_put_contents('src/danog/MadelineProto/MTProto.php', $doc); + + \file_put_contents('src/danog/MadelineProto/Settings/TLSchema.php', $doc); } diff --git a/tools/build_docs/schemas.php b/tools/build_docs/schemas.php index 169d829b0..08bb60b24 100644 --- a/tools/build_docs/schemas.php +++ b/tools/build_docs/schemas.php @@ -43,7 +43,7 @@ function initDocs(array $layers): array foreach (\array_slice($layers, 0, -1) as $layer => $file) { $layer = "v$layer"; $docs[] = [ - 'tl_schema' => ['telegram' => $file], + 'tl_schema' => ['telegram' => $file, 'mtproto' => '', 'secret' => '', 'td' => ''], 'title' => 'MadelineProto API documentation (layer '.$layer.')', 'description' => 'MadelineProto API documentation (layer '.$layer.')', 'output_dir' => \getcwd()."/docs/old_docs/API_docs_".$layer,