diff --git a/docs b/docs
index 57562236..96003158 160000
--- a/docs
+++ b/docs
@@ -1 +1 @@
-Subproject commit 57562236aade5d13a01c18a2290aa647686eebd5
+Subproject commit 9600315809337a79a88c7d878c7ce4ca16e29603
diff --git a/examples/bot.php b/examples/bot.php
index 9c622fba..24f70816 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 a878ff05..8fd40f0a 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 e6a1e209..e53c5a72 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 dfeb6c07..70472cf8 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 ea7992b9..657d0028 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 8b7f7dd3..9f82177f 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 4733c40e..0a69818d 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 bdde393c..31576128 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 ce1f2891..1ef3a563 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 61b41d29..e2e1e29e 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 2a17c334..53958df3 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 ca489bca..0aec9a77 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 7366c8b3..b9dcc706 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 75553a5e..6d27d284 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 e312b232..54c44662 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 efe1a79f..ce2e3b0b 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