From 1536b4f75d5464a90f88912d98576f86f63494f5 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 18 Dec 2024 16:01:36 +0000 Subject: [PATCH] Bump and improve docs --- docs | 2 +- src/API.php | 2 +- src/Namespace/Messages.php | 8 ++++---- tools/AnnotationsBuilder.php | 5 ++++- tools/DocsBuilder/Constructors.php | 10 ++++++++-- tools/DocsBuilder/Methods.php | 10 ++++++++-- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/docs b/docs index 2b2f9132f..dcb26887f 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 2b2f9132f2c7215de984117bc5bff4e41430df1f +Subproject commit dcb26887f15a719008ce2a7595dbcc69941a84b1 diff --git a/src/API.php b/src/API.php index dc27bbe82..79d085b54 100644 --- a/src/API.php +++ b/src/API.php @@ -51,7 +51,7 @@ final class API extends AbstractAPI * * @var string */ - public const RELEASE = '8.4.0'; + public const RELEASE = '8.4.1'; /** * We're not logged in. * diff --git a/src/Namespace/Messages.php b/src/Namespace/Messages.php index 2001c842a..32b73ae7b 100644 --- a/src/Namespace/Messages.php +++ b/src/Namespace/Messages.php @@ -2766,7 +2766,7 @@ public function getPaidReactionPrivacy(?int $floodWaitLimit = null, ?string $que * @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID. * @param ?\Amp\Cancellation $cancellation Cancellation */ - public function viewSponsoredMessage(array|int|string|null $peer = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool; + public function viewSponsoredMessage(array|int|string|null $peer = null, string|null $random_id = '', ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool; /** * @@ -2778,7 +2778,7 @@ public function viewSponsoredMessage(array|int|string|null $peer = null, ?int $f * @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID. * @param ?\Amp\Cancellation $cancellation Cancellation */ - public function clickSponsoredMessage(bool|null $media = null, bool|null $fullscreen = null, array|int|string|null $peer = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool; + public function clickSponsoredMessage(bool|null $media = null, bool|null $fullscreen = null, array|int|string|null $peer = null, string|null $random_id = '', ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool; /** * @@ -2789,7 +2789,7 @@ public function clickSponsoredMessage(bool|null $media = null, bool|null $fullsc * @param ?\Amp\Cancellation $cancellation Cancellation * @return array{_: 'channels.sponsoredMessageReportResultChooseOption', title: string, options: list}|array{_: 'channels.sponsoredMessageReportResultAdsHidden'}|array{_: 'channels.sponsoredMessageReportResultReported'} @see https://docs.madelineproto.xyz/API_docs/types/channels.SponsoredMessageReportResult.html */ - public function reportSponsoredMessage(array|int|string|null $peer = null, string|null $option = '', ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array; + public function reportSponsoredMessage(array|int|string|null $peer = null, string|null $random_id = '', string|null $option = '', ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array; /** * @@ -2798,7 +2798,7 @@ public function reportSponsoredMessage(array|int|string|null $peer = null, strin * @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.sponsoredMessages', posts_between?: int, messages: list, photo?: array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list, video_sizes?: list, dc_id: array}, media?: array{_: 'messageMediaEmpty'}|array{_: 'messageMediaPhoto', spoiler: bool, photo?: array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list, video_sizes?: list, dc_id: array}, ttl_seconds?: int}|array{_: 'messageMediaGeo', geo: array{_: 'geoPointEmpty'}|array{_: 'geoPoint', long: array, lat: array, access_hash: array, accuracy_radius?: array}}|array{_: 'messageMediaContact', phone_number: string, first_name: string, last_name: string, vcard: string, user_id: int}|array{_: 'messageMediaUnsupported'}|array{_: 'messageMediaDocument', nopremium: bool, spoiler: bool, video: bool, round: bool, voice: bool, document?: array{_: 'documentEmpty', id: array}|array{_: 'document', id: array, access_hash: array, file_reference: array, date: array, mime_type: array, size: array, thumbs?: list, video_thumbs?: list, dc_id: array, attributes: list}, alt_documents?: list, video_thumbs?: list, dc_id: array, attributes: list}>, ttl_seconds?: int}|array{_: 'messageMediaWebPage', force_large_media: bool, force_small_media: bool, manual: bool, safe: bool, webpage: array{_: 'webPageEmpty', id: array, url?: array}|array{_: 'webPagePending', id: array, url?: array, date: array}|array{_: 'webPage', has_large_media: array, id: array, url: array, display_url: array, hash: array, type?: array, site_name?: array, title?: array, description?: array, photo?: array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list, video_sizes?: list, dc_id: array}, embed_url?: array, embed_type?: array, embed_width?: array, embed_height?: array, duration?: array, author?: array, document?: array{_: 'documentEmpty', id: array}|array{_: 'document', id: array, access_hash: array, file_reference: array, date: array, mime_type: array, size: array, thumbs?: list, video_thumbs?: list, dc_id: array, attributes: list}, cached_page?: array, attributes?: list}|array{_: 'webPageNotModified', cached_page_views?: array}}|array{_: 'messageMediaVenue', geo: array{_: 'geoPointEmpty'}|array{_: 'geoPoint', long: array, lat: array, access_hash: array, accuracy_radius?: array}, title: string, address: string, provider: string, venue_id: string, venue_type: string}|array{_: 'messageMediaGame', game: array{_: 'game', id: array, access_hash: array, short_name: array, title: array, description: array, photo: array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list, video_sizes?: list, dc_id: array}, document?: array{_: 'documentEmpty', id: array}|array{_: 'document', id: array, access_hash: array, file_reference: array, date: array, mime_type: array, size: array, thumbs?: list, video_thumbs?: list, dc_id: array, attributes: list}}}|array{_: 'messageMediaInvoice', shipping_address_requested: bool, test: bool, title: string, description: string, photo?: array{_: 'webDocument', url: array, access_hash: array, size: array, mime_type: array, attributes: list}|array{_: 'webDocumentNoProxy', url: array, size: array, mime_type: array, attributes: list}, receipt_msg_id?: int, currency: string, total_amount: int, start_param: string, extended_media?: array{_: 'messageExtendedMediaPreview', w?: array, h?: array, thumb?: array, video_duration?: array}}|array{_: 'messageMediaGeoLive', geo: array{_: 'geoPointEmpty'}|array{_: 'geoPoint', long: array, lat: array, access_hash: array, accuracy_radius?: array}, heading?: int, period: int, proximity_notification_radius?: int}|array{_: 'messageMediaPoll', poll: array{_: 'poll', question: array, id: array, closed: array, public_voters: array, multiple_choice: array, quiz: array, answers: list, close_period?: array, close_date?: array}, results: array{_: 'pollResults', min: array, results?: list, total_voters?: array, recent_voters?: list, solution?: array, solution_entities?: list}}|array{_: 'messageMediaDice', value: int, emoticon: string}|array{_: 'messageMediaStory', peer: array|int|string, via_mention: bool, id: int, story?: array{_: 'storyItemDeleted', id: array}|array{_: 'storyItemSkipped', close_friends: array, id: array, date: array, expire_date: array}}|array{_: 'messageMediaGiveaway', only_new_subscribers: bool, winners_are_visible: bool, channels: list, countries_iso2?: list, prize_description?: string, quantity: int, months?: int, stars?: int, until_date: int}|array{_: 'messageMediaGiveawayResults', only_new_subscribers: bool, refunded: bool, channel_id: int, additional_peers_count?: int, launch_msg_id: int, winners_count: int, unclaimed_count: int, winners: list, months?: int, stars?: int, prize_description?: string, until_date: int}|array{_: 'messageMediaPaidMedia', stars_amount: int, extended_media: list}, color?: array{_: 'peerColor', color?: int, background_emoji_id?: int}, button_text: string, sponsor_info?: string, additional_info?: string}>, chats: list, users: list}|array{_: 'messages.sponsoredMessagesEmpty'} @see https://docs.madelineproto.xyz/API_docs/types/messages.SponsoredMessages.html + * @return array{_: 'messages.sponsoredMessages', posts_between?: int, messages: list, photo?: array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list, video_sizes?: list, dc_id: array}, media?: array{_: 'messageMediaEmpty'}|array{_: 'messageMediaPhoto', spoiler: bool, photo?: array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list, video_sizes?: list, dc_id: array}, ttl_seconds?: int}|array{_: 'messageMediaGeo', geo: array{_: 'geoPointEmpty'}|array{_: 'geoPoint', long: array, lat: array, access_hash: array, accuracy_radius?: array}}|array{_: 'messageMediaContact', phone_number: string, first_name: string, last_name: string, vcard: string, user_id: int}|array{_: 'messageMediaUnsupported'}|array{_: 'messageMediaDocument', nopremium: bool, spoiler: bool, video: bool, round: bool, voice: bool, document?: array{_: 'documentEmpty', id: array}|array{_: 'document', id: array, access_hash: array, file_reference: array, date: array, mime_type: array, size: array, thumbs?: list, video_thumbs?: list, dc_id: array, attributes: list}, alt_documents?: list, video_thumbs?: list, dc_id: array, attributes: list}>, ttl_seconds?: int}|array{_: 'messageMediaWebPage', force_large_media: bool, force_small_media: bool, manual: bool, safe: bool, webpage: array{_: 'webPageEmpty', id: array, url?: array}|array{_: 'webPagePending', id: array, url?: array, date: array}|array{_: 'webPage', has_large_media: array, id: array, url: array, display_url: array, hash: array, type?: array, site_name?: array, title?: array, description?: array, photo?: array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list, video_sizes?: list, dc_id: array}, embed_url?: array, embed_type?: array, embed_width?: array, embed_height?: array, duration?: array, author?: array, document?: array{_: 'documentEmpty', id: array}|array{_: 'document', id: array, access_hash: array, file_reference: array, date: array, mime_type: array, size: array, thumbs?: list, video_thumbs?: list, dc_id: array, attributes: list}, cached_page?: array, attributes?: list}|array{_: 'webPageNotModified', cached_page_views?: array}}|array{_: 'messageMediaVenue', geo: array{_: 'geoPointEmpty'}|array{_: 'geoPoint', long: array, lat: array, access_hash: array, accuracy_radius?: array}, title: string, address: string, provider: string, venue_id: string, venue_type: string}|array{_: 'messageMediaGame', game: array{_: 'game', id: array, access_hash: array, short_name: array, title: array, description: array, photo: array{_: 'photoEmpty', id: array}|array{_: 'photo', has_stickers: array, id: array, access_hash: array, file_reference: array, date: array, sizes: list, video_sizes?: list, dc_id: array}, document?: array{_: 'documentEmpty', id: array}|array{_: 'document', id: array, access_hash: array, file_reference: array, date: array, mime_type: array, size: array, thumbs?: list, video_thumbs?: list, dc_id: array, attributes: list}}}|array{_: 'messageMediaInvoice', shipping_address_requested: bool, test: bool, title: string, description: string, photo?: array{_: 'webDocument', url: array, access_hash: array, size: array, mime_type: array, attributes: list}|array{_: 'webDocumentNoProxy', url: array, size: array, mime_type: array, attributes: list}, receipt_msg_id?: int, currency: string, total_amount: int, start_param: string, extended_media?: array{_: 'messageExtendedMediaPreview', w?: array, h?: array, thumb?: array, video_duration?: array}}|array{_: 'messageMediaGeoLive', geo: array{_: 'geoPointEmpty'}|array{_: 'geoPoint', long: array, lat: array, access_hash: array, accuracy_radius?: array}, heading?: int, period: int, proximity_notification_radius?: int}|array{_: 'messageMediaPoll', poll: array{_: 'poll', question: array, id: array, closed: array, public_voters: array, multiple_choice: array, quiz: array, answers: list, close_period?: array, close_date?: array}, results: array{_: 'pollResults', min: array, results?: list, total_voters?: array, recent_voters?: list, solution?: array, solution_entities?: list}}|array{_: 'messageMediaDice', value: int, emoticon: string}|array{_: 'messageMediaStory', peer: array|int|string, via_mention: bool, id: int, story?: array{_: 'storyItemDeleted', id: array}|array{_: 'storyItemSkipped', close_friends: array, id: array, date: array, expire_date: array}}|array{_: 'messageMediaGiveaway', only_new_subscribers: bool, winners_are_visible: bool, channels: list, countries_iso2?: list, prize_description?: string, quantity: int, months?: int, stars?: int, until_date: int}|array{_: 'messageMediaGiveawayResults', only_new_subscribers: bool, refunded: bool, channel_id: int, additional_peers_count?: int, launch_msg_id: int, winners_count: int, unclaimed_count: int, winners: list, months?: int, stars?: int, prize_description?: string, until_date: int}|array{_: 'messageMediaPaidMedia', stars_amount: int, extended_media: list}, color?: array{_: 'peerColor', color?: int, background_emoji_id?: int}, button_text: string, sponsor_info?: string, additional_info?: string}>, chats: list, users: list}|array{_: 'messages.sponsoredMessagesEmpty'} @see https://docs.madelineproto.xyz/API_docs/types/messages.SponsoredMessages.html */ public function getSponsoredMessages(array|int|string|null $peer = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array; diff --git a/tools/AnnotationsBuilder.php b/tools/AnnotationsBuilder.php index 292a4bd28..b090c591e 100644 --- a/tools/AnnotationsBuilder.php +++ b/tools/AnnotationsBuilder.php @@ -284,7 +284,10 @@ private function filterParams(array $params, string $type, ?string $method = nul { $newParams = []; foreach ($params as $param) { - if (\in_array($param['name'], ['flags', 'flags2', 'random_id', 'random_bytes'], true)) { + if (\in_array($param['name'], ['flags', 'flags2', 'random_bytes'], true)) { + continue; + } + if ($param['name'] === 'random_id' && stripos($method ?? $type, 'sponsored') === false) { continue; } if ($method) { diff --git a/tools/DocsBuilder/Constructors.php b/tools/DocsBuilder/Constructors.php index e5dce31d7..bcfadb00c 100644 --- a/tools/DocsBuilder/Constructors.php +++ b/tools/DocsBuilder/Constructors.php @@ -66,7 +66,10 @@ public function mkConstructors(): void if ($param['type'] === 'strlong') { $param['type'] = 'long'; } - if (\in_array($param['name'], ['flags', 'flags2', 'random_id', 'random_bytes'], true)) { + if (\in_array($param['name'], ['flags', 'flags2', 'random_bytes'], true)) { + continue; + } + if ($param['name'] === 'random_id' && stripos($constructor, 'sponsored') === false) { continue; } if ($param['name'] === 'peer' && $param['type'] === 'Peer') { @@ -121,7 +124,10 @@ public function mkConstructors(): void if ($param['type'] === 'strlong') { $param['type'] = 'long'; } - if (\in_array($param['name'], ['flags', 'flags2', 'random_id', 'random_bytes'], true)) { + if (\in_array($param['name'], ['flags', 'flags2', 'random_bytes'], true)) { + continue; + } + if ($param['name'] === 'random_id' && stripos($constructor, 'sponsored') === false) { continue; } if ($type === 'EncryptedMessage' && $param['name'] === 'bytes' && !isset($this->settings['td'])) { diff --git a/tools/DocsBuilder/Methods.php b/tools/DocsBuilder/Methods.php index 65806e44c..1b88750d5 100644 --- a/tools/DocsBuilder/Methods.php +++ b/tools/DocsBuilder/Methods.php @@ -87,7 +87,10 @@ public function mkMethods(): void } $params = ''; foreach ($data['params'] as $param) { - if (\in_array($param['name'], ['flags', 'flags2', 'random_id', 'random_bytes'], true)) { + if (\in_array($param['name'], ['flags', 'flags2', 'random_bytes'], true)) { + continue; + } + if ($param['name'] === 'random_id' && stripos($method, 'sponsored') === false) { continue; } if ($param['name'] === 'data' && $type === 'messages_SentEncryptedMessage' && !isset($this->settings['td'])) { @@ -141,7 +144,10 @@ public function mkMethods(): void $hasreplymarkup = false; $hasmessage = false; foreach ($data['params'] as $param) { - if (\in_array($param['name'], ['flags', 'flags2', 'random_id', 'random_bytes'], true)) { + if (\in_array($param['name'], ['flags', 'flags2', 'random_bytes'], true)) { + continue; + } + if ($param['name'] === 'random_id' && stripos($method, 'sponsored') === false) { continue; } if ($param['name'] === 'data' && $type === 'messages_SentEncryptedMessage' && !isset($this->settings['td'])) {