From c3ba72eb8ae63ef31688e3f4e4056b4f969abef4 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Mon, 2 Jan 2023 21:55:47 +0100 Subject: Update to Bot API 6.4 --- include/tgbot/Api.h | 89 ++++++++++++++++++++++--- include/tgbot/TgTypeParser.h | 16 +++++ include/tgbot/types/Chat.h | 15 +++++ include/tgbot/types/ForumTopicEdited.h | 30 +++++++++ include/tgbot/types/GeneralForumTopicHidden.h | 21 ++++++ include/tgbot/types/GeneralForumTopicUnhidden.h | 21 ++++++ include/tgbot/types/InputMedia.h | 6 +- include/tgbot/types/InputMediaAnimation.h | 8 ++- include/tgbot/types/InputMediaPhoto.h | 6 +- include/tgbot/types/InputMediaVideo.h | 12 +++- include/tgbot/types/Message.h | 29 ++++++++ include/tgbot/types/ReplyKeyboardMarkup.h | 24 +++++-- include/tgbot/types/WriteAccessAllowed.h | 21 ++++++ 13 files changed, 274 insertions(+), 24 deletions(-) create mode 100644 include/tgbot/types/ForumTopicEdited.h create mode 100644 include/tgbot/types/GeneralForumTopicHidden.h create mode 100644 include/tgbot/types/GeneralForumTopicUnhidden.h create mode 100644 include/tgbot/types/WriteAccessAllowed.h (limited to 'include') diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index ae91032..c3ae922 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -258,6 +258,7 @@ public: * @param allowSendingWithoutReply Optional. Pass True if the message should be sent even if the specified replied-to message is not found * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + * @param hasSpoiler Optional. Pass True if the photo needs to be covered with a spoiler animation * * @return On success, the sent Message is returned. */ @@ -271,7 +272,8 @@ public: const std::vector& captionEntities = std::vector(), bool allowSendingWithoutReply = false, bool protectContent = false, - std::int32_t messageThreadId = 0) const; + std::int32_t messageThreadId = 0, + bool hasSpoiler = false) const; /** * @brief Use this method to send audio files, if you want Telegram clients to display them in the music player. @@ -371,6 +373,7 @@ public: * @param allowSendingWithoutReply Optional. Pass True if the message should be sent even if the specified replied-to message is not found * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + * @param hasSpoiler Optional. Pass True if the video needs to be covered with a spoiler animation * * @return On success, the sent Message is returned. */ @@ -389,7 +392,8 @@ public: const std::vector& captionEntities = std::vector(), bool allowSendingWithoutReply = false, bool protectContent = false, - std::int32_t messageThreadId = 0) const; + std::int32_t messageThreadId = 0, + bool hasSpoiler = false) const; /** * @brief Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). @@ -411,6 +415,7 @@ public: * @param allowSendingWithoutReply Optional. Pass True if the message should be sent even if the specified replied-to message is not found * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only + * @param hasSpoiler Optional. Pass True if the animation needs to be covered with a spoiler animation * * @return On success, the sent Message is returned. */ @@ -428,7 +433,8 @@ public: const std::vector& captionEntities = std::vector(), bool allowSendingWithoutReply = false, bool protectContent = false, - std::int32_t messageThreadId = 0) const; + std::int32_t messageThreadId = 0, + bool hasSpoiler = false) const; /** * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. @@ -732,18 +738,20 @@ public: * The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). * * Example: The ImageBot needs some time to process a request and upload the image. - * Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. + * Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use Api::sendChatAction with action = upload_photo. * The user will see a “sending photo” status for the bot. * * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. + * @param messageThreadId Optional. Unique identifier for the target message thread; supergroups only * - * @return True on success. + * @return Returns True on success. */ bool sendChatAction(std::int64_t chatId, - const std::string& action) const; + const std::string& action, + std::int32_t messageThreadId = 0) const; /** * @brief Use this method to get a list of profile pictures for a user. @@ -1149,6 +1157,8 @@ public: /** * @brief Use this method to get information about a member of a chat. * + * The method is guaranteed to work for other users, only if the bot is an administrator in the chat. + * * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) * @param userId Unique identifier of the target user * @@ -1214,15 +1224,15 @@ public: * * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) * @param messageThreadId Unique identifier for the target message thread of the forum topic - * @param name New topic name, 1-128 characters - * @param iconCustomEmojiId New unique identifier of the custom emoji shown as the topic icon. Use Api::getForumTopicIconStickers to get all allowed custom emoji identifiers + * @param name Optional. New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept + * @param iconCustomEmojiId Optional. New unique identifier of the custom emoji shown as the topic icon. Use Api::getForumTopicIconStickers to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept * * @return Returns True on success. */ bool editForumTopic(boost::variant chatId, std::int32_t messageThreadId, - const std::string& name, - const std::string& iconCustomEmojiId) const; + const std::string& name = "", + boost::variant iconCustomEmojiId = 0) const; /** * @brief Use this method to close an open topic in a forum supergroup chat. @@ -1276,6 +1286,65 @@ public: bool unpinAllForumTopicMessages(boost::variant chatId, std::int32_t messageThreadId) const; + /** + * @brief Use this method to edit the name of the 'General' topic in a forum supergroup chat. + * + * The bot must be an administrator in the chat for this to work and must have canManageTopics administrator rights. + * + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param name New topic name, 1-128 characters + * + * @return Returns True on success. + */ + bool editGeneralForumTopic(boost::variant chatId, + std::string name) const; + + /** + * @brief Use this method to close an open 'General' topic in a forum supergroup chat. + * + * The bot must be an administrator in the chat for this to work and must have the canManageTopics administrator rights. + * + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * + * @return Returns True on success. + */ + bool closeGeneralForumTopic(boost::variant chatId) const; + + /** + * @brief 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 canManageTopics administrator rights. + * The topic will be automatically unhidden if it was hidden. + * + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * + * @return Returns True on success. + */ + bool reopenGeneralForumTopic(boost::variant chatId) const; + + /** + * @brief 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 canManageTopics administrator rights. + * The topic will be automatically closed if it was open. + * + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * + * @return Returns True on success. + */ + bool hideGeneralForumTopic(boost::variant chatId) const; + + /** + * @brief 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 canManageTopics administrator rights. + * + * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * + * @return Returns True on success. + */ + bool unhideGeneralForumTopic(boost::variant chatId) const; + /** * @brief Use this method to send answers to callback queries sent from inline keyboards. * diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index b303c47..66c1f8f 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -28,7 +28,11 @@ #include "tgbot/types/MessageAutoDeleteTimerChanged.h" #include "tgbot/types/ForumTopicCreated.h" #include "tgbot/types/ForumTopicClosed.h" +#include "tgbot/types/ForumTopicEdited.h" #include "tgbot/types/ForumTopicReopened.h" +#include "tgbot/types/GeneralForumTopicHidden.h" +#include "tgbot/types/GeneralForumTopicUnhidden.h" +#include "tgbot/types/WriteAccessAllowed.h" #include "tgbot/types/VideoChatScheduled.h" #include "tgbot/types/VideoChatStarted.h" #include "tgbot/types/VideoChatEnded.h" @@ -236,9 +240,21 @@ public: ForumTopicClosed::Ptr parseJsonAndGetForumTopicClosed(const boost::property_tree::ptree& data) const; std::string parseForumTopicClosed(const ForumTopicClosed::Ptr& object) const; + ForumTopicEdited::Ptr parseJsonAndGetForumTopicEdited(const boost::property_tree::ptree& data) const; + std::string parseForumTopicEdited(const ForumTopicEdited::Ptr& object) const; + ForumTopicReopened::Ptr parseJsonAndGetForumTopicReopened(const boost::property_tree::ptree& data) const; std::string parseForumTopicReopened(const ForumTopicReopened::Ptr& object) const; + GeneralForumTopicHidden::Ptr parseJsonAndGetGeneralForumTopicHidden(const boost::property_tree::ptree& data) const; + std::string parseGeneralForumTopicHidden(const GeneralForumTopicHidden::Ptr& object) const; + + GeneralForumTopicUnhidden::Ptr parseJsonAndGetGeneralForumTopicUnhidden(const boost::property_tree::ptree& data) const; + std::string parseGeneralForumTopicUnhidden(const GeneralForumTopicUnhidden::Ptr& object) const; + + WriteAccessAllowed::Ptr parseJsonAndGetWriteAccessAllowed(const boost::property_tree::ptree& data) const; + std::string parseWriteAccessAllowed(const WriteAccessAllowed::Ptr& object) const; + VideoChatScheduled::Ptr parseJsonAndGetVideoChatScheduled(const boost::property_tree::ptree& data) const; std::string parseVideoChatScheduled(const VideoChatScheduled::Ptr& object) const; diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h index 2d31289..2401300 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -167,6 +167,21 @@ public: */ std::int32_t messageAutoDeleteTime; + /** + * @brief Optional. True, if aggressive anti-spam checks are enabled in the supergroup. + * + * The field is only available to chat administrators. + * Returned only in Api::getChat. + */ + bool hasAggressiveAntiSpamEnabled; + + /** + * @brief Optional. True, if non-administrators can only get the list of bots and administrators in the chat. + * + * Returned only in Api::getChat. + */ + bool hasHiddenMembers; + /** * @brief Optional. True, if messages from the chat can't be forwarded to other chats. * diff --git a/include/tgbot/types/ForumTopicEdited.h b/include/tgbot/types/ForumTopicEdited.h new file mode 100644 index 0000000..18b75bc --- /dev/null +++ b/include/tgbot/types/ForumTopicEdited.h @@ -0,0 +1,30 @@ +#ifndef TGBOT_FORUMTOPICEDITED_H +#define TGBOT_FORUMTOPICEDITED_H + +#include +#include + +namespace TgBot { + +/** + * @brief This object represents a service message about an edited forum topic. + * + * @ingroup types + */ +class ForumTopicEdited { +public: + typedef std::shared_ptr Ptr; + + /** + * @brief Optional. New name of the topic, if it was edited + */ + std::string name; + + /** + * @brief Optional. New identifier of the custom emoji shown as the topic icon, if it was edited; an empty string if the icon was removed + */ + std::string iconCustomEmojiId; +}; +} + +#endif //TGBOT_FORUMTOPICEDITED_H diff --git a/include/tgbot/types/GeneralForumTopicHidden.h b/include/tgbot/types/GeneralForumTopicHidden.h new file mode 100644 index 0000000..1a32a77 --- /dev/null +++ b/include/tgbot/types/GeneralForumTopicHidden.h @@ -0,0 +1,21 @@ +#ifndef TGBOT_GENERALFORUMTOPICHIDDEN_H +#define TGBOT_GENERALFORUMTOPICHIDDEN_H + +#include + +namespace TgBot { + +/** + * @brief This object represents a service message about General forum topic hidden in the chat. + * + * Currently holds no information. + * + * @ingroup types + */ +class GeneralForumTopicHidden { +public: + typedef std::shared_ptr Ptr; +}; +} + +#endif //TGBOT_GENERALFORUMTOPICHIDDEN_H diff --git a/include/tgbot/types/GeneralForumTopicUnhidden.h b/include/tgbot/types/GeneralForumTopicUnhidden.h new file mode 100644 index 0000000..e2b33a3 --- /dev/null +++ b/include/tgbot/types/GeneralForumTopicUnhidden.h @@ -0,0 +1,21 @@ +#ifndef TGBOT_GENERALFORUMTOPICUNHIDDEN_H +#define TGBOT_GENERALFORUMTOPICUNHIDDEN_H + +#include + +namespace TgBot { + +/** + * @brief This object represents a service message about General forum topic unhidden in the chat. + * + * Currently holds no information. + * + * @ingroup types + */ +class GeneralForumTopicUnhidden { +public: + typedef std::shared_ptr Ptr; +}; +} + +#endif //TGBOT_GENERALFORUMTOPICUNHIDDEN_H diff --git a/include/tgbot/types/InputMedia.h b/include/tgbot/types/InputMedia.h index c7ff6c0..9ce50c3 100644 --- a/include/tgbot/types/InputMedia.h +++ b/include/tgbot/types/InputMedia.h @@ -31,24 +31,26 @@ public: /** * @brief File to send. + * * Pass a fileId 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. * https://core.telegram.org/bots/api#sending-files */ std::string media; /** - * @brief Optional. Caption of the media to to be sent, 0-1024 characters after entities parsing + * @brief Optional. Caption of the media to be sent, 0-1024 characters after entities parsing */ std::string caption; /** * @brief Optional. Mode for parsing entities in the media caption. + * * See https://core.telegram.org/bots/api#formatting-options for more details. */ std::string parseMode; /** - * @brief Optional. List of special entities that appear in the caption, which can be specified instead of InputMedia::parseMode + * @brief Optional. List of special entities that appear in the caption, which can be specified instead of parseMode */ std::vector captionEntities; }; diff --git a/include/tgbot/types/InputMediaAnimation.h b/include/tgbot/types/InputMediaAnimation.h index b6109a0..1cc2621 100644 --- a/include/tgbot/types/InputMediaAnimation.h +++ b/include/tgbot/types/InputMediaAnimation.h @@ -26,6 +26,7 @@ public: /** * @brief Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. + * * The thumbnail should be in JPEG format and less than 200 kB in size. * A thumbnail's width and height should not exceed 320. * Ignored if the file is not uploaded using multipart/form-data. @@ -45,9 +46,14 @@ public: std::int32_t height; /** - * @brief Optional. Animation duration + * @brief Optional. Animation duration in seconds */ std::int32_t duration; + + /** + * @brief Optional. Pass True if the animation needs to be covered with a spoiler animation + */ + bool hasSpoiler; }; } diff --git a/include/tgbot/types/InputMediaPhoto.h b/include/tgbot/types/InputMediaPhoto.h index 998981d..5897beb 100644 --- a/include/tgbot/types/InputMediaPhoto.h +++ b/include/tgbot/types/InputMediaPhoto.h @@ -4,7 +4,6 @@ #include "tgbot/types/InputMedia.h" #include -#include namespace TgBot { @@ -22,6 +21,11 @@ public: InputMediaPhoto() { this->type = TYPE; } + + /** + * @brief Optional. Pass True if the photo needs to be covered with a spoiler animation + */ + bool hasSpoiler; }; } diff --git a/include/tgbot/types/InputMediaVideo.h b/include/tgbot/types/InputMediaVideo.h index 348d973..2645c91 100644 --- a/include/tgbot/types/InputMediaVideo.h +++ b/include/tgbot/types/InputMediaVideo.h @@ -26,8 +26,9 @@ public: /** * @brief Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. + * * The thumbnail should be in JPEG format and less than 200 kB in size. - * A thumbnail's width and height should not exceed 320. + * A thumbnail's width and height should not exceed 320. * 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 . * https://core.telegram.org/bots/api#sending-files @@ -45,14 +46,19 @@ public: std::int32_t height; /** - * @brief Optional. Video duration + * @brief Optional. Video duration in seconds */ std::int32_t duration; /** - * @brief Optional. Pass True, if the uploaded video is suitable for streaming + * @brief Optional. Pass True if the uploaded video is suitable for streaming */ bool supportsStreaming; + + /** + * @brief Optional. Pass True if the video needs to be covered with a spoiler animation + */ + bool hasSpoiler; }; } diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index 4d1ea7b..11ba954 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -22,11 +22,15 @@ #include "tgbot/types/MessageAutoDeleteTimerChanged.h" #include "tgbot/types/Invoice.h" #include "tgbot/types/SuccessfulPayment.h" +#include "tgbot/types/WriteAccessAllowed.h" #include "tgbot/types/PassportData.h" #include "tgbot/types/ProximityAlertTriggered.h" #include "tgbot/types/ForumTopicCreated.h" +#include "tgbot/types/ForumTopicEdited.h" #include "tgbot/types/ForumTopicClosed.h" #include "tgbot/types/ForumTopicReopened.h" +#include "tgbot/types/GeneralForumTopicHidden.h" +#include "tgbot/types/GeneralForumTopicUnhidden.h" #include "tgbot/types/VideoChatScheduled.h" #include "tgbot/types/VideoChatStarted.h" #include "tgbot/types/VideoChatEnded.h" @@ -219,6 +223,11 @@ public: */ std::vector captionEntities; + /** + * @brief Optional. True, if the message media is covered by a spoiler animation + */ + bool hasMediaSpoiler; + /** * @brief Optional. Message is a shared contact, information about the contact */ @@ -346,6 +355,11 @@ public: */ std::string connectedWebsite; + /** + * @brief Optional. Service message: the user allowed the bot added to the attachment menu to write messages + */ + WriteAccessAllowed::Ptr writeAccessAllowed; + /** * @brief Optional. Telegram Passport data */ @@ -363,6 +377,11 @@ public: */ ForumTopicCreated::Ptr forumTopicCreated; + /** + * @brief Optional. Service message: forum topic edited + */ + ForumTopicEdited::Ptr forumTopicEdited; + /** * @brief Optional. Service message: forum topic closed */ @@ -373,6 +392,16 @@ public: */ ForumTopicReopened::Ptr forumTopicReopened; + /** + * @brief Optional. Service message: the 'General' forum topic hidden + */ + GeneralForumTopicHidden::Ptr generalForumTopicHidden; + + /** + * @brief Optional. Service message: the 'General' forum topic unhidden + */ + GeneralForumTopicUnhidden::Ptr generalForumTopicUnhidden; + /** * @brief Optional. Service message: video chat scheduled */ diff --git a/include/tgbot/types/ReplyKeyboardMarkup.h b/include/tgbot/types/ReplyKeyboardMarkup.h index f122934..d40d767 100644 --- a/include/tgbot/types/ReplyKeyboardMarkup.h +++ b/include/tgbot/types/ReplyKeyboardMarkup.h @@ -1,17 +1,17 @@ -#ifndef TGBOT_CPP_REPLYKEYBOARDMARKUP_H -#define TGBOT_CPP_REPLYKEYBOARDMARKUP_H +#ifndef TGBOT_REPLYKEYBOARDMARKUP_H +#define TGBOT_REPLYKEYBOARDMARKUP_H #include "tgbot/types/GenericReply.h" #include "tgbot/types/KeyboardButton.h" -#include #include +#include #include namespace TgBot { /** - * @brief This object represents a custom keyboard with reply options (see https://core.telegram.org/bots#keyboards for details and examples). + * @brief This object represents a custom keyboard with reply options (see https://core.telegram.org/bots/features#keyboards for details and examples). * * @ingroup types */ @@ -25,16 +25,25 @@ public: */ std::vector> keyboard; + /** + * @brief 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. + */ + bool isPersistent; + /** * @brief 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. */ bool resizeKeyboard; /** * @brief Optional. Requests clients to hide 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 + * + * 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. */ bool oneTimeKeyboard; @@ -45,6 +54,7 @@ public: /** * @brief 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 replyToMessageId), sender of the original message. * * Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language. @@ -54,4 +64,4 @@ public: }; } -#endif //TGBOT_CPP_REPLYKEYBOARDMARKUP_H +#endif //TGBOT_REPLYKEYBOARDMARKUP_H diff --git a/include/tgbot/types/WriteAccessAllowed.h b/include/tgbot/types/WriteAccessAllowed.h new file mode 100644 index 0000000..d01aa31 --- /dev/null +++ b/include/tgbot/types/WriteAccessAllowed.h @@ -0,0 +1,21 @@ +#ifndef TGBOT_WRITEACCESSALLOWED_H +#define TGBOT_WRITEACCESSALLOWED_H + +#include + +namespace TgBot { + +/** + * @brief This object represents a service message about a user allowing a bot added to the attachment menu to write messages. + * + * Currently holds no information. + * + * @ingroup types + */ +class WriteAccessAllowed { +public: + typedef std::shared_ptr Ptr; +}; +} + +#endif //TGBOT_WRITEACCESSALLOWED_H -- cgit v1.2.3