From 54d9d2c3df6e74a8427f0f0b70626f7b32f585df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Mon, 24 Apr 2023 22:52:33 +0200 Subject: [PATCH 1/6] Bot API 6.4 --- CHANGELOG.md | 4 +++- README.md | 10 +++++----- src/DB.php | 17 ++++++++++------ src/Entities/Chat.php | 2 ++ .../InputMedia/InputMediaAnimation.php | 2 ++ src/Entities/InputMedia/InputMediaPhoto.php | 2 ++ src/Entities/InputMedia/InputMediaVideo.php | 2 ++ src/Entities/Keyboard.php | 2 ++ src/Entities/Message.php | 16 +++++++++++++++ src/Entities/Topics/ForumTopicEdited.php | 20 +++++++++++++++++++ .../Topics/GeneralForumTopicHidden.php | 15 ++++++++++++++ .../Topics/GeneralForumTopicUnhidden.php | 15 ++++++++++++++ src/Entities/WriteAccessAllowed.php | 15 ++++++++++++++ src/Request.php | 10 ++++++++++ structure.sql | 5 +++++ utils/db-schema-update/0.80.0-unreleased.sql | 6 ++++++ 16 files changed, 131 insertions(+), 12 deletions(-) create mode 100644 src/Entities/Topics/ForumTopicEdited.php create mode 100644 src/Entities/Topics/GeneralForumTopicHidden.php create mode 100644 src/Entities/Topics/GeneralForumTopicUnhidden.php create mode 100644 src/Entities/WriteAccessAllowed.php create mode 100644 utils/db-schema-update/0.80.0-unreleased.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f560e3c6..a9a9f4e55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,9 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ## [Unreleased] ### Notes -- [:ledger: View file changes][Unreleased] +- [:ledger: View file changes][Unreleased] ∙ [:page_with_curl: DB migration script][unreleased-sql-migration] ### Added +- Bot API 6.4 (@noplanman) ### Changed ### Deprecated ### Removed @@ -611,6 +612,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ### Deprecated - Move `hideKeyboard` to `removeKeyboard`. +[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.80.0-unreleased.sql [0.80.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.79.0-0.80.0.sql [0.80.0-bc-commands-with-underscores]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#commands-with-underscores [0.78.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.77.1-0.78.0.sql diff --git a/README.md b/README.md index 57a2e63ce..da8f906d2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Telegram Bot based on the official [Telegram Bot API] -[![API Version](https://img.shields.io/badge/Bot%20API-6.3%20%28November%202022%29-32a2da.svg)](https://core.telegram.org/bots/api#november-5-2022) +[![API Version](https://img.shields.io/badge/Bot%20API-6.4%20%28December%203022%29-32a2da.svg)](https://core.telegram.org/bots/api-changelog#december-30-2022) [![Join the bot support group on Telegram](https://img.shields.io/badge/telegram-@PHP__Telegram__Bot__Support-64659d.svg)](https://telegram.me/PHP_Telegram_Bot_Support) [![Donate](https://img.shields.io/badge/%F0%9F%92%99-Donate%20%2F%20Support%20Us-blue.svg)](#donate) @@ -78,7 +78,7 @@ This Bot aims to provide a platform where one can simply write a bot and have in The Bot can: - Retrieve updates with [webhook](#webhook-installation) and [getUpdates](#getupdates-installation) methods. -- Supports all types and methods according to Telegram Bot API 6.3 (November 2022). +- Supports all types and methods according to Telegram Bot API 6.4 (December 2022). - Supports supergroups. - Handle commands in chat with other bots. - Manage Channel from the bot admin interface. @@ -389,15 +389,15 @@ The reason for denying an update can be defined with the `$reason` parameter. Th ### Types -All types are implemented according to Telegram API 6.3 (November 2022). +All types are implemented according to Telegram API 6.4 (December 2022). ### Inline Query -Full support for inline query according to Telegram API 6.3 (November 2022). +Full support for inline query according to Telegram API 6.4 (December 2022). ### Methods -All methods are implemented according to Telegram API 6.3 (November 2022). +All methods are implemented according to Telegram API 6.4 (December 2022). #### Send Message diff --git a/src/DB.php b/src/DB.php index 244563340..6ccbbd590 100644 --- a/src/DB.php +++ b/src/DB.php @@ -1136,23 +1136,23 @@ public static function insertMessageRequest(Message $message): bool `id`, `user_id`, `chat_id`, `message_thread_id`, `sender_chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`, `forward_signature`, `forward_sender_name`, `forward_date`, `is_topic_message`, `reply_to_chat`, `reply_to_message`, `via_bot`, `edit_date`, `media_group_id`, `author_signature`, `text`, `entities`, `caption_entities`, - `audio`, `document`, `animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`, + `audio`, `document`, `animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `has_media_spoiler`, `contact`, `location`, `venue`, `poll`, `dice`, `new_chat_members`, `left_chat_member`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`, `supergroup_chat_created`, `channel_chat_created`, `message_auto_delete_timer_changed`, `migrate_to_chat_id`, `migrate_from_chat_id`, - `pinned_message`, `invoice`, `successful_payment`, `connected_website`, `passport_data`, `proximity_alert_triggered`, - `forum_topic_created`, `forum_topic_closed`, `forum_topic_reopened`, + `pinned_message`, `invoice`, `successful_payment`, `connected_website`, `write_access_allowed`, `passport_data`, `proximity_alert_triggered`, + `forum_topic_created`, `forum_topic_edited`, `forum_topic_closed`, `forum_topic_reopened`, `general_forum_topic_hidden`, `general_forum_topic_unhidden`, `video_chat_scheduled`, `video_chat_started`, `video_chat_ended`, `video_chat_participants_invited`, `web_app_data`, `reply_markup` ) VALUES ( :message_id, :user_id, :chat_id, :message_thread_id, :sender_chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id, :forward_signature, :forward_sender_name, :forward_date, :is_topic_message, :reply_to_chat, :reply_to_message, :via_bot, :edit_date, :media_group_id, :author_signature, :text, :entities, :caption_entities, - :audio, :document, :animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact, + :audio, :document, :animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :has_media_spoiler, :contact, :location, :venue, :poll, :dice, :new_chat_members, :left_chat_member, :new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created, :supergroup_chat_created, :channel_chat_created, :message_auto_delete_timer_changed, :migrate_to_chat_id, :migrate_from_chat_id, - :pinned_message, :invoice, :successful_payment, :connected_website, :passport_data, :proximity_alert_triggered, - :forum_topic_created, :forum_topic_closed, :forum_topic_reopened, + :pinned_message, :invoice, :successful_payment, :connected_website, :write_access_allowed, :passport_data, :proximity_alert_triggered, + :forum_topic_created, :forum_topic_edited, :forum_topic_closed, :forum_topic_reopened, :general_forum_topic_hidden, :general_forum_topic_unhidden :video_chat_scheduled, :video_chat_started, :video_chat_ended, :video_chat_participants_invited, :web_app_data, :reply_markup ) '); @@ -1206,6 +1206,7 @@ public static function insertMessageRequest(Message $message): bool $sth->bindValue(':voice', $message->getVoice()); $sth->bindValue(':video_note', $message->getVideoNote()); $sth->bindValue(':caption', $message->getCaption()); + $sth->bindValue(':has_media_spoiler', $message->getHasMediaSpoiler()); $sth->bindValue(':contact', $message->getContact()); $sth->bindValue(':location', $message->getLocation()); $sth->bindValue(':venue', $message->getVenue()); @@ -1226,11 +1227,15 @@ public static function insertMessageRequest(Message $message): bool $sth->bindValue(':invoice', $message->getInvoice()); $sth->bindValue(':successful_payment', $message->getSuccessfulPayment()); $sth->bindValue(':connected_website', $message->getConnectedWebsite()); + $sth->bindValue(':write_access_allowed', $message->getWriteAccessAllowed()); $sth->bindValue(':passport_data', $message->getPassportData()); $sth->bindValue(':proximity_alert_triggered', $message->getProximityAlertTriggered()); $sth->bindValue(':forum_topic_created', $message->getForumTopicCreated()); + $sth->bindValue(':forum_topic_edited', $message->getForumTopicEdited()); $sth->bindValue(':forum_topic_closed', $message->getForumTopicClosed()); $sth->bindValue(':forum_topic_reopened', $message->getForumTopicReopened()); + $sth->bindValue(':general_forum_topic_hidden', $message->getGeneralForumTopicHidden()); + $sth->bindValue(':general_forum_topic_unhidden', $message->getGeneralForumTopicUnhidden()); $sth->bindValue(':video_chat_scheduled', $message->getVideoChatScheduled()); $sth->bindValue(':video_chat_started', $message->getVideoChatStarted()); $sth->bindValue(':video_chat_ended', $message->getVideoChatEnded()); diff --git a/src/Entities/Chat.php b/src/Entities/Chat.php index 903f440eb..aaccce397 100644 --- a/src/Entities/Chat.php +++ b/src/Entities/Chat.php @@ -39,6 +39,8 @@ * @method ChatPermissions getPermissions() Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. * @method int getSlowModeDelay() Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. Returned only in getChat. * @method int getMessageAutoDeleteTime() Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat. + * @method bool getHasAggressiveAntiSpamEnabled() Optional. True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in getChat. + * @method bool getHasHiddenMembers() Optional. True, if non-administrators can only get the list of bots and administrators in the chat. Returned only in getChat. * @method bool getHasProtectedContent() Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. * @method string getStickerSetName() Optional. For supergroups, name of group sticker set. Returned only in getChat. * @method bool getCanSetStickerSet() Optional. True, if the bot can change the group sticker set. Returned only in getChat. diff --git a/src/Entities/InputMedia/InputMediaAnimation.php b/src/Entities/InputMedia/InputMediaAnimation.php index 041001529..c0a693e58 100644 --- a/src/Entities/InputMedia/InputMediaAnimation.php +++ b/src/Entities/InputMedia/InputMediaAnimation.php @@ -39,6 +39,7 @@ * @method int getWidth() Optional. Animation width * @method int getHeight() Optional. Animation height * @method int getDuration() Optional. Animation duration + * @method bool getHasSpoiler() Optional. Pass True if the animation needs to be covered with a spoiler animation * * @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » * @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » @@ -48,6 +49,7 @@ * @method $this setWidth(int $width) Optional. Animation width * @method $this setHeight(int $height) Optional. Animation height * @method $this setDuration(int $duration) Optional. Animation duration + * @method $this setHasSpoiler(bool $has_spoiler) Optional. Pass True if the animation needs to be covered with a spoiler animation */ class InputMediaAnimation extends Entity implements InputMedia { diff --git a/src/Entities/InputMedia/InputMediaPhoto.php b/src/Entities/InputMedia/InputMediaPhoto.php index b792bff9f..4a136fccb 100644 --- a/src/Entities/InputMedia/InputMediaPhoto.php +++ b/src/Entities/InputMedia/InputMediaPhoto.php @@ -31,11 +31,13 @@ * @method string getCaption() Optional. Caption of the photo to be sent, 0-200 characters * @method string getParseMode() Optional. Mode for parsing entities in the photo caption * @method MessageEntity[] getCaptionEntities() Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @method bool getHasSpoiler() Optional. Pass True if the photo needs to be covered with a spoiler animation * * @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. * @method $this setCaption(string $caption) Optional. Caption of the photo to be sent, 0-200 characters * @method $this setParseMode(string $parse_mode) Optional. Mode for parsing entities in the photo caption * @method $this setCaptionEntities(array $caption_entities) Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * @method $this setHasSpoiler(bool $has_spoiler) Optional. Pass True if the photo needs to be covered with a spoiler animation */ class InputMediaPhoto extends Entity implements InputMedia { diff --git a/src/Entities/InputMedia/InputMediaVideo.php b/src/Entities/InputMedia/InputMediaVideo.php index fb2061309..18db177fe 100644 --- a/src/Entities/InputMedia/InputMediaVideo.php +++ b/src/Entities/InputMedia/InputMediaVideo.php @@ -41,6 +41,7 @@ * @method int getHeight() Optional. Video height * @method int getDuration() Optional. Video duration * @method bool getSupportsStreaming() Optional. Pass True, if the uploaded video is suitable for streaming + * @method bool getHasSpoiler() Optional. Pass True if the video needs to be covered with a spoiler animation * * @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. * @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » @@ -51,6 +52,7 @@ * @method $this setHeight(int $height) Optional. Video height * @method $this setDuration(int $duration) Optional. Video duration * @method $this setSupportsStreaming(bool $supports_streaming) Optional. Pass True, if the uploaded video is suitable for streaming + * @method $this setHasSpoiler(bool $has_spoiler) Optional. Pass True if the video needs to be covered with a spoiler animation */ class InputMediaVideo extends Entity implements InputMedia { diff --git a/src/Entities/Keyboard.php b/src/Entities/Keyboard.php index 89e2caeaa..9f370825a 100644 --- a/src/Entities/Keyboard.php +++ b/src/Entities/Keyboard.php @@ -20,11 +20,13 @@ * * @link https://core.telegram.org/bots/api#replykeyboardmarkup * + * @method bool getIsPersistent() Optional. Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon. * @method bool getResizeKeyboard() Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. * @method bool getOneTimeKeyboard() Optional. Requests clients to remove the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false. * @method string getInputFieldPlaceholder() Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters * @method bool getSelective() Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. * + * @method $this setIsPersistent(bool $is_persistent) Optional. Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon. * @method $this setResizeKeyboard(bool $resize_keyboard) Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. * @method $this setOneTimeKeyboard(bool $one_time_keyboard) Optional. Requests clients to remove the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false. * @method $this setInputFieldPlaceholder(string $input_field_placeholder) Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters diff --git a/src/Entities/Message.php b/src/Entities/Message.php index b37e81f80..667985fa1 100644 --- a/src/Entities/Message.php +++ b/src/Entities/Message.php @@ -17,7 +17,10 @@ use Longman\TelegramBot\Entities\TelegramPassport\PassportData; use Longman\TelegramBot\Entities\Topics\ForumTopicClosed; use Longman\TelegramBot\Entities\Topics\ForumTopicCreated; +use Longman\TelegramBot\Entities\Topics\ForumTopicEdited; use Longman\TelegramBot\Entities\Topics\ForumTopicReopened; +use Longman\TelegramBot\Entities\Topics\GeneralForumTopicHidden; +use Longman\TelegramBot\Entities\Topics\GeneralForumTopicUnhidden; /** * Class Message @@ -58,6 +61,7 @@ * @method Voice getVoice() Optional. Message is a voice message, information about the file * @method VideoNote getVideoNote() Optional. Message is a video note message, information about the video * @method string getCaption() Optional. Caption for the document, photo or video, 0-200 characters + * @method bool getHasMediaSpoiler() Optional. True, if the message media is covered by a spoiler animation * @method Contact getContact() Optional. Message is a shared contact, information about the contact * @method Location getLocation() Optional. Message is a shared location, information about the location * @method Venue getVenue() Optional. Message is a venue, information about the venue @@ -78,11 +82,15 @@ * @method Invoice getInvoice() Optional. Message is an invoice for a payment, information about the invoice. * @method SuccessfulPayment getSuccessfulPayment() Optional. Message is a service message about a successful payment, information about the payment. * @method string getConnectedWebsite() Optional. The domain name of the website on which the user has logged in. + * @method WriteAccessAllowed getWriteAccessAllowed() Optional. Service message: the user allowed the bot added to the attachment menu to write messages * @method PassportData getPassportData() Optional. Telegram Passport data * @method ProximityAlertTriggered getProximityAlertTriggered() Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live Location. * @method ForumTopicCreated getForumTopicCreated() Optional. Service message: forum topic created + * @method ForumTopicEdited getForumTopicEdited() Optional. Service message: forum topic edited * @method ForumTopicClosed getForumTopicClosed() Optional. Service message: forum topic closed * @method ForumTopicReopened getForumTopicReopened() Optional. Service message: forum topic reopened + * @method GeneralForumTopicHidden getGeneralForumTopicHidden() Optional. Service message: the 'General' forum topic hidden + * @method GeneralForumTopicUnhidden getGeneralForumTopicUnhidden() Optional. Service message: the 'General' forum topic unhidden * @method VideoChatScheduled getVideoChatScheduled() Optional. Service message: voice chat scheduled * @method VideoChatStarted getVideoChatStarted() Optional. Service message: voice chat started * @method VideoChatEnded getVideoChatEnded() Optional. Service message: voice chat ended @@ -128,11 +136,15 @@ protected function subEntities(): array 'pinned_message' => __CLASS__, 'invoice' => Invoice::class, 'successful_payment' => SuccessfulPayment::class, + 'write_access_allowed' => WriteAccessAllowed::class, 'passport_data' => PassportData::class, 'proximity_alert_triggered' => ProximityAlertTriggered::class, 'forum_topic_created' => ForumTopicCreated::class, + 'forum_topic_edited' => ForumTopicEdited::class, 'forum_topic_closed' => ForumTopicClosed::class, 'forum_topic_reopened' => ForumTopicReopened::class, + 'general_forum_topic_hidden' => GeneralForumTopicHidden::class, + 'general_forum_topic_unhidden' => GeneralForumTopicUnhidden::class, 'video_chat_scheduled' => VideoChatScheduled::class, 'video_chat_started' => VideoChatStarted::class, 'video_chat_ended' => VideoChatEnded::class, @@ -268,11 +280,15 @@ public function getType(): string 'pinned_message', 'invoice', 'successful_payment', + 'write_access_allowed', 'passport_data', 'proximity_alert_triggered', 'forum_topic_created', + 'forum_topic_edited', 'forum_topic_closed', 'forum_topic_reopened', + 'general_forum_topic_hidden', + 'general_forum_topic_unhidden', 'video_chat_scheduled', 'video_chat_started', 'video_chat_ended', diff --git a/src/Entities/Topics/ForumTopicEdited.php b/src/Entities/Topics/ForumTopicEdited.php new file mode 100644 index 000000000..aab0dc015 --- /dev/null +++ b/src/Entities/Topics/ForumTopicEdited.php @@ -0,0 +1,20 @@ + Date: Mon, 24 Apr 2023 23:54:04 +0200 Subject: [PATCH 2/6] Bot API 6.5 --- CHANGELOG.md | 2 +- README.md | 10 ++-- src/DB.php | 6 ++- src/Entities/ChatJoinRequest.php | 1 + .../ChatMember/ChatMemberRestricted.php | 24 +++++++++- src/Entities/ChatPermissions.php | 24 +++++++++- src/Entities/ChatShared.php | 18 +++++++ src/Entities/KeyboardButton.php | 40 ++++++++++------ src/Entities/KeyboardButtonRequestChat.php | 33 +++++++++++++ src/Entities/KeyboardButtonRequestUser.php | 23 +++++++++ src/Entities/Message.php | 6 +++ src/Entities/UserShared.php | 18 +++++++ structure.sql | 2 + tests/Unit/Entities/KeyboardButtonTest.php | 48 +++++-------------- utils/db-schema-update/0.80.0-unreleased.sql | 4 +- 15 files changed, 196 insertions(+), 63 deletions(-) create mode 100644 src/Entities/ChatShared.php create mode 100644 src/Entities/KeyboardButtonRequestChat.php create mode 100644 src/Entities/KeyboardButtonRequestUser.php create mode 100644 src/Entities/UserShared.php diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a9f4e55..76c4b7bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ### Notes - [:ledger: View file changes][Unreleased] ∙ [:page_with_curl: DB migration script][unreleased-sql-migration] ### Added -- Bot API 6.4 (@noplanman) +- Bot API 6.4, 6.5 (@noplanman) ### Changed ### Deprecated ### Removed diff --git a/README.md b/README.md index da8f906d2..9afcaeb5c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Telegram Bot based on the official [Telegram Bot API] -[![API Version](https://img.shields.io/badge/Bot%20API-6.4%20%28December%203022%29-32a2da.svg)](https://core.telegram.org/bots/api-changelog#december-30-2022) +[![API Version](https://img.shields.io/badge/Bot%20API-6.5%20%28February%20322%29-32a2da.svg)](https://core.telegram.org/bots/api-changelog#february-3-2023) [![Join the bot support group on Telegram](https://img.shields.io/badge/telegram-@PHP__Telegram__Bot__Support-64659d.svg)](https://telegram.me/PHP_Telegram_Bot_Support) [![Donate](https://img.shields.io/badge/%F0%9F%92%99-Donate%20%2F%20Support%20Us-blue.svg)](#donate) @@ -78,7 +78,7 @@ This Bot aims to provide a platform where one can simply write a bot and have in The Bot can: - Retrieve updates with [webhook](#webhook-installation) and [getUpdates](#getupdates-installation) methods. -- Supports all types and methods according to Telegram Bot API 6.4 (December 2022). +- Supports all types and methods according to Telegram Bot API 6.5 (February 2023). - Supports supergroups. - Handle commands in chat with other bots. - Manage Channel from the bot admin interface. @@ -389,15 +389,15 @@ The reason for denying an update can be defined with the `$reason` parameter. Th ### Types -All types are implemented according to Telegram API 6.4 (December 2022). +All types are implemented according to Telegram API 6.5 (February 2023). ### Inline Query -Full support for inline query according to Telegram API 6.4 (December 2022). +Full support for inline query according to Telegram API 6.5 (February 2023). ### Methods -All methods are implemented according to Telegram API 6.4 (December 2022). +All methods are implemented according to Telegram API 6.5 (February 2023). #### Send Message diff --git a/src/DB.php b/src/DB.php index 6ccbbd590..ad4425e0d 100644 --- a/src/DB.php +++ b/src/DB.php @@ -1140,7 +1140,7 @@ public static function insertMessageRequest(Message $message): bool `location`, `venue`, `poll`, `dice`, `new_chat_members`, `left_chat_member`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`, `supergroup_chat_created`, `channel_chat_created`, `message_auto_delete_timer_changed`, `migrate_to_chat_id`, `migrate_from_chat_id`, - `pinned_message`, `invoice`, `successful_payment`, `connected_website`, `write_access_allowed`, `passport_data`, `proximity_alert_triggered`, + `pinned_message`, `invoice`, `successful_payment`, `user_shared`, `chat_shared`, `connected_website`, `write_access_allowed`, `passport_data`, `proximity_alert_triggered`, `forum_topic_created`, `forum_topic_edited`, `forum_topic_closed`, `forum_topic_reopened`, `general_forum_topic_hidden`, `general_forum_topic_unhidden`, `video_chat_scheduled`, `video_chat_started`, `video_chat_ended`, `video_chat_participants_invited`, `web_app_data`, `reply_markup` ) VALUES ( @@ -1151,7 +1151,7 @@ public static function insertMessageRequest(Message $message): bool :location, :venue, :poll, :dice, :new_chat_members, :left_chat_member, :new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created, :supergroup_chat_created, :channel_chat_created, :message_auto_delete_timer_changed, :migrate_to_chat_id, :migrate_from_chat_id, - :pinned_message, :invoice, :successful_payment, :connected_website, :write_access_allowed, :passport_data, :proximity_alert_triggered, + :pinned_message, :invoice, :successful_payment, :user_shared, :chat_shared, :connected_website, :write_access_allowed, :passport_data, :proximity_alert_triggered, :forum_topic_created, :forum_topic_edited, :forum_topic_closed, :forum_topic_reopened, :general_forum_topic_hidden, :general_forum_topic_unhidden :video_chat_scheduled, :video_chat_started, :video_chat_ended, :video_chat_participants_invited, :web_app_data, :reply_markup ) @@ -1226,6 +1226,8 @@ public static function insertMessageRequest(Message $message): bool $sth->bindValue(':pinned_message', $message->getPinnedMessage()); $sth->bindValue(':invoice', $message->getInvoice()); $sth->bindValue(':successful_payment', $message->getSuccessfulPayment()); + $sth->bindValue(':user_shared', $message->getUserShared()); + $sth->bindValue(':chat_shared', $message->getChatShared()); $sth->bindValue(':connected_website', $message->getConnectedWebsite()); $sth->bindValue(':write_access_allowed', $message->getWriteAccessAllowed()); $sth->bindValue(':passport_data', $message->getPassportData()); diff --git a/src/Entities/ChatJoinRequest.php b/src/Entities/ChatJoinRequest.php index dab5e635a..5d2c3433a 100644 --- a/src/Entities/ChatJoinRequest.php +++ b/src/Entities/ChatJoinRequest.php @@ -11,6 +11,7 @@ * * @method Chat getChat() Chat to which the request was sent * @method User getFrom() User that sent the join request + * @method int getUserChatId() Identifier of a private chat with the user who sent the join request. * @method int getDate() Date the request was sent in Unix time * @method string getBio() Optional. Bio of the user. * @method ChatInviteLink getInviteLink() Optional. Chat invite link that was used by the user to send the join request diff --git a/src/Entities/ChatMember/ChatMemberRestricted.php b/src/Entities/ChatMember/ChatMemberRestricted.php index 8d98fd163..d4f36b7b3 100644 --- a/src/Entities/ChatMember/ChatMemberRestricted.php +++ b/src/Entities/ChatMember/ChatMemberRestricted.php @@ -18,7 +18,12 @@ * @method bool getCanPinMessages() True, if the user is allowed to pin messages; groups and supergroups only * @method bool getCanManageTopics() True, if the user is allowed to create forum topics * @method bool getCanSendMessages() True, if the user is allowed to send text messages, contacts, locations and venues - * @method bool getCanSendMediaMessages() True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes + * @method bool getCanSendAudios() True, if the user is allowed to send audios + * @method bool getCanSendDocuments() True, if the user is allowed to send documents + * @method bool getCanSendPhotos() True, if the user is allowed to send photos + * @method bool getCanSendVideos() True, if the user is allowed to send videos + * @method bool getCanSendVideoNotes() True, if the user is allowed to send video notes + * @method bool getCanSendVoiceNotes() True, if the user is allowed to send voice notes * @method bool getCanSendPolls() True, if the user is allowed to send polls * @method bool getCanSendOtherMessages() True, if the user is allowed to send animations, games, stickers and use inline bots * @method bool getCanAddWebPagePreviews() True, if the user is allowed to add web page previews to their messages @@ -35,4 +40,21 @@ protected function subEntities(): array 'user' => User::class, ]; } + + /** + * True, if the user is allowed to send audios, documents, photos, videos, video notes OR voice notes + * + * @deprecated Use new fine-grained methods provided by Telegram Bot API. + * + * @return bool + */ + public function getCanSendMediaMessages(): bool + { + return $this->getCanSendAudios() || + $this->getCanSendDocuments() || + $this->getCanSendPhotos() || + $this->getCanSendVideos() || + $this->getCanSendVideoNotes() || + $this->getCanSendVoiceNotes(); + } } diff --git a/src/Entities/ChatPermissions.php b/src/Entities/ChatPermissions.php index c06e61783..504ccea44 100644 --- a/src/Entities/ChatPermissions.php +++ b/src/Entities/ChatPermissions.php @@ -17,7 +17,12 @@ * @link https://core.telegram.org/bots/api#chatpermissions * * @method bool getCanSendMessages() Optional. True, if the user is allowed to send text messages, contacts, locations and venues - * @method bool getCanSendMediaMessages() Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages + * @method bool getCanSendAudios() Optional. True, if the user is allowed to send audios + * @method bool getCanSendDocuments() Optional. True, if the user is allowed to send documents + * @method bool getCanSendPhotos() Optional. True, if the user is allowed to send photos + * @method bool getCanSendVideos() Optional. True, if the user is allowed to send videos + * @method bool getCanSendVideoNotes() Optional. True, if the user is allowed to send video notes + * @method bool getCanSendVoiceNotes() Optional. True, if the user is allowed to send voice notes * @method bool getCanSendPolls() Optional. True, if the user is allowed to send polls, implies can_send_messages * @method bool getCanSendOtherMessages() Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages * @method bool getCanAddWebPagePreviews() Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages @@ -28,5 +33,20 @@ */ class ChatPermissions extends Entity { - + /** + * True, if the user is allowed to send audios, documents, photos, videos, video notes OR voice notes + * + * @deprecated Use new fine-grained methods provided by Telegram Bot API. + * + * @return bool + */ + public function getCanSendMediaMessages(): bool + { + return $this->getCanSendAudios() || + $this->getCanSendDocuments() || + $this->getCanSendPhotos() || + $this->getCanSendVideos() || + $this->getCanSendVideoNotes() || + $this->getCanSendVoiceNotes(); + } } diff --git a/src/Entities/ChatShared.php b/src/Entities/ChatShared.php new file mode 100644 index 000000000..5987d36db --- /dev/null +++ b/src/Entities/ChatShared.php @@ -0,0 +1,18 @@ + KeyboardButtonRequestUser::class, + 'request_chat' => KeyboardButtonRequestChat::class, 'request_poll' => KeyboardButtonPollType::class, 'web_app' => WebAppInfo::class, ]; @@ -61,7 +69,7 @@ protected function subEntities(): array /** * Check if the passed data array could be a KeyboardButton. * - * @param array $data + * @param array $data * * @return bool */ @@ -81,13 +89,15 @@ protected function validate(): void // Make sure only 1 of the optional request fields is set. $field_count = array_filter([ + $this->getRequestUser(), + $this->getRequestChat(), $this->getRequestContact(), $this->getRequestLocation(), $this->getRequestPoll(), $this->getWebApp(), ]); if (count($field_count) > 1) { - throw new TelegramException('You must use only one of these fields: request_contact, request_location, request_poll, web_app!'); + throw new TelegramException('You must use only one of these fields: request_user, request_chat, request_contact, request_location, request_poll, web_app!'); } } @@ -97,8 +107,8 @@ protected function validate(): void public function __call($method, $args) { // Only 1 of these can be set, so clear the others when setting a new one. - if (in_array($method, ['setRequestContact', 'setRequestLocation', 'setRequestPoll', 'setWebApp'], true)) { - unset($this->request_contact, $this->request_location, $this->request_poll, $this->web_app); + if (in_array($method, ['setRequestUser', 'setRequestChat', 'setRequestContact', 'setRequestLocation', 'setRequestPoll', 'setWebApp'], true)) { + unset($this->reqest_user, $this->request_chat, $this->request_contact, $this->request_location, $this->request_poll, $this->web_app); } return parent::__call($method, $args); diff --git a/src/Entities/KeyboardButtonRequestChat.php b/src/Entities/KeyboardButtonRequestChat.php new file mode 100644 index 000000000..02cdf29fe --- /dev/null +++ b/src/Entities/KeyboardButtonRequestChat.php @@ -0,0 +1,33 @@ + __CLASS__, 'invoice' => Invoice::class, 'successful_payment' => SuccessfulPayment::class, + 'user_shared' => UserShared::class, + 'chat_shared' => ChatShared::class, 'write_access_allowed' => WriteAccessAllowed::class, 'passport_data' => PassportData::class, 'proximity_alert_triggered' => ProximityAlertTriggered::class, @@ -280,6 +284,8 @@ public function getType(): string 'pinned_message', 'invoice', 'successful_payment', + 'user_shared', + 'chat_shared', 'write_access_allowed', 'passport_data', 'proximity_alert_triggered', diff --git a/src/Entities/UserShared.php b/src/Entities/UserShared.php new file mode 100644 index 000000000..aac35d2ca --- /dev/null +++ b/src/Entities/UserShared.php @@ -0,0 +1,18 @@ +expectException(TelegramException::class); - $this->expectExceptionMessage('You must use only one of these fields: request_contact, request_location, request_poll, web_app!'); + $this->expectExceptionMessage('You must use only one of these fields: request_user, request_chat, request_contact, request_location, request_poll, web_app!'); new KeyboardButton(['text' => 'message', 'request_contact' => true, 'request_location' => true]); } public function testKeyboardButtonSuccess(): void { new KeyboardButton(['text' => 'message']); + new KeyboardButton(['text' => 'message', 'request_user' => new KeyboardButtonRequestUser([])]); + new KeyboardButton(['text' => 'message', 'request_chat' => new KeyboardButtonRequestChat([])]); new KeyboardButton(['text' => 'message', 'request_contact' => true]); new KeyboardButton(['text' => 'message', 'request_location' => true]); new KeyboardButton(['text' => 'message', 'request_poll' => new KeyboardButtonPollType([])]); @@ -56,49 +60,21 @@ public function testInlineKeyboardButtonCouldBe(): void self::assertFalse(KeyboardButton::couldBe(['no_text' => 'message'])); } - public function testKeyboardButtonParameterSetting(): void + public function testReturnsSubentitiesOnArray() { $button = new KeyboardButton('message'); - self::assertSame('message', $button->getText()); - self::assertEmpty($button->getRequestContact()); - self::assertEmpty($button->getRequestLocation()); - self::assertEmpty($button->getRequestPoll()); - self::assertEmpty($button->getWebApp()); - - $button->setText('new message'); - self::assertSame('new message', $button->getText()); - - $button->setRequestContact(true); - self::assertTrue($button->getRequestContact()); - self::assertEmpty($button->getRequestLocation()); - self::assertEmpty($button->getRequestPoll()); - self::assertEmpty($button->getWebApp()); - - $button->setRequestLocation(true); - self::assertEmpty($button->getRequestContact()); - self::assertTrue($button->getRequestLocation()); - self::assertEmpty($button->getRequestPoll()); - self::assertEmpty($button->getWebApp()); - - $button->setRequestPoll(new KeyboardButtonPollType([])); - self::assertEmpty($button->getRequestContact()); - self::assertEmpty($button->getRequestLocation()); - self::assertInstanceOf(KeyboardButtonPollType::class, $button->getRequestPoll()); - self::assertEmpty($button->getWebApp()); + $button->request_user = []; + $this->assertInstanceOf(KeyboardButtonRequestUser::class, $button->getRequestUser()); - $button->setWebApp(new WebAppInfo([])); - self::assertEmpty($button->getRequestContact()); - self::assertEmpty($button->getRequestLocation()); - self::assertEmpty($button->getRequestPoll()); - self::assertInstanceOf(WebAppInfo::class, $button->getWebApp()); - } + $button = new KeyboardButton('message'); + $button->request_chat = []; + $this->assertInstanceOf(KeyboardButtonRequestChat::class, $button->getRequestChat()); - public function testReturnsSubentitiesOnArray() - { $button = new KeyboardButton('message'); $button->request_poll = []; $this->assertInstanceOf(KeyboardButtonPollType::class, $button->getRequestPoll()); + $button = new KeyboardButton('message'); $button->web_app = []; $this->assertInstanceOf(WebAppInfo::class, $button->getWebApp()); } diff --git a/utils/db-schema-update/0.80.0-unreleased.sql b/utils/db-schema-update/0.80.0-unreleased.sql index 6e9a3a358..4411b1201 100644 --- a/utils/db-schema-update/0.80.0-unreleased.sql +++ b/utils/db-schema-update/0.80.0-unreleased.sql @@ -3,4 +3,6 @@ ALTER TABLE `message` ADD COLUMN `write_access_allowed` TEXT DEFAULT NULL COMMENT 'Service message: the user allowed the bot added to the attachment menu to write messages' AFTER `connected_website`, ADD COLUMN `forum_topic_edited` TEXT DEFAULT NULL COMMENT 'Service message: forum topic edited' AFTER `forum_topic_created`, ADD COLUMN `general_forum_topic_hidden` TEXT DEFAULT NULL COMMENT 'Service message: the General forum topic hidden' AFTER `forum_topic_reopened`, - ADD COLUMN `general_forum_topic_unhidden` TEXT DEFAULT NULL COMMENT 'Service message: the General forum topic unhidden' AFTER `general_forum_topic_hidden`; + ADD COLUMN `general_forum_topic_unhidden` TEXT DEFAULT NULL COMMENT 'Service message: the General forum topic unhidden' AFTER `general_forum_topic_hidden`, + ADD COLUMN `user_shared` TEXT DEFAULT NULL COMMENT 'Optional. Service message: a user was shared with the bot' AFTER `successful_payment`, + ADD COLUMN `chat_shared` TEXT DEFAULT NULL COMMENT 'Optional. Service message: a chat was shared with the bot' AFTER `user_shared`; From 6bcdf199b81a0b1c094839a7e95e09a0d5a7f191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Tue, 25 Apr 2023 02:36:26 +0200 Subject: [PATCH 3/6] Bot API 6.6, thumb to thumbnail rename with helper --- CHANGELOG.md | 2 +- README.md | 10 ++-- src/Entities/Animation.php | 4 +- src/Entities/Audio.php | 4 +- src/Entities/BotDescription.php | 17 ++++++ src/Entities/BotShortDescription.php | 17 ++++++ src/Entities/Document.php | 4 +- src/Entities/Entity.php | 23 +++++++- .../InlineQuery/InlineQueryResultArticle.php | 18 +++--- .../InlineQuery/InlineQueryResultContact.php | 18 +++--- .../InlineQuery/InlineQueryResultDocument.php | 18 +++--- .../InlineQuery/InlineQueryResultGif.php | 8 ++- .../InlineQuery/InlineQueryResultLocation.php | 18 +++--- .../InlineQuery/InlineQueryResultMpeg4Gif.php | 10 ++-- .../InlineQuery/InlineQueryResultVenue.php | 18 +++--- .../InputMedia/InputMediaAnimation.php | 6 +- src/Entities/InputMedia/InputMediaAudio.php | 6 +- .../InputMedia/InputMediaDocument.php | 6 +- src/Entities/InputMedia/InputMediaVideo.php | 6 +- src/Entities/InputSticker.php | 20 +++++++ src/Entities/Sticker.php | 5 +- src/Entities/StickerSet.php | 6 +- src/Entities/Video.php | 4 +- src/Entities/VideoNote.php | 4 +- src/Request.php | 57 +++++++++++++------ 25 files changed, 206 insertions(+), 103 deletions(-) create mode 100644 src/Entities/BotDescription.php create mode 100644 src/Entities/BotShortDescription.php create mode 100644 src/Entities/InputSticker.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 76c4b7bc0..8de9664d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ### Notes - [:ledger: View file changes][Unreleased] ∙ [:page_with_curl: DB migration script][unreleased-sql-migration] ### Added -- Bot API 6.4, 6.5 (@noplanman) +- Bot API 6.4, 6.5, 6.6 (@noplanman) ### Changed ### Deprecated ### Removed diff --git a/README.md b/README.md index 9afcaeb5c..2ae321de3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Telegram Bot based on the official [Telegram Bot API] -[![API Version](https://img.shields.io/badge/Bot%20API-6.5%20%28February%20322%29-32a2da.svg)](https://core.telegram.org/bots/api-changelog#february-3-2023) +[![API Version](https://img.shields.io/badge/Bot%20API-6.6%20%28March%202023%29-32a2da.svg)](https://core.telegram.org/bots/api-changelog#march-9-2023) [![Join the bot support group on Telegram](https://img.shields.io/badge/telegram-@PHP__Telegram__Bot__Support-64659d.svg)](https://telegram.me/PHP_Telegram_Bot_Support) [![Donate](https://img.shields.io/badge/%F0%9F%92%99-Donate%20%2F%20Support%20Us-blue.svg)](#donate) @@ -78,7 +78,7 @@ This Bot aims to provide a platform where one can simply write a bot and have in The Bot can: - Retrieve updates with [webhook](#webhook-installation) and [getUpdates](#getupdates-installation) methods. -- Supports all types and methods according to Telegram Bot API 6.5 (February 2023). +- Supports all types and methods according to Telegram Bot API 6.6 (March 2023). - Supports supergroups. - Handle commands in chat with other bots. - Manage Channel from the bot admin interface. @@ -389,15 +389,15 @@ The reason for denying an update can be defined with the `$reason` parameter. Th ### Types -All types are implemented according to Telegram API 6.5 (February 2023). +All types are implemented according to Telegram API 6.6 (March 2023). ### Inline Query -Full support for inline query according to Telegram API 6.5 (February 2023). +Full support for inline query according to Telegram API 6.6 (March 2023). ### Methods -All methods are implemented according to Telegram API 6.5 (February 2023). +All methods are implemented according to Telegram API 6.6 (March 2023). #### Send Message diff --git a/src/Entities/Animation.php b/src/Entities/Animation.php index 95538206f..83b012a29 100644 --- a/src/Entities/Animation.php +++ b/src/Entities/Animation.php @@ -23,7 +23,7 @@ * @method int getWidth() Video width as defined by sender * @method int getHeight() Video height as defined by sender * @method int getDuration() Duration of the video in seconds as defined by sender - * @method PhotoSize getThumb() Optional. Animation thumbnail as defined by sender + * @method PhotoSize getThumbnail() Optional. Animation thumbnail as defined by sender * @method string getFileName() Optional. Original animation filename as defined by sender * @method string getMimeType() Optional. MIME type of the file as defined by sender * @method int getFileSize() Optional. File size @@ -36,7 +36,7 @@ class Animation extends Entity protected function subEntities(): array { return [ - 'thumb' => PhotoSize::class, + 'thumbnail' => PhotoSize::class, ]; } } diff --git a/src/Entities/Audio.php b/src/Entities/Audio.php index 2a1d10344..91d1359ba 100644 --- a/src/Entities/Audio.php +++ b/src/Entities/Audio.php @@ -24,7 +24,7 @@ * @method string getFileName() Optional. Original filename as defined by sender * @method string getMimeType() Optional. MIME type of the file as defined by sender * @method int getFileSize() Optional. File size - * @method PhotoSize getThumb() Optional. Thumbnail of the album cover to which the music file belongs + * @method PhotoSize getThumbnail() Optional. Thumbnail of the album cover to which the music file belongs */ class Audio extends Entity { @@ -34,7 +34,7 @@ class Audio extends Entity protected function subEntities(): array { return [ - 'thumb' => PhotoSize::class, + 'thumbnail' => PhotoSize::class, ]; } } diff --git a/src/Entities/BotDescription.php b/src/Entities/BotDescription.php new file mode 100644 index 000000000..ec1d72d27 --- /dev/null +++ b/src/Entities/BotDescription.php @@ -0,0 +1,17 @@ + PhotoSize::class, + 'thumbnail' => PhotoSize::class, ]; } } diff --git a/src/Entities/Entity.php b/src/Entities/Entity.php index 8b043ceb0..7a01b2794 100644 --- a/src/Entities/Entity.php +++ b/src/Entities/Entity.php @@ -26,7 +26,7 @@ */ abstract class Entity implements \JsonSerializable { - + public static $fixThumbnailRename = true; /** * Entity constructor. @@ -96,6 +96,7 @@ public function __toString() protected function assignMemberVariables(array $data): void { foreach ($data as $key => $value) { + $key = $this->fixThumbnailRename($key); $this->$key = $value; } } @@ -140,8 +141,11 @@ public function getProperty(string $property, $default = null) */ public function __call($method, $args) { + $method = $this->fixThumbnailRename($method); + //Convert method to snake_case (which is the name of the property) $property_name = mb_strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', substr($method, 3)), '_')); + $property_name = $this->fixThumbnailRename($property_name); $action = substr($method, 0, 3); if ($action === 'get') { @@ -176,6 +180,23 @@ public function __call($method, $args) return null; } + /** + * BC for renamed thumb -> thumbnail methods and fields + * + * @todo Remove after a few versions. + * + * @param string $name + * @return string + */ + protected function fixThumbnailRename(string $name): string + { + return self::$fixThumbnailRename ? preg_replace('/([Tt])humb(nail)?/', '$1humbnail', $name, -1, $count) : $name; + + /*if ($count) { + // Notify user that there are still outdated method calls? + }*/ + } + /** * Return an array of nice objects from an array of object arrays * diff --git a/src/Entities/InlineQuery/InlineQueryResultArticle.php b/src/Entities/InlineQuery/InlineQueryResultArticle.php index 911dd47af..70ef6604e 100644 --- a/src/Entities/InlineQuery/InlineQueryResultArticle.php +++ b/src/Entities/InlineQuery/InlineQueryResultArticle.php @@ -28,9 +28,9 @@ * 'url' => '', * 'hide_url' => true, * 'description' => '', - * 'thumb_url' => '', - * 'thumb_width' => 30, - * 'thumb_height' => 30, + * 'thumbnail_url' => '', + * 'thumbnail_width' => 30, + * 'thumbnail_height' => 30, * ]; * * @@ -42,9 +42,9 @@ * @method string getUrl() Optional. URL of the result * @method bool getHideUrl() Optional. Pass True, if you don't want the URL to be shown in the message * @method string getDescription() Optional. Short description of the result - * @method string getThumbUrl() Optional. Url of the thumbnail for the result - * @method int getThumbWidth() Optional. Thumbnail width - * @method int getThumbHeight() Optional. Thumbnail height + * @method string getThumbnailUrl() Optional. Url of the thumbnail for the result + * @method int getThumbnailWidth() Optional. Thumbnail width + * @method int getThumbnailHeight() Optional. Thumbnail height * * @method $this setId(string $id) Unique identifier for this result, 1-64 Bytes * @method $this setTitle(string $title) Title of the result @@ -53,9 +53,9 @@ * @method $this setUrl(string $url) Optional. URL of the result * @method $this setHideUrl(bool $hide_url) Optional. Pass True, if you don't want the URL to be shown in the message * @method $this setDescription(string $description) Optional. Short description of the result - * @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result - * @method $this setThumbWidth(int $thumb_width) Optional. Thumbnail width - * @method $this setThumbHeight(int $thumb_height) Optional. Thumbnail height + * @method $this setThumbnailUrl(string $thumbnail_url) Optional. Url of the thumbnail for the result + * @method $this setThumbnailWidth(int $thumbnail_width) Optional. Thumbnail width + * @method $this setThumbnailHeight(int $thumbnail_height) Optional. Thumbnail height */ class InlineQueryResultArticle extends InlineEntity implements InlineQueryResult { diff --git a/src/Entities/InlineQuery/InlineQueryResultContact.php b/src/Entities/InlineQuery/InlineQueryResultContact.php index 604c7b437..b4d6cfa85 100644 --- a/src/Entities/InlineQuery/InlineQueryResultContact.php +++ b/src/Entities/InlineQuery/InlineQueryResultContact.php @@ -27,9 +27,9 @@ * 'last_name' => '', * 'reply_markup' => , * 'input_message_content' => , - * 'thumb_url' => '', - * 'thumb_width' => 30, - * 'thumb_height' => 30, + * 'thumbnail_url' => '', + * 'thumbnail_width' => 30, + * 'thumbnail_height' => 30, * ]; * * @@ -41,9 +41,9 @@ * @method string getVcard() Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes * @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message * @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the contact - * @method string getThumbUrl() Optional. Url of the thumbnail for the result - * @method int getThumbWidth() Optional. Thumbnail width - * @method int getThumbHeight() Optional. Thumbnail height + * @method string getThumbnailUrl() Optional. Url of the thumbnail for the result + * @method int getThumbnailWidth() Optional. Thumbnail width + * @method int getThumbnailHeight() Optional. Thumbnail height * * @method $this setId(string $id) Unique identifier for this result, 1-64 Bytes * @method $this setPhoneNumber(string $phone_number) Contact's phone number @@ -52,9 +52,9 @@ * @method $this setVcard(string $vcard) Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes * @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message * @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the contact - * @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result - * @method $this setThumbWidth(int $thumb_width) Optional. Thumbnail width - * @method $this setThumbHeight(int $thumb_height) Optional. Thumbnail height + * @method $this setThumbnailUrl(string $thumbnail_url) Optional. Url of the thumbnail for the result + * @method $this setThumbnailWidth(int $thumbnail_width) Optional. Thumbnail width + * @method $this setThumbnailHeight(int $thumbnail_height) Optional. Thumbnail height */ class InlineQueryResultContact extends InlineEntity implements InlineQueryResult { diff --git a/src/Entities/InlineQuery/InlineQueryResultDocument.php b/src/Entities/InlineQuery/InlineQueryResultDocument.php index 5ce9c208f..8db76febe 100644 --- a/src/Entities/InlineQuery/InlineQueryResultDocument.php +++ b/src/Entities/InlineQuery/InlineQueryResultDocument.php @@ -29,9 +29,9 @@ * 'description' => '', * 'reply_markup' => , * 'input_message_content' => , - * 'thumb_url' => '', - * 'thumb_width' => 30, - * 'thumb_height' => 30, + * 'thumbnail_url' => '', + * 'thumbnail_width' => 30, + * 'thumbnail_height' => 30, * ]; * * @@ -46,9 +46,9 @@ * @method string getDescription() Optional. Short description of the result * @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message * @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the file - * @method string getThumbUrl() Optional. URL of the thumbnail (jpeg only) for the file - * @method int getThumbWidth() Optional. Thumbnail width - * @method int getThumbHeight() Optional. Thumbnail height + * @method string getThumbnailUrl() Optional. URL of the thumbnail (jpeg only) for the file + * @method int getThumbnailWidth() Optional. Thumbnail width + * @method int getThumbnailHeight() Optional. Thumbnail height * * @method $this setId(string $id) Unique identifier for this result, 1-64 bytes * @method $this setTitle(string $title) Title for the result @@ -60,9 +60,9 @@ * @method $this setDescription(string $description) Optional. Short description of the result * @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message * @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the file - * @method $this setThumbUrl(string $thumb_url) Optional. URL of the thumbnail (jpeg only) for the file - * @method $this setThumbWidth(int $thumb_width) Optional. Thumbnail width - * @method $this setThumbHeight(int $thumb_height) Optional. Thumbnail height + * @method $this setThumbnailUrl(string $thumbnail_url) Optional. URL of the thumbnail (jpeg only) for the file + * @method $this setThumbnailWidth(int $thumbnail_width) Optional. Thumbnail width + * @method $this setThumbnailHeight(int $thumbnail_height) Optional. Thumbnail height */ class InlineQueryResultDocument extends InlineEntity implements InlineQueryResult { diff --git a/src/Entities/InlineQuery/InlineQueryResultGif.php b/src/Entities/InlineQuery/InlineQueryResultGif.php index f3d502441..34c9810cc 100644 --- a/src/Entities/InlineQuery/InlineQueryResultGif.php +++ b/src/Entities/InlineQuery/InlineQueryResultGif.php @@ -25,7 +25,7 @@ * 'gif_url' => '', * 'gif_width' => 30, * 'gif_height' => 30, - * 'thumb_url' => '', + * 'thumbnail_url' => '', * 'title' => '', * 'caption' => '', * 'reply_markup' => , @@ -39,7 +39,8 @@ * @method int getGifWidth() Optional. Width of the GIF * @method int getGifHeight() Optional. Height of the GIF * @method int getGifDuration() Optional. Duration of the GIF - * @method string getThumbUrl() URL of the static thumbnail for the result (jpeg or gif) + * @method string getThumbnailUrl() URL of the static thumbnail for the result (jpeg or gif) + * @method string getThumbnailMimeType() Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” * @method string getTitle() Optional. Title for the result * @method string getCaption() Optional. Caption of the GIF file to be sent, 0-200 characters * @method string getParseMode() Optional. Mode for parsing entities in the caption @@ -52,7 +53,8 @@ * @method $this setGifWidth(int $gif_width) Optional. Width of the GIF * @method $this setGifHeight(int $gif_height) Optional. Height of the GIF * @method $this setGifDuration(int $gif_duration) Optional. Duration of the GIF - * @method $this setThumbUrl(string $thumb_url) URL of the static thumbnail for the result (jpeg or gif) + * @method $this setThumbnailUrl(string $thumbnail_url) URL of the static thumbnail for the result (jpeg or gif) + * @method $this setThumbnailMimeType(string $thumbnail_mime_type) Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” * @method $this setTitle(string $title) Optional. Title for the result * @method $this setCaption(string $caption) Optional. Caption of the GIF file to be sent, 0-200 characters * @method $this setParseMode(string $parse_mode) Optional. Mode for parsing entities in the caption diff --git a/src/Entities/InlineQuery/InlineQueryResultLocation.php b/src/Entities/InlineQuery/InlineQueryResultLocation.php index be57f72f1..888556d4b 100644 --- a/src/Entities/InlineQuery/InlineQueryResultLocation.php +++ b/src/Entities/InlineQuery/InlineQueryResultLocation.php @@ -31,9 +31,9 @@ * 'proximity_alert_radius' => 300, * 'reply_markup' => , * 'input_message_content' => , - * 'thumb_url' => '', - * 'thumb_width' => 30, - * 'thumb_height' => 30, + * 'thumbnail_url' => '', + * 'thumbnail_width' => 30, + * 'thumbnail_height' => 30, * ]; * * @@ -48,9 +48,9 @@ * @method int getProximityAlertRadius() Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. * @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message * @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the location - * @method string getThumbUrl() Optional. Url of the thumbnail for the result - * @method int getThumbWidth() Optional. Thumbnail width - * @method int getThumbHeight() Optional. Thumbnail height + * @method string getThumbnailUrl() Optional. Url of the thumbnail for the result + * @method int getThumbnailWidth() Optional. Thumbnail width + * @method int getThumbnailHeight() Optional. Thumbnail height * * @method $this setId(string $id) Unique identifier for this result, 1-64 Bytes * @method $this setLatitude(float $latitude) Location latitude in degrees @@ -62,9 +62,9 @@ * @method $this setProximityAlertRadius(int $proximity_alert_radius) Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. * @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message * @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the location - * @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result - * @method $this setThumbWidth(int $thumb_width) Optional. Thumbnail width - * @method $this setThumbHeight(int $thumb_height) Optional. Thumbnail height + * @method $this setThumbnailUrl(string $thumbnail_url) Optional. Url of the thumbnail for the result + * @method $this setThumbnailWidth(int $thumbnail_width) Optional. Thumbnail width + * @method $this setThumbnailHeight(int $thumbnail_height) Optional. Thumbnail height */ class InlineQueryResultLocation extends InlineEntity implements InlineQueryResult { diff --git a/src/Entities/InlineQuery/InlineQueryResultMpeg4Gif.php b/src/Entities/InlineQuery/InlineQueryResultMpeg4Gif.php index 195f8a2b8..01015eeca 100644 --- a/src/Entities/InlineQuery/InlineQueryResultMpeg4Gif.php +++ b/src/Entities/InlineQuery/InlineQueryResultMpeg4Gif.php @@ -25,7 +25,7 @@ * 'mpeg4_url' => '', * 'mpeg4_width' => 30, * 'mpeg4_height' => 30, - * 'thumb_url' => '', + * 'thumbnail_url' => '', * 'title' => '', * 'caption' => '', * 'reply_markup' => , @@ -39,8 +39,8 @@ * @method int getMpeg4Width() Optional. Video width * @method int getMpeg4Height() Optional. Video height * @method int getMpeg4Duration() Optional. Video duration - * @method string getThumbUrl() URL of the static thumbnail (jpeg or gif) for the result - * @method string getThumbMimeType() Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” + * @method string getThumbnailUrl() URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + * @method string getThumbnailMimeType() Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” * @method string getTitle() Optional. Title for the result * @method string getCaption() Optional. Caption of the MPEG-4 file to be sent, 0-200 characters * @method string getParseMode() Optional. Mode for parsing entities in the caption @@ -53,8 +53,8 @@ * @method $this setMpeg4Width(int $mpeg4_width) Optional. Video width * @method $this setMpeg4Height(int $mpeg4_height) Optional. Video height * @method $this setMpeg4Duration(int $mpeg4_duration) Optional. Video duration - * @method $this setThumbUrl(string $thumb_url) URL of the static thumbnail (jpeg or gif) for the result - * @method $this setThumbMimeType(string $thumb_mime_type) Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” + * @method $this setThumbnailUrl(string $thumbnail_url) URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + * @method $this setThumbnailMimeType(string $thumbnail_mime_type) Optional. MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” * @method $this setTitle(string $title) Optional. Title for the result * @method $this setCaption(string $caption) Optional. Caption of the MPEG-4 file to be sent, 0-200 characters * @method $this setParseMode(string $parse_mode) Optional. Mode for parsing entities in the caption diff --git a/src/Entities/InlineQuery/InlineQueryResultVenue.php b/src/Entities/InlineQuery/InlineQueryResultVenue.php index 04d8091b3..8ab428b00 100644 --- a/src/Entities/InlineQuery/InlineQueryResultVenue.php +++ b/src/Entities/InlineQuery/InlineQueryResultVenue.php @@ -29,9 +29,9 @@ * 'foursquare_id' => '', * 'reply_markup' => , * 'input_message_content' => , - * 'thumb_url' => '', - * 'thumb_width' => 30, - * 'thumb_height' => 30, + * 'thumbnail_url' => '', + * 'thumbnail_width' => 30, + * 'thumbnail_height' => 30, * ]; * * @@ -47,9 +47,9 @@ * @method string getGooglePlaceType() Optional. Google Places type of the venue * @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message * @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the venue - * @method string getThumbUrl() Optional. Url of the thumbnail for the result - * @method int getThumbWidth() Optional. Thumbnail width - * @method int getThumbHeight() Optional. Thumbnail height + * @method string getThumbnailUrl() Optional. Url of the thumbnail for the result + * @method int getThumbnailWidth() Optional. Thumbnail width + * @method int getThumbnailHeight() Optional. Thumbnail height * * @method $this setId(string $id) Unique identifier for this result, 1-64 Bytes * @method $this setLatitude(float $latitude) Latitude of the venue location in degrees @@ -62,9 +62,9 @@ * @method $this setGooglePlaceType(string $google_place_type) Optional. Google Places type of the venue * @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message * @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the venue - * @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result - * @method $this setThumbWidth(int $thumb_width) Optional. Thumbnail width - * @method $this setThumbHeight(int $thumb_height) Optional. Thumbnail height + * @method $this setThumbnailUrl(string $thumbnail_url) Optional. Url of the thumbnail for the result + * @method $this setThumbnailWidth(int $thumbnail_width) Optional. Thumbnail width + * @method $this setThumbnailHeight(int $thumbnail_height) Optional. Thumbnail height */ class InlineQueryResultVenue extends InlineEntity implements InlineQueryResult { diff --git a/src/Entities/InputMedia/InputMediaAnimation.php b/src/Entities/InputMedia/InputMediaAnimation.php index c0a693e58..7671923cb 100644 --- a/src/Entities/InputMedia/InputMediaAnimation.php +++ b/src/Entities/InputMedia/InputMediaAnimation.php @@ -21,7 +21,7 @@ * * $data = [ * 'media' => '123abc', - * 'thumb' => '456def', + * 'thumbnail' => '456def', * 'caption' => '*Animation* caption', * 'parse_mode' => 'markdown', * 'width' => 200, @@ -32,7 +32,7 @@ * * @method string getType() Type of the result, must be animation * @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » - * @method string getThumb() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @method string getThumbnail() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » * @method string getCaption() Optional. Caption of the animation to be sent, 0-200 characters * @method string getParseMode() Optional. Mode for parsing entities in the animation caption * @method MessageEntity[] getCaptionEntities() Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode @@ -42,7 +42,7 @@ * @method bool getHasSpoiler() Optional. Pass True if the animation needs to be covered with a spoiler animation * * @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » - * @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @method $this setThumbnail(string $thumbnail) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » * @method $this setCaption(string $caption) Optional. Caption of the animation to be sent, 0-200 characters * @method $this setParseMode(string $parse_mode) Optional. Mode for parsing entities in the animation caption * @method $this setCaptionEntities(array $caption_entities) Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode diff --git a/src/Entities/InputMedia/InputMediaAudio.php b/src/Entities/InputMedia/InputMediaAudio.php index 0ec2ea823..a992095fe 100644 --- a/src/Entities/InputMedia/InputMediaAudio.php +++ b/src/Entities/InputMedia/InputMediaAudio.php @@ -21,7 +21,7 @@ * * $data = [ * 'media' => '123abc', - * 'thumb' => '456def', + * 'thumbnail' => '456def', * 'caption' => '*Audio* caption', * 'parse_mode' => 'markdown', * 'duration' => 42, @@ -32,7 +32,7 @@ * * @method string getType() Type of the result, must be audio * @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. - * @method string getThumb() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @method string getThumbnail() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » * @method string getCaption() Optional. Caption of the audio to be sent, 0-200 characters * @method string getParseMode() Optional. Mode for parsing entities in the audio caption * @method MessageEntity[] getCaptionEntities() Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode @@ -41,7 +41,7 @@ * @method string getTitle() Optional. Title of the audio * * @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. - * @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @method $this setThumbnail(string $thumbnail) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » * @method $this setCaption(string $caption) Optional. Caption of the audio to be sent, 0-200 characters * @method $this setParseMode(string $parse_mode) Optional. Mode for parsing entities in the audio caption * @method $this setCaptionEntities(array $caption_entities) Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode diff --git a/src/Entities/InputMedia/InputMediaDocument.php b/src/Entities/InputMedia/InputMediaDocument.php index 970fcffcb..138e43e8d 100644 --- a/src/Entities/InputMedia/InputMediaDocument.php +++ b/src/Entities/InputMedia/InputMediaDocument.php @@ -21,7 +21,7 @@ * * $data = [ * 'media' => '123abc', - * 'thumb' => '456def', + * 'thumbnail' => '456def', * 'caption' => '*Document* caption', * 'parse_mode' => 'markdown', * ]; @@ -29,14 +29,14 @@ * * @method string getType() Type of the result, must be document * @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. - * @method string getThumb() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @method string getThumbnail() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » * @method string getCaption() Optional. Caption of the document to be sent, 0-200 characters * @method string getParseMode() Optional. Mode for parsing entities in the document caption * @method MessageEntity[] getCaptionEntities() Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode * @method bool getDisableContentTypeDetection() Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always true, if the document is sent as part of an album. * * @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. - * @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @method $this setThumbnail(string $thumbnail) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » * @method $this setCaption(string $caption) Optional. Caption of the document to be sent, 0-200 characters * @method $this setParseMode(string $parse_mode) Optional. Mode for parsing entities in the document caption * @method $this setCaptionEntities(array $caption_entities) Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode diff --git a/src/Entities/InputMedia/InputMediaVideo.php b/src/Entities/InputMedia/InputMediaVideo.php index 18db177fe..3bc10652d 100644 --- a/src/Entities/InputMedia/InputMediaVideo.php +++ b/src/Entities/InputMedia/InputMediaVideo.php @@ -21,7 +21,7 @@ * * $data = [ * 'media' => '123abc', - * 'thumb' => '456def', + * 'thumbnail' => '456def', * 'caption' => '*Video* caption (streamable)', * 'parse_mode' => 'markdown', * 'width' => 800, @@ -33,7 +33,7 @@ * * @method string getType() Type of the result, must be video * @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. - * @method string getThumb() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @method string getThumbnail() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » * @method string getCaption() Optional. Caption of the video to be sent, 0-200 characters * @method string getParseMode() Optional. Mode for parsing entities in the video caption * @method MessageEntity[] getCaptionEntities() Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode @@ -44,7 +44,7 @@ * @method bool getHasSpoiler() Optional. Pass True if the video needs to be covered with a spoiler animation * * @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. - * @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @method $this setThumbnail(string $thumbnail) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » * @method $this setCaption(string $caption) Optional. Caption of the video to be sent, 0-200 characters * @method $this setParseMode(string $parse_mode) Optional. Mode for parsing entities in the video caption * @method $this setCaptionEntities(array $caption_entities) Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode diff --git a/src/Entities/InputSticker.php b/src/Entities/InputSticker.php new file mode 100644 index 000000000..2fa40e018 --- /dev/null +++ b/src/Entities/InputSticker.php @@ -0,0 +1,20 @@ +” to upload a new one using multipart/form-data under name. Animated and video stickers can't be uploaded via HTTP URL. More information on Sending Files » + * @method string[] getEmojiList() List of 1-20 emoji associated with the sticker + * @method MaskPosition getMaskPosition() Optional. Position where the mask should be placed on faces. For “mask” stickers only. + * @method string[] getKeywords() Optional. List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only. + */ +class InputSticker extends Entity +{ + +} diff --git a/src/Entities/Sticker.php b/src/Entities/Sticker.php index 94cafd706..3671c9523 100644 --- a/src/Entities/Sticker.php +++ b/src/Entities/Sticker.php @@ -23,12 +23,13 @@ * @method int getHeight() Sticker height * @method bool getIsAnimated() True, if the sticker is animated * @method bool getIsVideo() True, if the sticker is a video sticker - * @method PhotoSize getThumb() Optional. Sticker thumbnail in .webp or .jpg format + * @method PhotoSize getThumbnail() Optional. Sticker thumbnail in .webp or .jpg format * @method string getEmoji() Optional. Emoji associated with the sticker * @method string getSetName() Optional. Name of the sticker set to which the sticker belongs * @method File getPremiumAnimation() Optional. Premium animation for the sticker, if the sticker is premium * @method MaskPosition getMaskPosition() Optional. For mask stickers, the position where the mask should be placed * @method string getCustomEmojiId() Optional. For custom emoji stickers, unique identifier of the custom emoji + * @method bool getNeedsRepainting() Optional. True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, white color on chat photos, or another appropriate color in other places * @method int getFileSize() Optional. File size */ class Sticker extends Entity @@ -39,7 +40,7 @@ class Sticker extends Entity protected function subEntities(): array { return [ - 'thumb' => PhotoSize::class, + 'thumbnail' => PhotoSize::class, 'premium_animation' => File::class, 'mask_position' => MaskPosition::class, ]; diff --git a/src/Entities/StickerSet.php b/src/Entities/StickerSet.php index 773ccdbdb..8bb35ec4d 100644 --- a/src/Entities/StickerSet.php +++ b/src/Entities/StickerSet.php @@ -22,7 +22,7 @@ * @method bool getIsAnimated() True, if the sticker set contains animated stickers * @method bool getIsVideo() True, if the sticker set contains video stickers * @method Sticker[] getStickers() List of all set stickers - * @method PhotoSize getThumb() Optional. Sticker set thumbnail in the .WEBP or .TGS format + * @method PhotoSize getThumbnail() Optional. Sticker set thumbnail in the .WEBP or .TGS format */ class StickerSet extends Entity { @@ -32,8 +32,8 @@ class StickerSet extends Entity protected function subEntities(): array { return [ - 'stickers' => [Sticker::class], - 'thumb' => PhotoSize::class, + 'stickers' => [Sticker::class], + 'thumbnail' => PhotoSize::class, ]; } } diff --git a/src/Entities/Video.php b/src/Entities/Video.php index 9214c4f94..972f04da8 100644 --- a/src/Entities/Video.php +++ b/src/Entities/Video.php @@ -21,7 +21,7 @@ * @method int getWidth() Video width as defined by sender * @method int getHeight() Video height as defined by sender * @method int getDuration() Duration of the video in seconds as defined by sender - * @method PhotoSize getThumb() Optional. Video thumbnail + * @method PhotoSize getThumbnail() Optional. Video thumbnail * @method string getFileName() Optional. Original filename as defined by sender * @method string getMimeType() Optional. Mime type of a file as defined by sender * @method int getFileSize() Optional. File size @@ -34,7 +34,7 @@ class Video extends Entity protected function subEntities(): array { return [ - 'thumb' => PhotoSize::class, + 'thumbnail' => PhotoSize::class, ]; } } diff --git a/src/Entities/VideoNote.php b/src/Entities/VideoNote.php index aa4ee23f2..164934967 100644 --- a/src/Entities/VideoNote.php +++ b/src/Entities/VideoNote.php @@ -20,7 +20,7 @@ * @method string getFileUniqueId() Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. * @method int getLength() Video width and height as defined by sender * @method int getDuration() Duration of the audio in seconds as defined by sender - * @method PhotoSize getThumb() Optional. Video thumbnail as defined by sender + * @method PhotoSize getThumbnail() Optional. Video thumbnail as defined by sender * @method int getFileSize() Optional. File size */ class VideoNote extends Entity @@ -31,7 +31,7 @@ class VideoNote extends Entity protected function subEntities(): array { return [ - 'thumb' => PhotoSize::class, + 'thumbnail' => PhotoSize::class, ]; } } diff --git a/src/Request.php b/src/Request.php index 51336f5ff..75f93a77c 100644 --- a/src/Request.php +++ b/src/Request.php @@ -99,6 +99,10 @@ * @method static ServerResponse setMyCommands(array $data) Use this method to change the list of the bot's commands. Returns True on success. * @method static ServerResponse deleteMyCommands(array $data) Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success. * @method static ServerResponse getMyCommands(array $data) Use this method to get the current list of the bot's commands. Requires no parameters. Returns Array of BotCommand on success. + * @method static ServerResponse setMyDescription(array $data) Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success. + * @method static ServerResponse getMyDescription(array $data) Use this method to get the current bot description for the given user language. Returns BotDescription on success. + * @method static ServerResponse setMyShortDescription(array $data) Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success. + * @method static ServerResponse getMyShortDescription(array $data) Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success. * @method static ServerResponse setChatMenuButton(array $data) Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. * @method static ServerResponse getChatMenuButton(array $data) Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. * @method static ServerResponse setMyDefaultAdministratorRights(array $data) Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns True on success. @@ -116,7 +120,13 @@ * @method static ServerResponse addStickerToSet(array $data) Use this method to add a new sticker to a set created by the bot. Returns True on success. * @method static ServerResponse setStickerPositionInSet(array $data) Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. * @method static ServerResponse deleteStickerFromSet(array $data) Use this method to delete a sticker from a set created by the bot. Returns True on success. - * @method static ServerResponse setStickerSetThumb(array $data) Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success. + * @method static ServerResponse setStickerEmojiList(array $data) Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. + * @method static ServerResponse setStickerKeywords(array $data) Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. + * @method static ServerResponse setStickerMaskPosition(array $data) Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success. + * @method static ServerResponse setStickerSetTitle(array $data) Use this method to set the title of a created sticker set. Returns True on success. + * @method static ServerResponse setStickerSetThumbnail(array $data) Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success. + * @method static ServerResponse setCustomEmojiStickerSetThumbnail(array $data) Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success. + * @method static ServerResponse deleteStickerSet(array $data) Use this method to delete a sticker set that was created by the bot. Returns True on success. * @method static ServerResponse answerWebAppQuery(array $data) Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned. * @method static ServerResponse sendInvoice(array $data) Use this method to send invoices. On success, the sent Message is returned. * @method static ServerResponse createInvoiceLink(array $data) Use this method to create a link for an invoice. Returns the created invoice link as String on success. @@ -262,6 +272,10 @@ class Request 'setMyCommands', 'deleteMyCommands', 'getMyCommands', + 'setMyDescription', + 'getMyDescription', + 'setMyShortDescription', + 'getMyShortDescription', 'setChatMenuButton', 'getChatMenuButton', 'setMyDefaultAdministratorRights', @@ -279,7 +293,13 @@ class Request 'addStickerToSet', 'setStickerPositionInSet', 'deleteStickerFromSet', - 'setStickerSetThumb', + 'setStickerEmojiList', + 'setStickerKeywords', + 'setStickerMaskPosition', + 'setStickerSetTitle', + 'setStickerSetThumbnail', + 'setCustomEmojiStickerSetThumbnail', + 'deleteStickerSet', 'answerWebAppQuery', 'sendInvoice', 'createInvoiceLink', @@ -292,7 +312,7 @@ class Request ]; /** - * Some methods need a dummy param due to certain cURL issues. + * Methods that don't require any data need a dummy param due to certain cURL issues. * * @see Request::addDummyParamIfNecessary() * @@ -306,6 +326,10 @@ class Request 'close', 'deleteMyCommands', 'getMyCommands', + 'setMyDescription', + 'getMyDescription', + 'setMyShortDescription', + 'getMyShortDescription', 'setChatMenuButton', 'getChatMenuButton', 'setMyDefaultAdministratorRights', @@ -316,25 +340,26 @@ class Request * Available fields for InputFile helper * * This is basically the list of all fields that allow InputFile objects - * for which input can be simplified by providing local path directly as string. + * for which input can be simplified by providing local path directly as string. * * @var array */ private static $input_file_fields = [ 'setWebhook' => ['certificate'], 'sendPhoto' => ['photo'], - 'sendAudio' => ['audio', 'thumb'], - 'sendDocument' => ['document', 'thumb'], - 'sendVideo' => ['video', 'thumb'], - 'sendAnimation' => ['animation', 'thumb'], - 'sendVoice' => ['voice', 'thumb'], - 'sendVideoNote' => ['video_note', 'thumb'], + 'sendAudio' => ['audio', 'thumbnail'], + 'sendDocument' => ['document', 'thumbnail'], + 'sendVideo' => ['video', 'thumbnail'], + 'sendAnimation' => ['animation', 'thumbnail'], + 'sendVoice' => ['voice'], + 'sendVideoNote' => ['video_note', 'thumbnail'], 'setChatPhoto' => ['photo'], 'sendSticker' => ['sticker'], - 'uploadStickerFile' => ['png_sticker'], - 'createNewStickerSet' => ['png_sticker', 'tgs_sticker', 'webm_sticker'], - 'addStickerToSet' => ['png_sticker', 'tgs_sticker', 'webm_sticker'], - 'setStickerSetThumb' => ['thumb'], + 'uploadStickerFile' => ['sticker'], + // @todo Look into new InputSticker field and see if we can do the same there. + // 'createNewStickerSet' => ['png_sticker', 'tgs_sticker', 'webm_sticker'], + // 'addStickerToSet' => ['png_sticker', 'tgs_sticker', 'webm_sticker'], + 'setStickerSetThumbnail' => ['thumbnail'], ]; /** @@ -513,8 +538,8 @@ private static function mediaInputHelper($item, bool &$has_resource, array &$mul // Make a list of all possible media that can be handled by the helper. $possible_medias = array_filter([ - 'media' => $media_item->getMedia(), - 'thumb' => $media_item->getThumb(), + 'media' => $media_item->getMedia(), + 'thumbnail' => $media_item->getThumbnail(), ]); foreach ($possible_medias as $type => $media) { From ed7b35025846373c33f9318d521a6536ecb78410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Tue, 25 Apr 2023 02:39:23 +0200 Subject: [PATCH 4/6] Return more explicit entities as the ServerResponse result --- src/Entities/ServerResponse.php | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Entities/ServerResponse.php b/src/Entities/ServerResponse.php index 3ac4c3a54..3ff9ffa9b 100644 --- a/src/Entities/ServerResponse.php +++ b/src/Entities/ServerResponse.php @@ -107,21 +107,24 @@ public function printError($return = false) * @param array $result * @param string $bot_username * - * @return Chat|ChatMember|File|Message|User|UserProfilePhotos|WebhookInfo + * @return BotDescription|BotShortDescription|Chat|ChatAdministratorRights|ChatMember|File|Message|MenuButton|Poll|SentWebAppMessage|StickerSet|User|UserProfilePhotos|WebhookInfo */ private function createResultObject(array $result, string $bot_username): Entity { $result_object_types = [ - 'answerWebAppQuery' => SentWebAppMessage::class, + 'getWebhookInfo' => WebhookInfo::class, + 'getMe' => User::class, + 'getUserProfilePhotos' => UserProfilePhotos::class, + 'getFile' => File::class, 'getChat' => Chat::class, - 'getMyDefaultAdministratorRights' => ChatAdministratorRights::class, 'getChatMember' => ChatMemberFactory::class, + 'getMyDescription' => BotDescription::class, + 'getMyShortDescription' => BotShortDescription::class, 'getChatMenuButton' => MenuButtonFactory::class, - 'getFile' => File::class, - 'getMe' => User::class, + 'getMyDefaultAdministratorRights' => ChatAdministratorRights::class, 'getStickerSet' => StickerSet::class, - 'getUserProfilePhotos' => UserProfilePhotos::class, - 'getWebhookInfo' => WebhookInfo::class, + 'stopPoll' => Poll::class, + 'answerWebAppQuery' => SentWebAppMessage::class, ]; $action = Request::getCurrentAction(); @@ -139,15 +142,18 @@ private function createResultObject(array $result, string $bot_username): Entity * @param array $results * @param string $bot_username * - * @return BotCommand[]|ChatMember[]|GameHighScore[]|Message[]|Update[] + * @return BotCommand[]|ChatMember[]|GameHighScore[]|Message[]|Sticker[]|Update[] */ private function createResultObjects(array $results, string $bot_username): array { $result_object_types = [ - 'getMyCommands' => BotCommand::class, - 'getChatAdministrators' => ChatMemberFactory::class, - 'getGameHighScores' => GameHighScore::class, - 'sendMediaGroup' => Message::class, + 'getUpdates' => Update::class, + 'getChatAdministrators' => ChatMemberFactory::class, + 'getForumTopicIconStickers' => Sticker::class, + 'getMyCommands' => BotCommand::class, + 'getCustomEmojiStickers' => Sticker::class, + 'getGameHighScores' => GameHighScore::class, + 'sendMediaGroup' => Message::class, ]; $action = Request::getCurrentAction(); From 8ac145615d3c1215aa1da3fe81cba50bfbb60cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Tue, 25 Apr 2023 03:08:18 +0200 Subject: [PATCH 5/6] Bot API 6.7 --- CHANGELOG.md | 2 +- README.md | 10 +-- src/Entities/BotName.php | 17 ++++ src/Entities/ChatMemberUpdated.php | 1 + src/Entities/InlineKeyboardButton.php | 11 ++- src/Entities/InlineQueryResultsButton.php | 27 ++++++ src/Entities/ServerResponse.php | 3 +- src/Entities/SwitchInlineQueryChosenChat.php | 21 +++++ src/Entities/WriteAccessAllowed.php | 2 + src/Request.php | 6 ++ .../Entities/InlineKeyboardButtonTest.php | 86 ++++++------------- 11 files changed, 116 insertions(+), 70 deletions(-) create mode 100644 src/Entities/BotName.php create mode 100644 src/Entities/InlineQueryResultsButton.php create mode 100644 src/Entities/SwitchInlineQueryChosenChat.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 8de9664d0..ebbd44255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ### Notes - [:ledger: View file changes][Unreleased] ∙ [:page_with_curl: DB migration script][unreleased-sql-migration] ### Added -- Bot API 6.4, 6.5, 6.6 (@noplanman) +- Bot API 6.4, 6.5, 6.6, 6.7 (@noplanman) ### Changed ### Deprecated ### Removed diff --git a/README.md b/README.md index 2ae321de3..652199ab9 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Telegram Bot based on the official [Telegram Bot API] -[![API Version](https://img.shields.io/badge/Bot%20API-6.6%20%28March%202023%29-32a2da.svg)](https://core.telegram.org/bots/api-changelog#march-9-2023) +[![API Version](https://img.shields.io/badge/Bot%20API-6.7%20%28April%202023%29-32a2da.svg)](https://core.telegram.org/bots/api-changelog#april-21-2023) [![Join the bot support group on Telegram](https://img.shields.io/badge/telegram-@PHP__Telegram__Bot__Support-64659d.svg)](https://telegram.me/PHP_Telegram_Bot_Support) [![Donate](https://img.shields.io/badge/%F0%9F%92%99-Donate%20%2F%20Support%20Us-blue.svg)](#donate) @@ -78,7 +78,7 @@ This Bot aims to provide a platform where one can simply write a bot and have in The Bot can: - Retrieve updates with [webhook](#webhook-installation) and [getUpdates](#getupdates-installation) methods. -- Supports all types and methods according to Telegram Bot API 6.6 (March 2023). +- Supports all types and methods according to Telegram Bot API 6.7 (April 2023). - Supports supergroups. - Handle commands in chat with other bots. - Manage Channel from the bot admin interface. @@ -389,15 +389,15 @@ The reason for denying an update can be defined with the `$reason` parameter. Th ### Types -All types are implemented according to Telegram API 6.6 (March 2023). +All types are implemented according to Telegram API 6.7 (April 2023). ### Inline Query -Full support for inline query according to Telegram API 6.6 (March 2023). +Full support for inline query according to Telegram API 6.7 (April 2023). ### Methods -All methods are implemented according to Telegram API 6.6 (March 2023). +All methods are implemented according to Telegram API 6.7 (April 2023). #### Send Message diff --git a/src/Entities/BotName.php b/src/Entities/BotName.php new file mode 100644 index 000000000..a36635b43 --- /dev/null +++ b/src/Entities/BotName.php @@ -0,0 +1,17 @@ +getProperty($param) !== null) { $num_params++; } } if ($num_params !== 1) { - throw new TelegramException('You must use only one of these fields: url, login_url, callback_data, web_app, switch_inline_query, switch_inline_query_current_chat, callback_game, pay!'); + throw new TelegramException('You must use only one of these fields: url, login_url, callback_data, web_app, switch_inline_query, switch_inline_query_current_chat, switch_inline_query_chosen_chat, callback_game, pay!'); } } @@ -96,8 +99,8 @@ protected function validate(): void public function __call($method, $args) { // Only 1 of these can be set, so clear the others when setting a new one. - if (in_array($method, ['setUrl', 'setLoginUrl', 'setCallbackData', 'setWebApp', 'setSwitchInlineQuery', 'setSwitchInlineQueryCurrentChat', 'setCallbackGame', 'setPay'], true)) { - unset($this->url, $this->login_url, $this->callback_data, $this->web_app, $this->switch_inline_query, $this->switch_inline_query_current_chat, $this->callback_game, $this->pay); + if (in_array($method, ['setUrl', 'setLoginUrl', 'setCallbackData', 'setWebApp', 'setSwitchInlineQuery', 'setSwitchInlineQueryCurrentChat', 'setSwitchInlineQueryChosenChat', 'setCallbackGame', 'setPay'], true)) { + unset($this->url, $this->login_url, $this->callback_data, $this->web_app, $this->switch_inline_query, $this->switch_inline_query_current_chat, $this->switch_inline_query_chosen_chat, $this->callback_game, $this->pay); } return parent::__call($method, $args); diff --git a/src/Entities/InlineQueryResultsButton.php b/src/Entities/InlineQueryResultsButton.php new file mode 100644 index 000000000..a96222e9c --- /dev/null +++ b/src/Entities/InlineQueryResultsButton.php @@ -0,0 +1,27 @@ + WebAppInfo::class, + ]; + } +} diff --git a/src/Entities/ServerResponse.php b/src/Entities/ServerResponse.php index 3ff9ffa9b..2d8d92747 100644 --- a/src/Entities/ServerResponse.php +++ b/src/Entities/ServerResponse.php @@ -107,7 +107,7 @@ public function printError($return = false) * @param array $result * @param string $bot_username * - * @return BotDescription|BotShortDescription|Chat|ChatAdministratorRights|ChatMember|File|Message|MenuButton|Poll|SentWebAppMessage|StickerSet|User|UserProfilePhotos|WebhookInfo + * @return BotDescription|BotName|BotShortDescription|Chat|ChatAdministratorRights|ChatMember|File|Message|MenuButton|Poll|SentWebAppMessage|StickerSet|User|UserProfilePhotos|WebhookInfo */ private function createResultObject(array $result, string $bot_username): Entity { @@ -118,6 +118,7 @@ private function createResultObject(array $result, string $bot_username): Entity 'getFile' => File::class, 'getChat' => Chat::class, 'getChatMember' => ChatMemberFactory::class, + 'getMyName' => BotName::class, 'getMyDescription' => BotDescription::class, 'getMyShortDescription' => BotShortDescription::class, 'getChatMenuButton' => MenuButtonFactory::class, diff --git a/src/Entities/SwitchInlineQueryChosenChat.php b/src/Entities/SwitchInlineQueryChosenChat.php new file mode 100644 index 000000000..49218f6df --- /dev/null +++ b/src/Entities/SwitchInlineQueryChosenChat.php @@ -0,0 +1,21 @@ +expectException(TelegramException::class); - $this->expectExceptionMessage('You must use only one of these fields: url, login_url, callback_data, web_app, switch_inline_query, switch_inline_query_current_chat, callback_game, pay!'); + $this->expectExceptionMessage('You must use only one of these fields: url, login_url, callback_data, web_app, switch_inline_query, switch_inline_query_current_chat, switch_inline_query_chosen_chat, callback_game, pay!'); new InlineKeyboardButton(['text' => 'message']); } public function testInlineKeyboardButtonTooManyParametersFail(): void { $this->expectException(TelegramException::class); - $this->expectExceptionMessage('You must use only one of these fields: url, login_url, callback_data, web_app, switch_inline_query, switch_inline_query_current_chat, callback_game, pay!'); + $this->expectExceptionMessage('You must use only one of these fields: url, login_url, callback_data, web_app, switch_inline_query, switch_inline_query_current_chat, switch_inline_query_chosen_chat, callback_game, pay!'); $test_funcs = [ function () { new InlineKeyboardButton([ @@ -72,6 +73,13 @@ function () { 'switch_inline_query_current_chat' => 'switch_inline_query_current_chat_value', ]); }, + function () { + new InlineKeyboardButton([ + 'text' => 'message', + 'callback_data' => 'callback_data_value', + 'switch_inline_query_chosen_chat' => new SwitchInlineQueryChosenChat([]), + ]); + }, function () { new InlineKeyboardButton([ 'text' => 'message', @@ -99,6 +107,7 @@ public function testInlineKeyboardButtonSuccess(): void new InlineKeyboardButton(['text' => 'message', 'switch_inline_query' => '']); // Allow empty string. new InlineKeyboardButton(['text' => 'message', 'switch_inline_query_current_chat' => 'switch_inline_query_current_chat_value']); new InlineKeyboardButton(['text' => 'message', 'switch_inline_query_current_chat' => '']); // Allow empty string. + new InlineKeyboardButton(['text' => 'message', 'switch_inline_query_chosen_chat' => new SwitchInlineQueryChosenChat([])]); // Allow empty string. new InlineKeyboardButton(['text' => 'message', 'callback_game' => new CallbackGame([])]); new InlineKeyboardButton(['text' => 'message', 'pay' => true]); self::assertTrue(true); @@ -118,6 +127,9 @@ public function testInlineKeyboardButtonCouldBe(): void self::assertTrue(InlineKeyboardButton::couldBe( ['text' => 'message', 'switch_inline_query_current_chat' => 'switch_inline_query_current_chat_value'] )); + self::assertTrue(InlineKeyboardButton::couldBe( + ['text' => 'message', 'switch_inline_query_chosen_chat' => new SwitchInlineQueryChosenChat([])] + )); self::assertTrue(InlineKeyboardButton::couldBe( ['text' => 'message', 'callback_game' => new CallbackGame([])] )); @@ -128,12 +140,18 @@ public function testInlineKeyboardButtonCouldBe(): void self::assertFalse(InlineKeyboardButton::couldBe(['no_text' => 'message'])); self::assertFalse(InlineKeyboardButton::couldBe(['text' => 'message'])); self::assertFalse(InlineKeyboardButton::couldBe(['url' => 'url_value'])); - self::assertFalse(InlineKeyboardButton::couldBe( - ['callback_data' => 'callback_data_value'] - )); - self::assertFalse(InlineKeyboardButton::couldBe( - ['switch_inline_query' => 'switch_inline_query_value'] - )); + self::assertFalse(InlineKeyboardButton::couldBe([ + 'callback_data' => 'callback_data_value' + ])); + self::assertFalse(InlineKeyboardButton::couldBe([ + 'switch_inline_query' => 'switch_inline_query_value' + ])); + self::assertFalse(InlineKeyboardButton::couldBe([ + 'switch_inline_query_current_chat' => 'switch_inline_query_current_chat_value' + ])); + self::assertFalse(InlineKeyboardButton::couldBe([ + 'switch_inline_query_chosen_chat' => new SwitchInlineQueryChosenChat([]) + ])); self::assertFalse(InlineKeyboardButton::couldBe(['callback_game' => new CallbackGame([])])); self::assertFalse(InlineKeyboardButton::couldBe(['pay' => true])); @@ -142,59 +160,9 @@ public function testInlineKeyboardButtonCouldBe(): void 'callback_data' => 'callback_data_value', 'switch_inline_query' => 'switch_inline_query_value', 'switch_inline_query_current_chat' => 'switch_inline_query_current_chat_value', + 'switch_inline_query_chosen_chat' => new SwitchInlineQueryChosenChat([]), 'callback_game' => new CallbackGame([]), 'pay' => true, ])); } - - public function testInlineKeyboardButtonParameterSetting(): void - { - $button = new InlineKeyboardButton(['text' => 'message', 'url' => 'url_value']); - self::assertSame('url_value', $button->getUrl()); - self::assertEmpty($button->getCallbackData()); - self::assertEmpty($button->getSwitchInlineQuery()); - self::assertEmpty($button->getSwitchInlineQueryCurrentChat()); - self::assertEmpty($button->getCallbackGame()); - self::assertEmpty($button->getPay()); - - $button->setCallbackData('callback_data_value'); - self::assertEmpty($button->getUrl()); - self::assertSame('callback_data_value', $button->getCallbackData()); - self::assertEmpty($button->getSwitchInlineQuery()); - self::assertEmpty($button->getSwitchInlineQueryCurrentChat()); - self::assertEmpty($button->getCallbackGame()); - self::assertEmpty($button->getPay()); - - $button->setSwitchInlineQuery('switch_inline_query_value'); - self::assertEmpty($button->getUrl()); - self::assertEmpty($button->getCallbackData()); - self::assertSame('switch_inline_query_value', $button->getSwitchInlineQuery()); - self::assertEmpty($button->getSwitchInlineQueryCurrentChat()); - self::assertEmpty($button->getCallbackGame()); - self::assertEmpty($button->getPay()); - - $button->setSwitchInlineQueryCurrentChat('switch_inline_query_current_chat_value'); - self::assertEmpty($button->getUrl()); - self::assertEmpty($button->getCallbackData()); - self::assertEmpty($button->getSwitchInlineQuery()); - self::assertSame('switch_inline_query_current_chat_value', $button->getSwitchInlineQueryCurrentChat()); - self::assertEmpty($button->getCallbackGame()); - self::assertEmpty($button->getPay()); - - $button->setCallbackGame($callback_game = new CallbackGame([])); - self::assertEmpty($button->getUrl()); - self::assertEmpty($button->getCallbackData()); - self::assertEmpty($button->getSwitchInlineQuery()); - self::assertEmpty($button->getSwitchInlineQueryCurrentChat()); - self::assertSame($callback_game, $button->getCallbackGame()); - self::assertEmpty($button->getPay()); - - $button->setPay(true); - self::assertEmpty($button->getUrl()); - self::assertEmpty($button->getCallbackData()); - self::assertEmpty($button->getSwitchInlineQuery()); - self::assertEmpty($button->getSwitchInlineQueryCurrentChat()); - self::assertEmpty($button->getCallbackGame()); - self::assertTrue($button->getPay()); - } } From 948538637a042dc4d85c95f3b7662d57f58d8318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Tue, 25 Apr 2023 03:43:18 +0200 Subject: [PATCH 6/6] Micro-fix --- src/DB.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DB.php b/src/DB.php index ad4425e0d..efcc63a3b 100644 --- a/src/DB.php +++ b/src/DB.php @@ -1152,7 +1152,7 @@ public static function insertMessageRequest(Message $message): bool :new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created, :supergroup_chat_created, :channel_chat_created, :message_auto_delete_timer_changed, :migrate_to_chat_id, :migrate_from_chat_id, :pinned_message, :invoice, :successful_payment, :user_shared, :chat_shared, :connected_website, :write_access_allowed, :passport_data, :proximity_alert_triggered, - :forum_topic_created, :forum_topic_edited, :forum_topic_closed, :forum_topic_reopened, :general_forum_topic_hidden, :general_forum_topic_unhidden + :forum_topic_created, :forum_topic_edited, :forum_topic_closed, :forum_topic_reopened, :general_forum_topic_hidden, :general_forum_topic_unhidden, :video_chat_scheduled, :video_chat_started, :video_chat_ended, :video_chat_participants_invited, :web_app_data, :reply_markup ) ');