From 6ea1ae799accd92cbc47c7a62411cc72f1b9ccd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20L=C3=BCscher?= Date: Tue, 29 Aug 2023 20:28:33 +0200 Subject: [PATCH] Bot API 6.8 --- CHANGELOG.md | 4 +++- src/DB.php | 5 +++-- src/Entities/Chat.php | 1 + src/Entities/Message.php | 2 ++ src/Entities/PollAnswer.php | 6 ++++-- src/Entities/Story.php | 22 ++++++++++++++++++++ src/Request.php | 2 ++ structure.sql | 1 + utils/db-schema-update/0.81.0-unreleased.sql | 2 ++ 9 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/Entities/Story.php create mode 100644 utils/db-schema-update/0.81.0-unreleased.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index b9eedcca4..c3c3e5b03 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.8 (@noplanman) ### Changed ### Deprecated ### Removed @@ -624,6 +625,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/develop/utils/db-schema-update/0.81.0-unreleased.sql [0.81.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.80.0-0.81.0.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 diff --git a/src/DB.php b/src/DB.php index efcc63a3b..6472d1719 100644 --- a/src/DB.php +++ b/src/DB.php @@ -1136,7 +1136,7 @@ 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`, `has_media_spoiler`, `contact`, + `audio`, `document`, `animation`, `game`, `photo`, `sticker`, `story`, `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`, @@ -1147,7 +1147,7 @@ public static function insertMessageRequest(Message $message): bool :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, :has_media_spoiler, :contact, + :audio, :document, :animation, :game, :photo, :sticker, :story, :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, @@ -1202,6 +1202,7 @@ public static function insertMessageRequest(Message $message): bool $sth->bindValue(':game', $message->getGame()); $sth->bindValue(':photo', self::entitiesArrayToJson($message->getPhoto() ?: [])); $sth->bindValue(':sticker', $message->getSticker()); + $sth->bindValue(':story', $message->getStory()); $sth->bindValue(':video', $message->getVideo()); $sth->bindValue(':voice', $message->getVoice()); $sth->bindValue(':video_note', $message->getVideoNote()); diff --git a/src/Entities/Chat.php b/src/Entities/Chat.php index aaccce397..977982435 100644 --- a/src/Entities/Chat.php +++ b/src/Entities/Chat.php @@ -28,6 +28,7 @@ * @method ChatPhoto getPhoto() Optional. Chat photo. Returned only in getChat. * @method string[] getActiveUsernames() Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat. * @method string getEmojiStatusCustomEmojiId() Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat. + * @method int getEmojiStatusExpirationDate() Optional. Expiration date of the emoji status of the other party in a private chat in Unix time, if any. Returned only in getChat. * @method string getBio() Optional. Bio of the other party in a private chat. Returned only in getChat. * @method bool getHasPrivateForwards() Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user. Returned only in getChat. * @method bool getHasRestrictedVoiceAndVideoMessages() Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in getChat. diff --git a/src/Entities/Message.php b/src/Entities/Message.php index 6a302e3e2..58f36b433 100644 --- a/src/Entities/Message.php +++ b/src/Entities/Message.php @@ -57,6 +57,7 @@ * @method Game getGame() Optional. Message is a game, information about the game. * @method PhotoSize[] getPhoto() Optional. Message is a photo, available sizes of the photo * @method Sticker getSticker() Optional. Message is a sticker, information about the sticker + * @method Story getStory() Optional. Message is a forwarded story * @method Video getVideo() Optional. Message is a video, information about the video * @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 @@ -121,6 +122,7 @@ protected function subEntities(): array 'document' => Document::class, 'photo' => [PhotoSize::class], 'sticker' => Sticker::class, + 'story' => Story::class, 'video' => Video::class, 'video_note' => VideoNote::class, 'voice' => Voice::class, diff --git a/src/Entities/PollAnswer.php b/src/Entities/PollAnswer.php index 8f53df175..f55fe916f 100644 --- a/src/Entities/PollAnswer.php +++ b/src/Entities/PollAnswer.php @@ -19,7 +19,8 @@ * @link https://core.telegram.org/bots/api#pollanswer * * @method string getPollId() Unique poll identifier - * @method User getUser() The user, who changed the answer to the poll + * @method Chat getVoterChat() Optional. The chat that changed the answer to the poll, if the voter is anonymous + * @method User getUser() Optional. The user, who changed the answer to the poll * @method array getOptionIds() 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote. */ class PollAnswer extends Entity @@ -30,7 +31,8 @@ class PollAnswer extends Entity protected function subEntities(): array { return [ - 'user' => User::class, + 'voter_chat' => Chat::class, + 'user' => User::class, ]; } } diff --git a/src/Entities/Story.php b/src/Entities/Story.php new file mode 100644 index 000000000..5647db224 --- /dev/null +++ b/src/Entities/Story.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Longman\TelegramBot\Entities; + +/** + * Class Story + * + * @link https://core.telegram.org/bots/api#story + */ +class Story extends Entity +{ + +} diff --git a/src/Request.php b/src/Request.php index f756ccc74..04134f7c9 100644 --- a/src/Request.php +++ b/src/Request.php @@ -94,6 +94,7 @@ * @method static ServerResponse reopenGeneralForumTopic(array $data) Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. * @method static ServerResponse hideGeneralForumTopic(array $data) Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success. * @method static ServerResponse unhideGeneralForumTopic(array $data) Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * @method static ServerResponse unpinAllGeneralForumTopicMessages(array $data) Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. * @method static ServerResponse answerCallbackQuery(array $data) Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. * @method static ServerResponse answerInlineQuery(array $data) Use this method to send answers to an inline query. On success, True is returned. * @method static ServerResponse setMyCommands(array $data) Use this method to change the list of the bot's commands. Returns True on success. @@ -269,6 +270,7 @@ class Request 'reopenGeneralForumTopic', 'hideGeneralForumTopic', 'unhideGeneralForumTopic', + 'unpinAllGeneralForumTopicMessages', 'answerCallbackQuery', 'answerInlineQuery', 'setMyCommands', diff --git a/structure.sql b/structure.sql index 52b2701c3..205dadecd 100644 --- a/structure.sql +++ b/structure.sql @@ -102,6 +102,7 @@ CREATE TABLE IF NOT EXISTS `message` ( `game` TEXT COMMENT 'Game object. Message is a game, information about the game', `photo` TEXT COMMENT 'Array of PhotoSize objects. Message is a photo, available sizes of the photo', `sticker` TEXT COMMENT 'Sticker object. Message is a sticker, information about the sticker', + `story` TEXT COMMENT 'Story object. Message is a forwarded story', `video` TEXT COMMENT 'Video object. Message is a video, information about the video', `voice` TEXT COMMENT 'Voice Object. Message is a Voice, information about the Voice', `video_note` TEXT COMMENT 'VoiceNote Object. Message is a Video Note, information about the Video Note', diff --git a/utils/db-schema-update/0.81.0-unreleased.sql b/utils/db-schema-update/0.81.0-unreleased.sql new file mode 100644 index 000000000..bae194cb9 --- /dev/null +++ b/utils/db-schema-update/0.81.0-unreleased.sql @@ -0,0 +1,2 @@ +ALTER TABLE `message` + ADD COLUMN `story` TEXT DEFAULT NULL COMMENT 'Story object. Message is a forwarded story' AFTER `sticker`;