1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-26 17:24:40 +01:00

Add takeout ID to API

This commit is contained in:
Daniil Gentili 2023-12-23 22:13:17 +01:00
parent 2ede60bd42
commit 73adf72434
12 changed files with 43 additions and 12 deletions

2
docs

@ -1 +1 @@
Subproject commit 3aa2a561f9640cfab993c92966d48f3d21c72534
Subproject commit 67fa718adb58bde054db590b0ad6eb8201c4b15a

View File

@ -335,6 +335,12 @@ final class Blacklist {
$params = $this->filterParams($params, $type, $method);
$contents = '';
$signature = [];
if (\in_array($method, ['messages.getSplitRanges', 'contacts.getSaved', 'channels.getLeftChannels'], true)) {
$contents .= " * @param int \$takeoutId Takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.\n";
$signature []= "int \$takeoutId";
}
foreach ($params as $name => $param) {
if ($name === 'reply_to') {
$param['pow'] ??= 'yes';
@ -374,6 +380,13 @@ final class Blacklist {
$signature []= "?string \$queueId = null";
$contents .= " * @param ?\\Amp\\Cancellation \$cancellation Cancellation\n";
$signature []= "?\\Amp\\Cancellation \$cancellation = null";
// TODO users.getUsers
if (\in_array($method, ['messages.getDialogs', 'messages.getHistory', 'messages.search', 'stories.getStoriesArchive', 'photos.getUserPhotos', 'account.getAuthorizations', 'account.getWebAuthorizations'], true)) {
$contents .= " * @param ?int \$takeoutId Optional takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.\n";
$signature []= "?int \$takeoutId = null";
}
return [$contents, $signature];
}
/**

View File

@ -560,6 +560,12 @@ final class Connection
try {
if ($message->isMethod) {
$body = $this->API->getTL()->serializeMethod($message->constructor, $body);
if ($message->takeoutId !== null) {
$body = $this->API->getTL()->serializeMethod(
'invokeWithTakeout',
['takeout_id' => $message->takeoutId, 'query' => $body],
);
}
} else {
$body['_'] = $message->constructor;
$body = $this->API->getTL()->serializeObject(['type' => ''], $body, $message->constructor);

View File

@ -121,6 +121,7 @@ class MTProtoOutgoingMessage extends MTProtoMessage
* Custom flood wait limit for this message.
*/
public readonly ?int $floodWaitLimit = null,
public readonly ?int $takeoutId = null,
private ?DeferredFuture $resultDeferred = null,
public readonly ?Cancellation $cancellation = null
) {

View File

@ -175,6 +175,7 @@ trait CallHandler
floodWaitLimit: $args['floodWaitLimit'] ?? null,
resultDeferred: $response,
cancellation: $cancellation,
takeoutId: $args['takeoutId'] ?? null
);
if ($queueId !== null) {
$this->callQueue[$queueId] = $message;

View File

@ -231,9 +231,10 @@ interface Account
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?int $takeoutId Optional takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @return array{_: 'account.authorizations', authorization_ttl_days: int, authorizations: list<array{_: 'authorization', current: bool, official_app: bool, password_pending: bool, encrypted_requests_disabled: bool, call_requests_disabled: bool, unconfirmed: bool, hash: list<int>, device_model: string, platform: string, system_version: string, api_id: int, app_name: string, app_version: string, date_created: int, date_active: int, ip: string, country: string, region: string}>} @see https://docs.madelineproto.xyz/API_docs/types/account.Authorizations.html
*/
public function getAuthorizations(?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getAuthorizations(?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?int $takeoutId = null): array;
/**
* Log out an active [authorized session](https://core.telegram.org/api/auth) by its hash.
@ -296,9 +297,10 @@ interface Account
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?int $takeoutId Optional takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @return array{_: 'account.webAuthorizations', authorizations: list<array{_: 'webAuthorization', hash: list<int>, bot_id: int, domain: string, browser: string, platform: string, date_created: int, date_active: int, ip: string, region: string}>, users: list<array|int|string>} @see https://docs.madelineproto.xyz/API_docs/types/account.WebAuthorizations.html
*/
public function getWebAuthorizations(?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getWebAuthorizations(?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?int $takeoutId = null): array;
/**
* Log out an active web [telegram login](https://core.telegram.org/widgets/login) session.

View File

@ -327,13 +327,14 @@ interface Channels
/**
* Get a list of [channels/supergroups](https://core.telegram.org/api/channel) we left.
*
* @param int $takeoutId Takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @param int $offset Offset for [pagination](https://core.telegram.org/api/offsets)
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @return array{_: 'messages.chats', chats: list<array|int|string>}|array{_: 'messages.chatsSlice', count: int, chats: list<array|int|string>} @see https://docs.madelineproto.xyz/API_docs/types/messages.Chats.html
*/
public function getLeftChannels(int|null $offset = 0, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getLeftChannels(int $takeoutId, int|null $offset = 0, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
/**
* Get all groups that can be used as [discussion groups](https://core.telegram.org/api/discussion).

View File

@ -166,12 +166,13 @@ interface Contacts
/**
* Get all contacts.
*
* @param int $takeoutId Takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @return list<array{_: 'savedPhoneContact', phone: string, first_name: string, last_name: string, date: int}> Array of @see https://docs.madelineproto.xyz/API_docs/types/SavedContact.html
*/
public function getSaved(?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getSaved(int $takeoutId, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
/**
* Enable/disable [top peers](https://core.telegram.org/api/top-rating).

View File

@ -33,9 +33,10 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?int $takeoutId Optional takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @return array{_: 'messages.dialogs', dialogs: list<array>, messages: list<array>, chats: list<array>, users: list<array>}|array{_: 'messages.dialogsSlice', count: array, dialogs: list<array>, messages: list<array>, chats: list<array>, users: list<array>}|array{_: 'messages.dialogsNotModified', count: array} @see https://docs.madelineproto.xyz/API_docs/types/messages.Dialogs.html
*/
public function getDialogs(bool|null $exclude_pinned = null, int|null $folder_id = null, int|null $offset_date = 0, int|null $offset_id = 0, array|int|string|null $offset_peer = null, int|null $limit = 0, array $hash = [], ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getDialogs(bool|null $exclude_pinned = null, int|null $folder_id = null, int|null $offset_date = 0, int|null $offset_id = 0, array|int|string|null $offset_peer = null, int|null $limit = 0, array $hash = [], ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?int $takeoutId = null): array;
/**
* Returns the conversation history with one interlocutor / within a chat.
@ -51,9 +52,10 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?int $takeoutId Optional takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @return array{_: 'messages.messages', messages: list<array>, chats: list<array>, users: list<array>}|array{_: 'messages.messagesSlice', inexact: array, count: array, next_rate?: array, offset_id_offset?: array, messages: list<array>, chats: list<array>, users: list<array>}|array{_: 'messages.channelMessages', inexact: array, pts: array, count: array, offset_id_offset?: array, messages: list<array>, topics: list<array>, chats: list<array>, users: list<array>}|array{_: 'messages.messagesNotModified', count: array} @see https://docs.madelineproto.xyz/API_docs/types/messages.Messages.html
*/
public function getHistory(array|int|string|null $peer = null, int|null $offset_id = 0, int|null $offset_date = 0, int|null $add_offset = 0, int|null $limit = 0, int|null $max_id = 0, int|null $min_id = 0, array $hash = [], ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getHistory(array|int|string|null $peer = null, int|null $offset_id = 0, int|null $offset_date = 0, int|null $add_offset = 0, int|null $limit = 0, int|null $max_id = 0, int|null $min_id = 0, array $hash = [], ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?int $takeoutId = null): array;
/**
* Returns found messages.
@ -74,9 +76,10 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?int $takeoutId Optional takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @return array{_: 'messages.messages', messages: list<array>, chats: list<array>, users: list<array>}|array{_: 'messages.messagesSlice', inexact: array, count: array, next_rate?: array, offset_id_offset?: array, messages: list<array>, chats: list<array>, users: list<array>}|array{_: 'messages.channelMessages', inexact: array, pts: array, count: array, offset_id_offset?: array, messages: list<array>, topics: list<array>, chats: list<array>, users: list<array>}|array{_: 'messages.messagesNotModified', count: array} @see https://docs.madelineproto.xyz/API_docs/types/messages.Messages.html
*/
public function search(array $filter, array|int|string|null $peer = null, string|null $q = '', array|int|string|null $from_id = null, int|null $top_msg_id = null, int|null $min_date = 0, int|null $max_date = 0, int|null $offset_id = 0, int|null $add_offset = 0, int|null $limit = 0, int|null $max_id = 0, int|null $min_id = 0, array $hash = [], ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function search(array $filter, array|int|string|null $peer = null, string|null $q = '', array|int|string|null $from_id = null, int|null $top_msg_id = null, int|null $min_date = 0, int|null $max_date = 0, int|null $offset_id = 0, int|null $add_offset = 0, int|null $limit = 0, int|null $max_id = 0, int|null $min_id = 0, array $hash = [], ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?int $takeoutId = null): array;
/**
* Marks message history as read.
@ -1177,12 +1180,13 @@ interface Messages
/**
* Get message ranges for saving the user's chat history.
*
* @param int $takeoutId Takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @return list<array{_: 'messageRange', min_id: int, max_id: int}> Array of @see https://docs.madelineproto.xyz/API_docs/types/MessageRange.html
*/
public function getSplitRanges(?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getSplitRanges(int $takeoutId, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
/**
* Manually mark dialog as unread.

View File

@ -61,9 +61,10 @@ interface Photos
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?int $takeoutId Optional takeout ID, generated using account.initTakeoutSession, see [the takeout docs](https://core.telegram.org/api/takeout) for more info.
* @return array{_: 'photos.photos', photos: list<array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list<array>, video_sizes?: list<array>, dc_id: array}>, users: list<array|int|string>}|array{_: 'photos.photosSlice', count: int, photos: list<array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list<array>, video_sizes?: list<array>, dc_id: array}>, users: list<array|int|string>} @see https://docs.madelineproto.xyz/API_docs/types/photos.Photos.html
*/
public function getUserPhotos(array|int|string|null $user_id = null, int|null $offset = 0, int|null $max_id = 0, int|null $limit = 0, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getUserPhotos(array|int|string|null $user_id = null, int|null $offset = 0, int|null $max_id = 0, int|null $limit = 0, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?int $takeoutId = null): array;
/**
* Upload a custom profile picture for a contact, or suggest a new profile picture to a contact.

File diff suppressed because one or more lines are too long

View File

@ -602,7 +602,7 @@ final class TL implements TLInterface
$predicate = $object['_'];
$constructorData = $this->constructors->findByPredicate($predicate, $layer);
if ($constructorData === false) {
$this->API->logger($object, Logger::FATAL_ERROR);
//$this->API->logger($object, Logger::FATAL_ERROR);
throw new Exception(sprintf(Lang::$current_lang['type_extract_error'], $predicate));
}
if ($bare = $type['type'] != '' && $type['type'][0] === '%') {