diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2024-04-22 20:14:57 +0200 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2024-04-22 20:14:57 +0200 |
commit | 283cc4ba4670ed5546f007ec1a85b3fab40e6d6a (patch) | |
tree | c18de405b668687683ce811fde777394821b6d06 | |
parent | 28de9c683eba94aa100acd464e299f4ce56d8e03 (diff) |
Update to Bot API 7.2
27 files changed, 1085 insertions, 216 deletions
@@ -9,7 +9,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp). ## State -- [x] Telegram Bot API 7.1 +- [x] Telegram Bot API 7.2 - [ ] [MaybeInaccessibleMessage](https://core.telegram.org/bots/api#maybeinaccessiblemessage) - [ ] [Message->pinnedMessage](https://core.telegram.org/bots/api#message) - [ ] [CallbackQuery->message](https://core.telegram.org/bots/api#callbackquery) diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index da8b4ed..2288f5c 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -17,6 +17,7 @@ #include "tgbot/types/Venue.h" #include "tgbot/types/WebhookInfo.h" #include "tgbot/types/ChatMember.h" +#include "tgbot/types/Sticker.h" #include "tgbot/types/StickerSet.h" #include "tgbot/types/File.h" #include "tgbot/types/InputMedia.h" @@ -164,12 +165,13 @@ public: * @param text Text of the message to be sent, 1-4096 characters after entities parsing * @param linkPreviewOptions Optional. Link preview generation options for the message * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param parseMode Optional. Mode for parsing entities in the message text. See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details. * @param disableNotification Optional. Sends the message [silently](https://telegram.org/blog/channels-2-0#silent-messages). Users will receive a notification with no sound. * @param entities Optional. A JSON-serialized list of special entities that appear in message text, which can be specified instead of parseMode * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -182,7 +184,8 @@ public: bool disableNotification = false, const std::vector<MessageEntity::Ptr>& entities = std::vector<MessageEntity::Ptr>(), std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to forward messages of any kind. @@ -214,7 +217,7 @@ public: * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param fromChatId Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) - * @param messageIds Identifiers of 1-100 messages in the chat fromChatId to forward. The identifiers must be specified in a strictly increasing order. + * @param messageIds A JSON-serialized list of 1-100 identifiers of messages in the chat fromChatId to forward. The identifiers must be specified in a strictly increasing order. * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param disableNotification Optional. Sends the messages [silently](https://telegram.org/blog/channels-2-0#silent-messages). Users will receive a notification with no sound. * @param protectContent Optional. Protects the contents of the forwarded message from forwarding and saving @@ -272,7 +275,7 @@ public: * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param fromChatId Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) - * @param messageIds Identifiers of 1-100 messages in the chat fromChatId to copy. The identifiers must be specified in a strictly increasing order. + * @param messageIds A JSON-serialized list of 1-100 identifiers of messages in the chat fromChatId to copy. The identifiers must be specified in a strictly increasing order. * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param disableNotification Optional. Sends the messages [silently](https://telegram.org/blog/channels-2-0#silent-messages). Users will receive a notification with no sound. * @param protectContent Optional. Protects the contents of the sent messages from forwarding and saving @@ -295,13 +298,14 @@ public: * @param photo Photo to send. Pass a fileId as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. https://core.telegram.org/bots/api#sending-files * @param caption Optional. Photo caption (may also be used when resending photos by fileId), 0-1024 characters after entities parsing * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param parseMode Optional. Mode for parsing entities in the photo caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * @param hasSpoiler Optional. Pass True if the photo needs to be covered with a spoiler animation + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -315,7 +319,8 @@ public: const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), std::int32_t messageThreadId = 0, bool protectContent = false, - bool hasSpoiler = false) const; + bool hasSpoiler = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send audio files, if you want Telegram clients to display them in the music player. @@ -333,12 +338,13 @@ public: * @param title Optional. Track name * @param thumbnail 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. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param parseMode Optional. Mode for parsing entities in the audio caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -355,7 +361,8 @@ public: bool disableNotification = false, const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send general files. @@ -367,13 +374,14 @@ public: * @param thumbnail 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. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files * @param caption Optional. Document caption (may also be used when resending documents by fileId), 0-1024 characters after entities parsing * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param parseMode Optional. Mode for parsing entities in the document caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param disableContentTypeDetection Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -388,7 +396,8 @@ public: const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), bool disableContentTypeDetection = false, std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as Document). @@ -404,13 +413,14 @@ public: * @param thumbnail 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. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files * @param caption Optional. Video caption (may also be used when resending videos by fileId), 0-1024 characters after entities parsing * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param parseMode Optional. Mode for parsing entities in the video caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * @param hasSpoiler Optional. Pass True if the video needs to be covered with a spoiler animation + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -429,7 +439,8 @@ public: const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), std::int32_t messageThreadId = 0, bool protectContent = false, - bool hasSpoiler = false) const; + bool hasSpoiler = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). @@ -444,13 +455,14 @@ public: * @param thumbnail 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. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files * @param caption Optional. Animation caption (may also be used when resending animation by fileId), 0-1024 characters after entities parsing * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param parseMode Optional. Mode for parsing entities in the animation caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * @param hasSpoiler Optional. Pass True if the animation needs to be covered with a spoiler animation + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -468,7 +480,8 @@ public: const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), std::int32_t messageThreadId = 0, bool protectContent = false, - bool hasSpoiler = false) const; + bool hasSpoiler = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. @@ -481,12 +494,13 @@ public: * @param caption Optional. Voice message caption, 0-1024 characters after entities parsing * @param duration Optional. Duration of the voice message in seconds * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param parseMode Optional. Mode for parsing entities in the voice message caption. See https://core.telegram.org/bots/api#formatting-options for more details. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param captionEntities Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parseMode * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -500,7 +514,8 @@ public: bool disableNotification = false, const std::vector<MessageEntity::Ptr>& captionEntities = std::vector<MessageEntity::Ptr>(), std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send video messages. @@ -514,9 +529,10 @@ public: * @param duration Optional. Duration of sent video in seconds * @param length Optional. Video width and height, i.e. diameter of the video message * @param thumbnail 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. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. https://core.telegram.org/bots/api#sending-files - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -529,7 +545,8 @@ public: boost::variant<InputFile::Ptr, std::string> thumbnail = "", GenericReply::Ptr replyMarkup = nullptr, std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send a group of photos, videos, documents or audios as an album. @@ -542,6 +559,7 @@ public: * @param replyParameters Optional. Description of the message to reply to * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent messages from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, an array of Messages that were sent is returned. */ @@ -550,7 +568,8 @@ public: bool disableNotification = false, ReplyParameters::Ptr replyParameters = nullptr, std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send point on the map. @@ -560,13 +579,14 @@ public: * @param longitude Longitude of the location * @param livePeriod Optional. Period in seconds for which the location will be updated (see https://telegram.org/blog/live-locations, should be between 60 and 86400. * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param horizontalAccuracy Optional. The radius of uncertainty for the location, measured in meters; 0-1500 * @param heading Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. * @param proximityAlertRadius 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. * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -581,7 +601,8 @@ public: std::int32_t heading = 0, std::int32_t proximityAlertRadius = 0, std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to edit live location messages. @@ -637,11 +658,12 @@ public: * @param foursquareType Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param googlePlaceId Optional. Google Places identifier of the venue * @param googlePlaceType Optional. Google Places type of the venue. (See https://developers.google.com/places/web-service/supported_types) * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -658,7 +680,8 @@ public: const std::string& googlePlaceId = "", const std::string& googlePlaceType = "", std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send phone contacts. @@ -670,9 +693,10 @@ public: * @param vcard Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -685,7 +709,8 @@ public: ReplyParameters::Ptr replyParameters = nullptr, GenericReply::Ptr replyMarkup = nullptr, std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send a native poll. @@ -695,7 +720,7 @@ public: * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param isAnonymous Optional. True, if the poll needs to be anonymous, defaults to True * @param type Optional. Poll type, “quiz” or “regular”, defaults to “regular” * @param allowsMultipleAnswers Optional. True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False @@ -708,6 +733,7 @@ public: * @param isClosed Optional. Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -728,7 +754,8 @@ public: std::int32_t closeDate = 0, bool isClosed = false, std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to send an animated emoji that will display a random value. @@ -736,10 +763,11 @@ public: * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param emoji Optional. Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -749,7 +777,8 @@ public: GenericReply::Ptr replyMarkup = nullptr, const std::string& emoji = "", std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to change the chosen reactions on a message. @@ -759,7 +788,7 @@ public: * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param messageId Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead. - * @param reaction Optional. New list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. + * @param reaction Optional. A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. * @param isBig Optional. Pass True to set the reaction with a big animation * * @return Returns True on success. @@ -771,23 +800,26 @@ public: /** * @brief Use this method when you need to tell the user that something is happening on the bot's side. + * * 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. + * Example: The [ImageBot](https://t.me/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 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 + * @param messageThreadId Optional. Unique identifier for the target message thread; for supergroups only + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the action will be sent * * @return Returns True on success. */ bool sendChatAction(std::int64_t chatId, const std::string& action, - std::int32_t messageThreadId = 0) const; + std::int32_t messageThreadId = 0, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to get a list of profile pictures for a user. @@ -885,17 +917,17 @@ public: * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param userId Unique identifier of the target user * @param canChangeInfo Optional. Pass True if the administrator can change chat title, photo and other settings - * @param canPostMessages Optional. Pass True if the administrator can post messages in the channel, or access channel statistics; channels only - * @param canEditMessages Optional. Pass True if the administrator can edit messages of other users and can pin messages; channels only + * @param canPostMessages Optional. Pass True if the administrator can post messages in the channel, or access channel statistics; for channels only + * @param canEditMessages Optional. Pass True if the administrator can edit messages of other users and can pin messages; for channels only * @param canDeleteMessages Optional. Pass True if the administrator can delete messages of other users * @param canInviteUsers Optional. Pass True if the administrator can invite new users to the chat - * @param canPinMessages Optional. Pass True if the administrator can pin messages, supergroups only + * @param canPinMessages Optional. Pass True if the administrator can pin messages; for supergroups only * @param canPromoteMembers Optional. Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him) * @param isAnonymous Optional. Pass True if the administrator's presence in the chat is hidden * @param canManageChat Optional. Pass True if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege. * @param canManageVideoChats Optional. Pass True if the administrator can manage video chats * @param canRestrictMembers Optional. Pass True if the administrator can restrict, ban or unban chat members, or access supergroup statistics - * @param canManageTopics Optional. Pass True if the user is allowed to create, rename, close, and reopen forum topics, supergroups only + * @param canManageTopics Optional. Pass True if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only * @param canPostStories Optional. Pass True if the administrator can post stories to the chat * @param canEditStories Optional. Pass True if the administrator can edit stories posted by other users * @param canDeleteStories Optional. Pass True if the administrator can delete stories posted by other users @@ -1439,6 +1471,15 @@ public: std::int32_t userId) const; /** + * @brief Use this method to get information about the connection of the bot with a business account. + * + * @param businessConnectionId Unique identifier of the business connection + * + * @return Returns a BusinessConnection object on success. + */ + BusinessConnection::Ptr getBusinessConnection(const std::string& businessConnectionId) const; + + /** * @brief Use this method to change the list of the bot's commands. * * See https://core.telegram.org/bots#commands for more details about bot commands. @@ -1697,7 +1738,7 @@ public: * If some of the specified messages can't be found, they are skipped. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) - * @param messageIds Identifiers of 1-100 messages to delete. See Api::deleteMessage for limitations on which messages can be deleted + * @param messageIds A JSON-serialized list of 1-100 identifiers of messages to delete. See Api::deleteMessage for limitations on which messages can be deleted * * @return Returns True on success. */ @@ -1708,13 +1749,14 @@ public: * @brief Use this method to send static .WEBP, [animated](https://telegram.org/blog/animated-stickers) .TGS, or [video](https://telegram.org/blog/video-stickers-better-reactions) .WEBM stickers. * * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) - * @param sticker Sticker to send. Pass a fileId as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP or .TGS sticker using multipart/form-data. https://core.telegram.org/bots/api#sending-files. Video stickers can only be sent by a fileId. Animated stickers can't be sent via an HTTP URL. + * @param sticker Sticker to send. Pass a fileId as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. [More information on Sending Files »](https://core.telegram.org/bots/api#sending-files). Video and animated stickers can't be sent via an HTTP URL. * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. + * @param replyMarkup Optional. Additional interface options. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user. Not supported for messages sent on behalf of a business account * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving * @param emoji Optional. Emoji associated with the sticker; only for just uploaded stickers + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -1725,7 +1767,8 @@ public: bool disableNotification = false, std::int32_t messageThreadId = 0, bool protectContent = false, - const std::string& emoji = "") const; + const std::string& emoji = "", + const std::string& businessConnectionId = "") const; /** * @brief Use this method to get a sticker set. @@ -1739,19 +1782,19 @@ public: /** * @brief Use this method to get information about custom emoji stickers by their identifiers. * - * @param customEmojiIds List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. + * @param customEmojiIds A JSON-serialized list of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. * * @return Returns an Array of Sticker objects. */ std::vector<Sticker::Ptr> getCustomEmojiStickers(const std::vector<std::string>& customEmojiIds) const; /** - * @brief Use this method to upload a file with a sticker for later use in the Api::createNewStickerSet and Api::addStickerToSet methods (the file can be used multiple times). - * + * @brief Use this method to upload a file with a sticker for later use in the Api::createNewStickerSet, Api::addStickerToSet, or Api::replaceStickerInSet methods (the file can be used multiple times). + * * @param userId User identifier of sticker file owner * @param sticker A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. https://core.telegram.org/bots/api#sending-files * @param stickerFormat Format of the sticker, must be one of “static”, “animated”, “video” - * + * * @return Returns the uploaded File on success. */ File::Ptr uploadStickerFile(std::int64_t userId, @@ -1760,14 +1803,13 @@ public: /** * @brief Use this method to create a new sticker set owned by a user. - * + * * The bot will be able to edit the sticker set thus created. * * @param userId User identifier of created sticker set owner * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_<bot_username>". <bot_username> is case insensitive. 1-64 characters. * @param title Sticker set title, 1-64 characters * @param stickers A JSON-serialized list of 1-50 initial stickers to be added to the sticker set - * @param stickerFormat Format of stickers in the set, must be one of “static”, “animated”, “video” * @param stickerType Optional. Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created. * @param needsRepainting Optional. Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only * @@ -1777,17 +1819,14 @@ public: const std::string& name, const std::string& title, const std::vector<InputSticker::Ptr>& stickers, - const std::string& stickerFormat, - const std::string& stickerType = "", + Sticker::Type stickerType = Sticker::Type::Regular, bool needsRepainting = false) const; /** * @brief Use this method to add a new sticker to a set created by the bot. - * - * The format of the added sticker must match the format of the other stickers in the set. + * * Emoji sticker sets can have up to 200 stickers. - * Animated and video sticker sets can have up to 50 stickers. - * Static sticker sets can have up to 120 stickers. + * Other sticker sets can have up to 120 stickers. * * @param userId User identifier of sticker set owner * @param name Sticker set name @@ -1820,6 +1859,23 @@ public: bool deleteStickerFromSet(const std::string& sticker) const; /** + * @brief Use this method to replace an existing sticker in a sticker set with a new one. + * + * The method is equivalent to calling Api::deleteStickerFromSet, then Api::addStickerToSet, then Api::setStickerPositionInSet. + * + * @param userId User identifier of the sticker set owner + * @param name Sticker set name + * @param oldSticker File identifier of the replaced sticker + * @param sticker A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged. + * + * @return Returns True on success. + */ + bool replaceStickerInSet(std::int64_t userId, + const std::string& name, + const std::string& oldSticker, + InputSticker::Ptr sticker) const; + + /** * @brief 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. @@ -1871,17 +1927,19 @@ public: /** * @brief Use this method to set the thumbnail of a regular or mask sticker set. - * + * * The format of the thumbnail file must match the format of the stickers in the set. * * @param name Sticker set name * @param userId User identifier of the sticker set owner + * @param format Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a WEBM video * @param thumbnail Optional. A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a fileId as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. https://core.telegram.org/bots/api#sending-files. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. * * @return Returns True on success. */ bool setStickerSetThumbnail(const std::string& name, std::int64_t userId, + const std::string& format, boost::variant<InputFile::Ptr, std::string> thumbnail = "") const; /** @@ -2099,10 +2157,11 @@ public: * @param chatId Unique identifier for the target chat * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via @BotFather. * @param replyParameters Optional. Description of the message to reply to - * @param replyMarkup Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Play gameTitle' button will be shown. If not empty, the first button must launch the game. + * @param replyMarkup Optional. A JSON-serialized object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards). If empty, one 'Play gameTitle' button will be shown. If not empty, the first button must launch the game. Not supported for messages sent on behalf of a business account. * @param disableNotification Optional. Sends the message silently. Users will receive a notification with no sound. * @param messageThreadId Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only * @param protectContent Optional. Protects the contents of the sent message from forwarding and saving + * @param businessConnectionId Optional. Unique identifier of the business connection on behalf of which the message will be sent * * @return On success, the sent Message is returned. */ @@ -2112,7 +2171,8 @@ public: InlineKeyboardMarkup::Ptr replyMarkup = std::make_shared<InlineKeyboardMarkup>(), bool disableNotification = false, std::int32_t messageThreadId = 0, - bool protectContent = false) const; + bool protectContent = false, + const std::string& businessConnectionId = "") const; /** * @brief Use this method to set the score of the specified user in a game message. diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index f79b9c6..661930e 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -43,6 +43,7 @@ #include "tgbot/types/ForumTopicReopened.h" #include "tgbot/types/GeneralForumTopicHidden.h" #include "tgbot/types/GeneralForumTopicUnhidden.h" +#include "tgbot/types/SharedUser.h" #include "tgbot/types/UsersShared.h" #include "tgbot/types/ChatShared.h" #include "tgbot/types/WriteAccessAllowed.h" @@ -83,6 +84,11 @@ #include "tgbot/types/ChatMemberBanned.h" #include "tgbot/types/ChatJoinRequest.h" #include "tgbot/types/ChatPermissions.h" +#include "tgbot/types/Birthdate.h" +#include "tgbot/types/BusinessIntro.h" +#include "tgbot/types/BusinessLocation.h" +#include "tgbot/types/BusinessOpeningHoursInterval.h" +#include "tgbot/types/BusinessOpeningHours.h" #include "tgbot/types/ChatLocation.h" #include "tgbot/types/ReactionType.h" #include "tgbot/types/ReactionTypeEmoji.h" @@ -115,6 +121,8 @@ #include "tgbot/types/ChatBoostUpdated.h" #include "tgbot/types/ChatBoostRemoved.h" #include "tgbot/types/UserChatBoosts.h" +#include "tgbot/types/BusinessConnection.h" +#include "tgbot/types/BusinessMessagesDeleted.h" #include "tgbot/types/ResponseParameters.h" #include "tgbot/types/InputMedia.h" #include "tgbot/types/InputMediaPhoto.h" @@ -327,6 +335,9 @@ public: GeneralForumTopicUnhidden::Ptr parseJsonAndGetGeneralForumTopicUnhidden(const boost::property_tree::ptree& data) const; std::string parseGeneralForumTopicUnhidden(const GeneralForumTopicUnhidden::Ptr& object) const; + SharedUser::Ptr parseJsonAndGetSharedUser(const boost::property_tree::ptree& data) const; + std::string parseSharedUser(const SharedUser::Ptr& object) const; + UsersShared::Ptr parseJsonAndGetUsersShared(const boost::property_tree::ptree& data) const; std::string parseUsersShared(const UsersShared::Ptr& object) const; @@ -447,6 +458,21 @@ public: ChatPermissions::Ptr parseJsonAndGetChatPermissions(const boost::property_tree::ptree& data) const; std::string parseChatPermissions(const ChatPermissions::Ptr& object) const; + Birthdate::Ptr parseJsonAndGetBirthdate(const boost::property_tree::ptree& data) const; + std::string parseBirthdate(const Birthdate::Ptr& object) const; + + BusinessIntro::Ptr parseJsonAndGetBusinessIntro(const boost::property_tree::ptree& data) const; + std::string parseBusinessIntro(const BusinessIntro::Ptr& object) const; + + BusinessLocation::Ptr parseJsonAndGetBusinessLocation(const boost::property_tree::ptree& data) const; + std::string parseBusinessLocation(const BusinessLocation::Ptr& object) const; + + BusinessOpeningHoursInterval::Ptr parseJsonAndGetBusinessOpeningHoursInterval(const boost::property_tree::ptree& data) const; + std::string parseBusinessOpeningHoursInterval(const BusinessOpeningHoursInterval::Ptr& object) const; + + BusinessOpeningHours::Ptr parseJsonAndGetBusinessOpeningHours(const boost::property_tree::ptree& data) const; + std::string parseBusinessOpeningHours(const BusinessOpeningHours::Ptr& object) const; + ChatLocation::Ptr parseJsonAndGetChatLocation(const boost::property_tree::ptree& data) const; std::string parseChatLocation(const ChatLocation::Ptr& object) const; @@ -543,6 +569,12 @@ public: UserChatBoosts::Ptr parseJsonAndGetUserChatBoosts(const boost::property_tree::ptree& data) const; std::string parseUserChatBoosts(const UserChatBoosts::Ptr& object) const; + BusinessConnection::Ptr parseJsonAndGetBusinessConnection(const boost::property_tree::ptree& data) const; + std::string parseBusinessConnection(const BusinessConnection::Ptr& object) const; + + BusinessMessagesDeleted::Ptr parseJsonAndGetBusinessMessagesDeleted(const boost::property_tree::ptree& data) const; + std::string parseBusinessMessagesDeleted(const BusinessMessagesDeleted::Ptr& object) const; + ResponseParameters::Ptr parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const; std::string parseResponseParameters(const ResponseParameters::Ptr& object) const; diff --git a/include/tgbot/types/Birthdate.h b/include/tgbot/types/Birthdate.h new file mode 100644 index 0000000..af481cc --- /dev/null +++ b/include/tgbot/types/Birthdate.h @@ -0,0 +1,34 @@ +#ifndef TGBOT_BIRTHDATE_H +#define TGBOT_BIRTHDATE_H + +#include <cstdint> +#include <memory> + +namespace TgBot { + +/** + * @ingroup types + */ +class Birthdate { + +public: + typedef std::shared_ptr<Birthdate> Ptr; + + /** + * @brief Day of the user's birth; 1-31 + */ + std::uint8_t day; + + /** + * @brief Month of the user's birth; 1-12 + */ + std::uint8_t month; + + /** + * @brief Optional. Year of the user's birth + */ + std::uint16_t year; +}; +} + +#endif //TGBOT_BIRTHDATE_H diff --git a/include/tgbot/types/BusinessConnection.h b/include/tgbot/types/BusinessConnection.h new file mode 100644 index 0000000..349590b --- /dev/null +++ b/include/tgbot/types/BusinessConnection.h @@ -0,0 +1,57 @@ +#ifndef TGBOT_BUSINESSCONNECTION_H +#define TGBOT_BUSINESSCONNECTION_H + +#include "tgbot/types/User.h" + +#include <cstdint> +#include <memory> +#include <string> + +namespace TgBot { + +/** + * @brief Describes the connection of the bot with a business account. + * + * @ingroup types + */ +class BusinessConnection { + +public: + typedef std::shared_ptr<BusinessConnection> Ptr; + + /** + * @brief Unique identifier of the business connection + */ + std::string id; + + /** + * @brief Business account user that created the business connection + */ + User::Ptr user; + + /** + * @brief Identifier of a private chat with the user who created the business connection. + * + * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + */ + std::int64_t userChatId; + + /** + * @brief Date the connection was established in Unix time + */ + std::uint32_t date; + + /** + * @brief True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours + */ + bool canReply; + + /** + * @brief True, if the connection is active + */ + bool isEnabled; +}; +} + +#endif //TGBOT_BUSINESSCONNECTION_H diff --git a/include/tgbot/types/BusinessIntro.h b/include/tgbot/types/BusinessIntro.h new file mode 100644 index 0000000..7631870 --- /dev/null +++ b/include/tgbot/types/BusinessIntro.h @@ -0,0 +1,36 @@ +#ifndef TGBOT_BUSINESSINTRO_H +#define TGBOT_BUSINESSINTRO_H + +#include "tgbot/types/Sticker.h" + +#include <memory> +#include <string> + +namespace TgBot { + +/** + * @ingroup types + */ +class BusinessIntro { + +public: + typedef std::shared_ptr<BusinessIntro> Ptr; + + /** + * @brief Optional. Title text of the business intro + */ + std::string title; + + /** + * @brief Optional. Message text of the business intro + */ + std::string message; + + /** + * @brief Optional. Sticker of the business intro + */ + Sticker::Ptr sticker; +}; +} + +#endif //TGBOT_BUSINESSINTRO_H diff --git a/include/tgbot/types/BusinessLocation.h b/include/tgbot/types/BusinessLocation.h new file mode 100644 index 0000000..09137a5 --- /dev/null +++ b/include/tgbot/types/BusinessLocation.h @@ -0,0 +1,31 @@ +#ifndef TGBOT_BUSINESSLOCATION_H +#define TGBOT_BUSINESSLOCATION_H + +#include "tgbot/types/Location.h" + +#include <memory> +#include <string> + +namespace TgBot { + +/** + * @ingroup types + */ +class BusinessLocation { + +public: + typedef std::shared_ptr<BusinessLocation> Ptr; + + /** + * @brief Address of the business + */ + std::string address; + + /** + * @brief Optional. Location of the business + */ + Location::Ptr location; +}; +} + +#endif //TGBOT_BUSINESSLOCATION_H diff --git a/include/tgbot/types/BusinessMessagesDeleted.h b/include/tgbot/types/BusinessMessagesDeleted.h new file mode 100644 index 0000000..ee22639 --- /dev/null +++ b/include/tgbot/types/BusinessMessagesDeleted.h @@ -0,0 +1,42 @@ +#ifndef TGBOT_BUSINESSMESSAGESDELETED_H +#define TGBOT_BUSINESSMESSAGESDELETED_H + +#include "tgbot/types/Chat.h" + +#include <cstdint> +#include <memory> +#include <string> +#include <vector> + +namespace TgBot { + +/** + * @brief This object is received when messages are deleted from a connected business account. + * + * @ingroup types + */ +class BusinessMessagesDeleted { + +public: + typedef std::shared_ptr<BusinessMessagesDeleted> Ptr; + + /** + * @brief Unique identifier of the business connection + */ + std::string businessConnectionId; + + /** + * @brief Information about a chat in the business account. + * + * The bot may not have access to the chat or the corresponding user. + */ + Chat::Ptr chat; + + /** + * @brief A JSON-serialized list of identifiers of deleted messages in the chat of the business account + */ + std::vector<std::int32_t> messageIds; +}; +} + +#endif //TGBOT_BUSINESSMESSAGESDELETED_H diff --git a/include/tgbot/types/BusinessOpeningHours.h b/include/tgbot/types/BusinessOpeningHours.h new file mode 100644 index 0000000..94d7457 --- /dev/null +++ b/include/tgbot/types/BusinessOpeningHours.h @@ -0,0 +1,32 @@ +#ifndef TGBOT_BUSINESSOPENINGHOURS_H +#define TGBOT_BUSINESSOPENINGHOURS_H + +#include "tgbot/types/BusinessOpeningHoursInterval.h" + +#include <memory> +#include <string> +#include <vector> + +namespace TgBot { + +/** + * @ingroup types + */ +class BusinessOpeningHours { + +public: + typedef std::shared_ptr<BusinessOpeningHours> Ptr; + + /** + * @brief Unique name of the time zone for which the opening hours are defined + */ + std::string timeZoneName; + + /** + * @brief List of time intervals describing business opening hours + */ + std::vector<BusinessOpeningHoursInterval::Ptr> openingHours; +}; +} + +#endif //TGBOT_BUSINESSOPENINGHOURS_H diff --git a/include/tgbot/types/BusinessOpeningHoursInterval.h b/include/tgbot/types/BusinessOpeningHoursInterval.h new file mode 100644 index 0000000..500e46d --- /dev/null +++ b/include/tgbot/types/BusinessOpeningHoursInterval.h @@ -0,0 +1,29 @@ +#ifndef TGBOT_BUSINESSOPENINGHOURSINTERVAL_H +#define TGBOT_BUSINESSOPENINGHOURSINTERVAL_H + +#include <cstdint> +#include <memory> + +namespace TgBot { + +/** + * @ingroup types + */ +class BusinessOpeningHoursInterval { + +public: + typedef std::shared_ptr<BusinessOpeningHoursInterval> Ptr; + + /** + * @brief The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60 + */ + std::int32_t openingMinute; + + /** + * @brief The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60 + */ + std::int32_t closingMinute; +}; +} + +#endif //TGBOT_BUSINESSOPENINGHOURSINTERVAL_H diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h index e96009e..411c01d 100644 --- a/include/tgbot/types/Chat.h +++ b/include/tgbot/types/Chat.h @@ -2,6 +2,11 @@ #define TGBOT_CHAT_H #include "tgbot/types/ChatPhoto.h" +#include "tgbot/types/Birthdate.h" +#include "tgbot/types/BusinessIntro.h" +#include "tgbot/types/BusinessLocation.h" +#include "tgbot/types/BusinessOpeningHours.h" +#include "tgbot/types/Chat.h" #include "tgbot/types/ReactionType.h" #include "tgbot/types/ChatPermissions.h" #include "tgbot/types/ChatLocation.h" @@ -85,6 +90,41 @@ public: std::vector<std::string> activeUsernames; /** + * @brief Optional. For private chats, the date of birth of the user. + * + * Returned only in Api::getChat. + */ + Birthdate::Ptr birthdate; + + /** + * @brief Optional. For private chats with business accounts, the intro of the business. + * + * Returned only in Api::getChat. + */ + BusinessIntro::Ptr businessIntro; + + /** + * @brief Optional. For private chats with business accounts, the location of the business. + * + * Returned only in Api::getChat. + */ + BusinessLocation::Ptr businessLocation; + + /** + * @brief Optional. For private chats with business accounts, the opening hours of the business. + * + * Returned only in Api::getChat. + */ + BusinessOpeningHours::Ptr businessOpeningHours; + + /** + * @brief Optional. For private chats, the personal channel of the user. + * + * Returned only in Api::getChat. + */ + Chat::Ptr personalChat; + + /** * @brief Optional. List of available reactions allowed in the chat. * * If omitted, then all [emoji reactions](https://core.telegram.org/bots/api#reactiontypeemoji) are allowed. diff --git a/include/tgbot/types/ChatAdministratorRights.h b/include/tgbot/types/ChatAdministratorRights.h index aba0d90..3836070 100644 --- a/include/tgbot/types/ChatAdministratorRights.h +++ b/include/tgbot/types/ChatAdministratorRights.h @@ -73,22 +73,22 @@ public: bool canDeleteStories; /** - * @brief Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only + * @brief Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only */ bool canPostMessages; /** - * @brief Optional. True, if the administrator can edit messages of other users and can pin messages; channels only + * @brief Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only */ bool canEditMessages; /** - * @brief Optional. True, if the user is allowed to pin messages; groups and supergroups only + * @brief Optional. True, if the user is allowed to pin messages; for groups and supergroups only */ bool canPinMessages; /** - * @brief Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only + * @brief Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only */ bool canManageTopics; }; diff --git a/include/tgbot/types/ChatMemberAdministrator.h b/include/tgbot/types/ChatMemberAdministrator.h index 121c238..d9f7a45 100644 --- a/include/tgbot/types/ChatMemberAdministrator.h +++ b/include/tgbot/types/ChatMemberAdministrator.h @@ -87,22 +87,22 @@ public: bool canDeleteStories; /** - * @brief Optional. True, if the administrator can post messages in the channel, or access channel statistics; channels only + * @brief Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only */ bool canPostMessages; /** - * @brief Optional. True, if the administrator can edit messages of other users and can pin messages; channels only + * @brief Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only */ bool canEditMessages; /** - * @brief Optional. True, if the user is allowed to pin messages; groups and supergroups only + * @brief Optional. True, if the user is allowed to pin messages; for groups and supergroups only */ bool canPinMessages; /** - * @brief Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only + * @brief Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only */ bool canManageTopics; diff --git a/include/tgbot/types/ChatShared.h b/include/tgbot/types/ChatShared.h index ffb41b3..6d410d3 100644 --- a/include/tgbot/types/ChatShared.h +++ b/include/tgbot/types/ChatShared.h @@ -1,17 +1,21 @@ #ifndef TGBOT_CHATSHARED_H #define TGBOT_CHATSHARED_H +#include "tgbot/types/PhotoSize.h" + #include <cstdint> #include <memory> +#include <string> +#include <vector> namespace TgBot { /** - * @brief This object contains information about the chat whose identifier was shared with the bot using a KeyboardButtonRequestChat button. + * @brief This object contains information about a chat that was shared with the bot using a KeyboardButtonRequestChat button. * * @ingroup types */ -class ChatShared { +class ChatShared { public: typedef std::shared_ptr<ChatShared> Ptr; @@ -23,13 +27,28 @@ public: /** * @brief Identifier of the shared chat. - * + * * The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means. - * + * * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. */ std::int64_t chatId; + + /** + * @brief Optional. Title of the chat, if the title was requested by the bot. + */ + std::string title; + + /** + * @brief Optional. Username of the chat, if the username was requested by the bot and available. + */ + std::string username; + + /** + * @brief Optional. Available sizes of the chat photo, if the photo was requested by the bot + */ + std::vector<PhotoSize::Ptr> photo; }; } diff --git a/include/tgbot/types/EncryptedPassportElement.h b/include/tgbot/types/EncryptedPassportElement.h index 3557f27..4547fd5 100644 --- a/include/tgbot/types/EncryptedPassportElement.h +++ b/include/tgbot/types/EncryptedPassportElement.h @@ -1,5 +1,5 @@ -#ifndef TGBOT_CPP_ENCRYPTEDPASSPORTELEMENT_H -#define TGBOT_CPP_ENCRYPTEDPASSPORTELEMENT_H +#ifndef TGBOT_ENCRYPTEDPASSPORTELEMENT_H +#define TGBOT_ENCRYPTEDPASSPORTELEMENT_H #include "tgbot/types/PassportFile.h" @@ -10,7 +10,7 @@ namespace TgBot { /** - * @brief Contains information about documents or other Telegram Passport elements shared with the bot by the user. + * @brief Describes documents or other Telegram Passport elements shared with the bot by the user. * * @ingroup types */ @@ -20,65 +20,67 @@ public: typedef std::shared_ptr<EncryptedPassportElement> Ptr; /** - * @brief Element type. - * One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”. + * @brief Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”. */ std::string type; /** - * @brief Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. - * Can be decrypted and verified using the accompanying @ref EncryptedCredentials. + * @brief Optional. Base64-encoded encrypted Telegram Passport element data provided by the user; available only for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. + * + * Can be decrypted and verified using the accompanying EncryptedCredentials. */ std::string data; /** - * @brief Optional. User's verified phone number, available only for “phone_number” type + * @brief Optional. User's verified phone number; available only for “phone_number” type */ std::string phoneNumber; /** - * @brief Optional. User's verified email address, available only for “email” type + * @brief Optional. User's verified email address; available only for “email” type */ std::string email; /** - * @brief Optional. Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. - * Files can be decrypted and verified using the accompanying @ref EncryptedCredentials. + * @brief Optional. Array of encrypted files with documents provided by the user; available only for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. + * + * Files can be decrypted and verified using the accompanying EncryptedCredentials. */ std::vector<PassportFile::Ptr> files; /** - * @brief Optional. Encrypted file with the front side of the document, provided by the user. - * Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. - * The file can be decrypted and verified using the accompanying @ref EncryptedCredentials. + * @brief Optional. Encrypted file with the front side of the document, provided by the user; available only for “passport”, “driver_license”, “identity_card” and “internal_passport”. + * + * The file can be decrypted and verified using the accompanying EncryptedCredentials. */ PassportFile::Ptr frontSide; /** - * @brief Optional. Encrypted file with the reverse side of the document, provided by the user. - * Available for “driver_license” and “identity_card”. - * The file can be decrypted and verified using the accompanying @ref EncryptedCredentials. + * @brief Optional. Encrypted file with the reverse side of the document, provided by the user; available only for “driver_license” and “identity_card”. + * + * The file can be decrypted and verified using the accompanying EncryptedCredentials. */ PassportFile::Ptr reverseSide; /** - * @brief Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. - * The file can be decrypted and verified using the accompanying @ref EncryptedCredentials. + * @brief Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available if requested for “passport”, “driver_license”, “identity_card” and “internal_passport”. + * + * The file can be decrypted and verified using the accompanying EncryptedCredentials. */ PassportFile::Ptr selfie; /** - * @brief Optional. Array of encrypted files with translated versions of documents provided by the user. - * Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. - * Files can be decrypted and verified using the accompanying @ref EncryptedCredentials. + * @brief Optional. Array of encrypted files with translated versions of documents provided by the user; available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. + * + * Files can be decrypted and verified using the accompanying EncryptedCredentials. */ std::vector<PassportFile::Ptr> translation; /** - * @brief Base64-encoded element hash for using in @ref PassportElementErrorUnspecified + * @brief Base64-encoded element hash for using in PassportElementErrorUnspecified */ std::string hash; }; } -#endif //TGBOT_CPP_ENCRYPTEDPASSPORTELEMENT_H +#endif //TGBOT_ENCRYPTEDPASSPORTELEMENT_H diff --git a/include/tgbot/types/InputSticker.h b/include/tgbot/types/InputSticker.h index 06dafd2..e636ba6 100644 --- a/include/tgbot/types/InputSticker.h +++ b/include/tgbot/types/InputSticker.h @@ -15,28 +15,40 @@ namespace TgBot { * @ingroup types */ class InputSticker { + public: typedef std::shared_ptr<InputSticker> Ptr; /** * @brief The added sticker. + * * Pass a fileId as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. - * Animated and video stickers can't be uploaded via HTTP URL. https://core.telegram.org/bots/api#sending-files + * Animated and video stickers can't be uploaded via HTTP URL. + * [More information on Sending Files »](https://core.telegram.org/bots/api#sending-files) */ std::string sticker; /** + * @brief Format of the added sticker, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video + */ + std::string format; + + /** * @brief List of 1-20 emoji associated with the sticker */ std::vector<std::string> emojiList; /** - * @brief Optional. Position where the mask should be placed on faces. For “mask” stickers only. + * @brief Optional. Position where the mask should be placed on faces. + * + * For “mask” stickers only. */ MaskPosition::Ptr maskPosition; /** - * @brief 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. + * @brief 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. */ std::vector<std::string> keywords; }; diff --git a/include/tgbot/types/KeyboardButtonRequestChat.h b/include/tgbot/types/KeyboardButtonRequestChat.h index 92e858d..0b3d9ea 100644 --- a/include/tgbot/types/KeyboardButtonRequestChat.h +++ b/include/tgbot/types/KeyboardButtonRequestChat.h @@ -10,9 +10,9 @@ namespace TgBot { /** * @brief This object defines the criteria used to request a suitable chat. - * - * The identifier of the selected chat will be shared with the bot when the corresponding button is pressed. - * https://core.telegram.org/bots/features#chat-and-user-selection + * + * Information about the selected chat will be shared with the bot when the corresponding button is pressed. + * The bot will be granted requested rights in the сhat if appropriate [More about requesting chats »](https://core.telegram.org/bots/features#chat-and-user-selection) * * @ingroup types */ @@ -23,7 +23,7 @@ public: /** * @brief Signed 32-bit identifier of the request, which will be received back in the ChatShared object. - * + * * Must be unique within the message */ std::int32_t requestId; @@ -35,47 +35,62 @@ public: /** * @brief Optional. Pass True to request a forum supergroup, pass False to request a non-forum chat. - * + * * If not specified, no additional restrictions are applied. */ bool chatIsForum; /** * @brief Optional. Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. - * + * * If not specified, no additional restrictions are applied. */ bool chatHasUsername; /** * @brief Optional. Pass True to request a chat owned by the user. - * + * * Otherwise, no additional restrictions are applied. */ bool chatIsCreated; /** * @brief Optional. A JSON-serialized object listing the required administrator rights of the user in the chat. - * - * The rights must be a superset of bot_administrator_rights. + * + * The rights must be a superset of botAdministratorRights. * If not specified, no additional restrictions are applied. */ ChatAdministratorRights::Ptr userAdministratorRights; /** * @brief Optional. A JSON-serialized object listing the required administrator rights of the bot in the chat. - * - * The rights must be a subset of user_administrator_rights. + * + * The rights must be a subset of userAdministratorRights. * If not specified, no additional restrictions are applied. */ ChatAdministratorRights::Ptr botAdministratorRights; /** * @brief Optional. Pass True to request a chat with the bot as a member. - * + * * Otherwise, no additional restrictions are applied. */ bool botIsMember; + + /** + * @brief Optional. Pass True to request the chat's title + */ + bool requestTitle; + + /** + * @brief Optional. Pass True to request the chat's username + */ + bool requestUsername; + + /** + * @brief Optional. Pass True to request the chat's photo + */ + bool requestPhoto; }; } diff --git a/include/tgbot/types/KeyboardButtonRequestUsers.h b/include/tgbot/types/KeyboardButtonRequestUsers.h index 612bd2d..c124c6a 100644 --- a/include/tgbot/types/KeyboardButtonRequestUsers.h +++ b/include/tgbot/types/KeyboardButtonRequestUsers.h @@ -9,7 +9,7 @@ namespace TgBot { /** * @brief This object defines the criteria used to request suitable users. * - * The identifiers of the selected users will be shared with the bot when the corresponding button is pressed. + * Information about the selected users will be shared with the bot when the corresponding button is pressed. * [More about requesting users »](https://core.telegram.org/bots/features#chat-and-user-selection) * * @ingroup types @@ -46,6 +46,21 @@ public: * Defaults to 1. */ std::uint8_t maxQuantity; + + /** + * @brief Optional. Pass True to request the users' first and last name + */ + bool requestName; + + /** + * @brief Optional. Pass True to request the users' username + */ + bool requestUsername; + + /** + * @brief Optional. Pass True to request the users' photo + */ + bool requestPhoto; }; } diff --git a/include/tgbot/types/Message.h b/include/tgbot/types/Message.h index a6fb3aa..d56f7c4 100644 --- a/include/tgbot/types/Message.h +++ b/include/tgbot/types/Message.h @@ -98,6 +98,13 @@ public: std::int32_t senderBoostCount; /** + * @brief Optional. The bot that actually sent the message on behalf of the business account. + * + * Available only for outgoing messages sent on behalf of the connected business account. + */ + User::Ptr senderBusinessBot; + + /** * @brief Date the message was sent in Unix time. * * It is always a positive number, representing a valid date. @@ -105,6 +112,13 @@ public: std::uint32_t date; /** + * @brief Optional. Unique identifier of the business connection from which the message was received. + * + * If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier. + */ + std::string businessConnectionId; + + /** * @brief Chat the message belongs to */ Chat::Ptr chat; @@ -162,6 +176,11 @@ public: bool hasProtectedContent; /** + * @brief Optional. True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message + */ + bool isFromOffline; + + /** * @brief Optional. The unique identifier of a media message group this message belongs to */ std::string mediaGroupId; diff --git a/include/tgbot/types/ReplyParameters.h b/include/tgbot/types/ReplyParameters.h index 72b314f..537de07 100644 --- a/include/tgbot/types/ReplyParameters.h +++ b/include/tgbot/types/ReplyParameters.h @@ -26,12 +26,17 @@ public: std::int32_t messageId; /** - * @brief Optional. If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format @channelusername) + * @brief Optional. If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format @channelusername). + * + * Not supported for messages sent on behalf of a business account. */ std::int64_t chatId; /** - * @brief Optional. Pass True if the message should be sent even if the specified message to be replied to is not found; can be used only for replies in the same chat and forum topic. + * @brief Optional. Pass True if the message should be sent even if the specified message to be replied to is not found. + * + * Always False for replies in another chat or forum topic. + * Always True for messages sent on behalf of a business account. */ bool allowSendingWithoutReply; diff --git a/include/tgbot/types/SharedUser.h b/include/tgbot/types/SharedUser.h new file mode 100644 index 0000000..680b38b --- /dev/null +++ b/include/tgbot/types/SharedUser.h @@ -0,0 +1,54 @@ +#ifndef TGBOT_SHAREDUSER_H +#define TGBOT_SHAREDUSER_H + +#include "tgbot/types/PhotoSize.h" + +#include <cstdint> +#include <memory> +#include <string> +#include <vector> + +namespace TgBot { + +/** + * @brief This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUser button. + * + * @ingroup types + */ +class SharedUser { + +public: + typedef std::shared_ptr<SharedUser> Ptr; + + /** + * @brief Identifier of the shared user. + * + * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. + * The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means. + */ + std::int64_t userId; + + /** + * @brief Optional. First name of the user, if the name was requested by the bot + */ + std::string firstName; + + /** + * @brief Optional. Last name of the user, if the name was requested by the bot + */ + std::string lastName; + + /** + * @brief Optional. Username of the user, if the username was requested by the bot + */ + std::string username; + + /** + * @brief Optional. Available sizes of the chat photo, if the photo was requested by the bot + */ + std::vector<PhotoSize::Ptr> photo; +}; +} + +#endif //TGBOT_SHAREDUSER_H diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h index c55b577..db424dc 100644 --- a/include/tgbot/types/StickerSet.h +++ b/include/tgbot/types/StickerSet.h @@ -16,6 +16,7 @@ namespace TgBot { * @ingroup types */ class StickerSet { + public: typedef std::shared_ptr<StickerSet> Ptr; @@ -37,19 +38,9 @@ public: std::string title; /** - * @brief Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji” - */ - Type type; - - /** - * @brief True, if the sticker set contains animated stickers - */ - bool isAnimated; - - /** - * @brief True, if the sticker set contains video stickers + * @brief Type of stickers in the set, currently one of Type::Regular, Type::Mask, Type::CustomEmoji” */ - bool isVideo; + Type stickerType; /** * @brief List of all set stickers diff --git a/include/tgbot/types/Update.h b/include/tgbot/types/Update.h index 3ac17ba..a7ad470 100644 --- a/include/tgbot/types/Update.h +++ b/include/tgbot/types/Update.h @@ -2,6 +2,8 @@ #define TGBOT_UPDATE_H #include "tgbot/types/Message.h" +#include "tgbot/types/BusinessConnection.h" +#include "tgbot/types/BusinessMessagesDeleted.h" #include "tgbot/types/MessageReactionUpdated.h" #include "tgbot/types/MessageReactionCountUpdated.h" #include "tgbot/types/InlineQuery.h" @@ -67,6 +69,26 @@ public: Message::Ptr editedChannelPost; /** + * @brief Optional. The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot + */ + BusinessConnection::Ptr businessConnection; + + /** + * @brief Optional. New non-service message from a connected business account + */ + Message::Ptr businessMessage; + + /** + * @brief Optional. New version of a message from a connected business account + */ + Message::Ptr editedBusinessMessage; + + /** + * @brief Optional. Messages were deleted from a connected business account + */ + BusinessMessagesDeleted::Ptr deletedBusinessMessages; + + /** * @brief Optional. A reaction to a message was changed by a user. * * The bot must be an administrator in the chat and must explicitly specify "message_reaction" in the list of allowedUpdates to receive these updates. diff --git a/include/tgbot/types/User.h b/include/tgbot/types/User.h index 328c0a2..6b28e1d 100644 --- a/include/tgbot/types/User.h +++ b/include/tgbot/types/User.h @@ -2,8 +2,8 @@ #define TGBOT_USER_H #include <cstdint> -#include <string> #include <memory> +#include <string> namespace TgBot { @@ -12,14 +12,14 @@ namespace TgBot { * * @ingroup types */ -class User { +class User { public: typedef std::shared_ptr<User> Ptr; /** * @brief Unique identifier for this user or bot. - * + * * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. * But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. */ @@ -46,7 +46,7 @@ public: std::string username; /** - * @brief Optional. IETF language tag of the user's language + * @brief Optional. [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) of the user's language */ std::string languageCode; @@ -62,21 +62,31 @@ public: /** * @brief Optional. True, if the bot can be invited to groups. + * * Returned only in Api::getMe. */ bool canJoinGroups; /** - * @brief Optional. True, if privacy mode is disabled for the bot. + * @brief Optional. True, if [privacy mode](https://core.telegram.org/bots/features#privacy-mode) is disabled for the bot. + * * Returned only in Api::getMe. */ bool canReadAllGroupMessages; /** * @brief Optional. True, if the bot supports inline queries. + * * Returned only in Api::getMe. */ bool supportsInlineQueries; + + /** + * @brief Optional. True, if the bot can be connected to a Telegram Business account to receive its messages. + * + * Returned only in Api::getMe. + */ + bool canConnectToBusiness; }; } diff --git a/include/tgbot/types/UsersShared.h b/include/tgbot/types/UsersShared.h index 82a63e5..343ac82 100644 --- a/include/tgbot/types/UsersShared.h +++ b/include/tgbot/types/UsersShared.h @@ -1,6 +1,8 @@ #ifndef TGBOT_USERSSHARED_H #define TGBOT_USERSSHARED_H +#include "tgbot/types/SharedUser.h" + #include <cstdint> #include <memory> #include <vector> @@ -23,13 +25,9 @@ public: std::int32_t requestId; /** - * @brief Identifiers of the shared users. - * - * These numbers may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting them. - * But they have at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. - * The bot may not have access to the users and could be unable to use these identifiers, unless the users are already known to the bot by some other means. + * @brief Information about users shared with the bot. */ - std::vector<std::int64_t> userIds; + std::vector<SharedUser::Ptr> users; }; } diff --git a/src/Api.cpp b/src/Api.cpp index cdd5ad7..2c4b82a 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -119,10 +119,14 @@ Message::Ptr Api::sendMessage(boost::variant<std::int64_t, std::string> chatId, bool disableNotification, const std::vector<MessageEntity::Ptr>& entities, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(10); + args.reserve(11); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -298,10 +302,14 @@ Message::Ptr Api::sendPhoto(boost::variant<std::int64_t, std::string> chatId, const std::vector<MessageEntity::Ptr>& captionEntities, std::int32_t messageThreadId, bool protectContent, - bool hasSpoiler) const { + bool hasSpoiler, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(11); + args.reserve(12); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -353,10 +361,14 @@ Message::Ptr Api::sendAudio(boost::variant<std::int64_t, std::string> chatId, bool disableNotification, const std::vector<MessageEntity::Ptr>& captionEntities, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(14); + args.reserve(15); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -421,10 +433,14 @@ Message::Ptr Api::sendDocument(boost::variant<std::int64_t, std::string> chatId, const std::vector<MessageEntity::Ptr>& captionEntities, bool disableContentTypeDetection, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(12); + args.reserve(13); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -487,10 +503,14 @@ Message::Ptr Api::sendVideo(boost::variant<std::int64_t, std::string> chatId, const std::vector<MessageEntity::Ptr>& captionEntities, std::int32_t messageThreadId, bool protectContent, - bool hasSpoiler) const { + bool hasSpoiler, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(16); + args.reserve(17); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -564,10 +584,14 @@ Message::Ptr Api::sendAnimation(boost::variant<std::int64_t, std::string> chatId const std::vector<MessageEntity::Ptr>& captionEntities, std::int32_t messageThreadId, bool protectContent, - bool hasSpoiler) const { + bool hasSpoiler, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(15); + args.reserve(16); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -634,10 +658,14 @@ Message::Ptr Api::sendVoice(boost::variant<std::int64_t, std::string> chatId, bool disableNotification, const std::vector<MessageEntity::Ptr>& captionEntities, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(11); + args.reserve(12); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -685,10 +713,14 @@ Message::Ptr Api::sendVideoNote(boost::variant<std::int64_t, std::string> chatId boost::variant<InputFile::Ptr, std::string> thumbnail, GenericReply::Ptr replyMarkup, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(10); + args.reserve(11); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -735,10 +767,14 @@ std::vector<Message::Ptr> Api::sendMediaGroup(boost::variant<std::int64_t, std:: bool disableNotification, ReplyParameters::Ptr replyParameters, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(6); + args.reserve(7); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -768,10 +804,14 @@ Message::Ptr Api::sendLocation(boost::variant<std::int64_t, std::string> chatId, std::int32_t heading, std::int32_t proximityAlertRadius, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(12); + args.reserve(13); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -893,10 +933,14 @@ Message::Ptr Api::sendVenue(boost::variant<std::int64_t, std::string> chatId, const std::string& googlePlaceId, const std::string& googlePlaceType, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(14); + args.reserve(15); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -942,10 +986,14 @@ Message::Ptr Api::sendContact(boost::variant<std::int64_t, std::string> chatId, ReplyParameters::Ptr replyParameters, GenericReply::Ptr replyMarkup, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(10); + args.reserve(11); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -991,10 +1039,14 @@ Message::Ptr Api::sendPoll(boost::variant<std::int64_t, std::string> chatId, std::int32_t closeDate, bool isClosed, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(18); + args.reserve(19); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -1056,10 +1108,14 @@ Message::Ptr Api::sendDice(boost::variant<std::int64_t, std::string> chatId, GenericReply::Ptr replyMarkup, const std::string& emoji, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(7); + args.reserve(8); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -1104,10 +1160,14 @@ bool Api::setMessageReaction(boost::variant<std::int64_t, std::string> chatId, bool Api::sendChatAction(std::int64_t chatId, const std::string& action, - std::int32_t messageThreadId) const { + std::int32_t messageThreadId, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(3); + args.reserve(4); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); args.emplace_back("action", action); if (messageThreadId != 0) { @@ -1745,6 +1805,15 @@ UserChatBoosts::Ptr Api::getUserChatBoosts(boost::variant<std::int64_t, std::str return _tgTypeParser.parseJsonAndGetUserChatBoosts(sendRequest("getUserChatBoosts", args)); } +BusinessConnection::Ptr Api::getBusinessConnection(const std::string& businessConnectionId) const { + std::vector<HttpReqArg> args; + args.reserve(1); + + args.emplace_back("business_connection_id", businessConnectionId); + + return _tgTypeParser.parseJsonAndGetBusinessConnection(sendRequest("getBusinessConnection", args)); +} + bool Api::setMyCommands(const std::vector<BotCommand::Ptr>& commands, BotCommandScope::Ptr scope, const std::string& languageCode) const { @@ -2137,10 +2206,14 @@ Message::Ptr Api::sendSticker(boost::variant<std::int64_t, std::string> chatId, bool disableNotification, std::int32_t messageThreadId, bool protectContent, - const std::string& emoji) const { + const std::string& emoji, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(8); + args.reserve(9); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); @@ -2208,19 +2281,21 @@ bool Api::createNewStickerSet(std::int64_t userId, const std::string& name, const std::string& title, const std::vector<InputSticker::Ptr>& stickers, - const std::string& stickerFormat, - const std::string& stickerType, + Sticker::Type stickerType, bool needsRepainting) const { std::vector<HttpReqArg> args; - args.reserve(7); + args.reserve(6); args.emplace_back("user_id", userId); args.emplace_back("name", name); args.emplace_back("title", title); args.emplace_back("stickers", _tgTypeParser.parseArray<InputSticker>(&TgTypeParser::parseInputSticker, stickers)); - args.emplace_back("sticker_format", stickerFormat); - if (!stickerType.empty()) { - args.emplace_back("sticker_type", stickerType); + if (stickerType == Sticker::Type::Regular) { + args.emplace_back("sticker_type", "regular"); + } else if (stickerType == Sticker::Type::Mask) { + args.emplace_back("sticker_type", "mask"); + } else if (stickerType == Sticker::Type::CustomEmoji) { + args.emplace_back("sticker_type", "custom_emoji"); } if (needsRepainting) { args.emplace_back("needs_repainting", needsRepainting); @@ -2262,6 +2337,21 @@ bool Api::deleteStickerFromSet(const std::string& sticker) const { return sendRequest("deleteStickerFromSet", args).get<bool>("", false); } +bool Api::replaceStickerInSet(std::int64_t userId, + const std::string& name, + const std::string& oldSticker, + InputSticker::Ptr sticker) const { + std::vector<HttpReqArg> args; + args.reserve(4); + + args.emplace_back("user_id", userId); + args.emplace_back("name", name); + args.emplace_back("old_sticker", oldSticker); + args.emplace_back("sticker", _tgTypeParser.parseInputSticker(sticker)); + + return sendRequest("replaceStickerInSet", args).get<bool>("", false); +} + bool Api::setStickerEmojiList(const std::string& sticker, const std::vector<std::string>& emojiList) const { std::vector<HttpReqArg> args; @@ -2318,12 +2408,14 @@ bool Api::setStickerSetTitle(const std::string& name, bool Api::setStickerSetThumbnail(const std::string& name, std::int64_t userId, + const std::string& format, boost::variant<InputFile::Ptr, std::string> thumbnail) const { std::vector<HttpReqArg> args; - args.reserve(3); + args.reserve(4); args.emplace_back("name", name); args.emplace_back("user_id", userId); + args.emplace_back("format", format); if (thumbnail.which() == 0) { // InputFile::Ptr if (boost::get<InputFile::Ptr>(thumbnail) != nullptr) { auto file = boost::get<InputFile::Ptr>(thumbnail); @@ -2625,10 +2717,14 @@ Message::Ptr Api::sendGame(std::int64_t chatId, InlineKeyboardMarkup::Ptr replyMarkup, bool disableNotification, std::int32_t messageThreadId, - bool protectContent) const { + bool protectContent, + const std::string& businessConnectionId) const { std::vector<HttpReqArg> args; - args.reserve(7); + args.reserve(8); + if (!businessConnectionId.empty()) { + args.emplace_back("business_connection_id", businessConnectionId); + } args.emplace_back("chat_id", chatId); if (messageThreadId != 0) { args.emplace_back("message_thread_id", messageThreadId); diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index a35a7c8..d3e9bd9 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -9,6 +9,10 @@ Update::Ptr TgTypeParser::parseJsonAndGetUpdate(const boost::property_tree::ptre result->editedMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "edited_message"); result->channelPost = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "channel_post"); result->editedChannelPost = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "edited_channel_post"); + result->businessConnection = tryParseJson<BusinessConnection>(&TgTypeParser::parseJsonAndGetBusinessConnection, data, "business_connection"); + result->businessMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "business_message"); + result->editedBusinessMessage = tryParseJson<Message>(&TgTypeParser::parseJsonAndGetMessage, data, "edited_business_message"); + result->deletedBusinessMessages = tryParseJson<BusinessMessagesDeleted>(&TgTypeParser::parseJsonAndGetBusinessMessagesDeleted, data, "deleted_business_messages"); result->messageReaction = tryParseJson<MessageReactionUpdated>(&TgTypeParser::parseJsonAndGetMessageReactionUpdated, data, "message_reaction"); result->messageReactionCount = tryParseJson<MessageReactionCountUpdated>(&TgTypeParser::parseJsonAndGetMessageReactionCountUpdated, data, "message_reaction_count"); result->inlineQuery = tryParseJson<InlineQuery>(&TgTypeParser::parseJsonAndGetInlineQuery, data, "inline_query"); @@ -37,6 +41,10 @@ std::string TgTypeParser::parseUpdate(const Update::Ptr& object) const { appendToJson(result, "edited_message", parseMessage(object->editedMessage)); appendToJson(result, "channel_post", parseMessage(object->channelPost)); appendToJson(result, "edited_channel_post", parseMessage(object->editedChannelPost)); + appendToJson(result, "business_connection", parseBusinessConnection(object->businessConnection)); + appendToJson(result, "business_message", parseMessage(object->businessMessage)); + appendToJson(result, "edited_business_message", parseMessage(object->editedBusinessMessage)); + appendToJson(result, "deleted_business_messages", parseBusinessMessagesDeleted(object->deletedBusinessMessages)); appendToJson(result, "message_reaction", parseMessageReactionUpdated(object->messageReaction)); appendToJson(result, "message_reaction_count", parseMessageReactionCountUpdated(object->messageReactionCount)); appendToJson(result, "inline_query", parseInlineQuery(object->inlineQuery)); @@ -69,8 +77,7 @@ WebhookInfo::Ptr TgTypeParser::parseJsonAndGetWebhookInfo(const boost::property_ result->allowedUpdates = parseJsonAndGetArray<std::string>( [] (const boost::property_tree::ptree& innerData)->std::string { return innerData.get<std::string>(""); - } - , data, "allowed_updates"); + }, data, "allowed_updates"); return result; } @@ -88,11 +95,10 @@ std::string TgTypeParser::parseWebhookInfo(const WebhookInfo::Ptr& object) const appendToJson(result, "last_error_message", object->lastErrorMessage); appendToJson(result, "last_synchronization_error_date", object->lastSynchronizationErrorDate); appendToJson(result, "max_connections", object->maxConnections); - appendToJson(result, "allowed_updates", - parseArray<std::string>([] (const std::string& s)->std::string { + appendToJson(result, "allowed_updates", parseArray<std::string>( + [] (const std::string& s)->std::string { return s; - } - , object->allowedUpdates)); + }, object->allowedUpdates)); removeLastComma(result); result += '}'; return result; @@ -111,6 +117,7 @@ User::Ptr TgTypeParser::parseJsonAndGetUser(const boost::property_tree::ptree& d result->canJoinGroups = data.get<bool>("can_join_groups", false); result->canReadAllGroupMessages = data.get<bool>("can_read_all_group_messages", false); result->supportsInlineQueries = data.get<bool>("supports_inline_queries", false); + result->canConnectToBusiness = data.get<bool>("can_connect_to_business", false); return result; } @@ -131,6 +138,7 @@ std::string TgTypeParser::parseUser(const User::Ptr& object) const { appendToJson(result, "can_join_groups", object->canJoinGroups); appendToJson(result, "can_read_all_group_messages", object->canReadAllGroupMessages); appendToJson(result, "supports_inline_queries", object->supportsInlineQueries); + appendToJson(result, "can_connect_to_business", object->canConnectToBusiness); removeLastComma(result); result += '}'; return result; @@ -159,6 +167,11 @@ Chat::Ptr TgTypeParser::parseJsonAndGetChat(const boost::property_tree::ptree& d [] (const boost::property_tree::ptree& innerData)->std::string { return innerData.get<std::string>(""); }, data, "active_usernames"); + result->birthdate = tryParseJson<Birthdate>(&TgTypeParser::parseJsonAndGetBirthdate, data, "birthdate"); + result->businessIntro = tryParseJson<BusinessIntro>(&TgTypeParser::parseJsonAndGetBusinessIntro, data, "business_intro"); + result->businessLocation = tryParseJson<BusinessLocation>(&TgTypeParser::parseJsonAndGetBusinessLocation, data, "business_location"); + result->businessOpeningHours = tryParseJson<BusinessOpeningHours>(&TgTypeParser::parseJsonAndGetBusinessOpeningHours, data, "business_opening_hours"); + result->personalChat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "personal_chat"); result->availableReactions = parseJsonAndGetArray<ReactionType>(&TgTypeParser::parseJsonAndGetReactionType, data, "available_reactions"); result->accentColorId = data.get<std::int32_t>("accent_color_id", 0); result->backgroundCustomEmojiId = data.get<std::string>("background_custom_emoji_id", ""); @@ -216,6 +229,11 @@ std::string TgTypeParser::parseChat(const Chat::Ptr& object) const { [] (const std::string& s)->std::string { return s; }, object->activeUsernames)); + appendToJson(result, "birthdate", parseBirthdate(object->birthdate)); + appendToJson(result, "business_intro", parseBusinessIntro(object->businessIntro)); + appendToJson(result, "business_location", parseBusinessLocation(object->businessLocation)); + appendToJson(result, "business_opening_hours", parseBusinessOpeningHours(object->businessOpeningHours)); + appendToJson(result, "personal_chat", parseChat(object->personalChat)); appendToJson(result, "available_reactions", parseArray(&TgTypeParser::parseReactionType, object->availableReactions)); appendToJson(result, "accent_color_id", object->accentColorId); appendToJson(result, "background_custom_emoji_id", object->backgroundCustomEmojiId); @@ -256,7 +274,9 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const boost::property_tree::pt result->from = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "from"); result->senderChat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "sender_chat"); result->senderBoostCount = data.get<std::int32_t>("sender_boost_count", 0); + result->senderBusinessBot = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "sender_business_bot"); result->date = data.get<std::uint32_t>("date", 0); + result->businessConnectionId = data.get<std::string>("business_connection_id", ""); result->chat = parseJsonAndGetChat(data.find("chat")->second); result->forwardOrigin = tryParseJson<MessageOrigin>(&TgTypeParser::parseJsonAndGetMessageOrigin, data, "forward_origin"); result->isTopicMessage = data.get<bool>("is_topic_message", false); @@ -268,6 +288,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const boost::property_tree::pt result->viaBot = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "via_bot"); result->editDate = data.get<std::uint32_t>("edit_date", 0); result->hasProtectedContent = data.get<bool>("has_protected_content", false); + result->isFromOffline = data.get<bool>("is_from_offline", false); result->mediaGroupId = data.get<std::string>("media_group_id", ""); result->authorSignature = data.get<std::string>("author_signature", ""); result->text = data.get<std::string>("text", ""); @@ -342,7 +363,9 @@ std::string TgTypeParser::parseMessage(const Message::Ptr& object) const { appendToJson(result, "from", parseUser(object->from)); appendToJson(result, "sender_chat", parseChat(object->senderChat)); appendToJson(result, "sender_boost_count", object->senderBoostCount); + appendToJson(result, "sender_business_bot", parseUser(object->senderBusinessBot)); appendToJson(result, "date", object->date); + appendToJson(result, "business_connection_id", object->businessConnectionId); appendToJson(result, "chat", parseChat(object->chat)); appendToJson(result, "forward_origin", parseMessageOrigin(object->forwardOrigin)); appendToJson(result, "is_topic_message", object->isTopicMessage); @@ -354,6 +377,7 @@ std::string TgTypeParser::parseMessage(const Message::Ptr& object) const { appendToJson(result, "via_bot", parseUser(object->viaBot)); appendToJson(result, "edit_date", object->editDate); appendToJson(result, "has_protected_content", object->hasProtectedContent); + appendToJson(result, "is_from_offline", object->isFromOffline); appendToJson(result, "media_group_id", object->mediaGroupId); appendToJson(result, "author_signature", object->authorSignature); appendToJson(result, "text", object->text); @@ -1343,7 +1367,7 @@ std::string TgTypeParser::parseForumTopicClosed(const ForumTopicClosed::Ptr& obj } std::string result; result += '{'; - //removeLastComma(result); + // removeLastComma(result); result += '}'; return result; } @@ -1379,7 +1403,7 @@ std::string TgTypeParser::parseForumTopicReopened(const ForumTopicReopened::Ptr& } std::string result; result += '{'; - //removeLastComma(result); + // removeLastComma(result); result += '}'; return result; } @@ -1395,7 +1419,7 @@ std::string TgTypeParser::parseGeneralForumTopicHidden(const GeneralForumTopicHi } std::string result; result += '{'; - //removeLastComma(result); + // removeLastComma(result); result += '}'; return result; } @@ -1411,7 +1435,33 @@ std::string TgTypeParser::parseGeneralForumTopicUnhidden(const GeneralForumTopic } std::string result; result += '{'; - //removeLastComma(result); + // removeLastComma(result); + result += '}'; + return result; +} + +SharedUser::Ptr TgTypeParser::parseJsonAndGetSharedUser(const boost::property_tree::ptree& data) const { + auto result(std::make_shared<SharedUser>()); + result->userId = data.get<std::int64_t>("user_id", 0); + result->firstName = data.get<std::string>("first_name", ""); + result->lastName = data.get<std::string>("last_name", ""); + result->username = data.get<std::string>("username", ""); + result->photo = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photo"); + return result; +} + +std::string TgTypeParser::parseSharedUser(const SharedUser::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "user_id", object->userId); + appendToJson(result, "first_name", object->firstName); + appendToJson(result, "last_name", object->lastName); + appendToJson(result, "username", object->username); + appendToJson(result, "photo", parseArray(&TgTypeParser::parsePhotoSize, object->photo)); + removeLastComma(result); result += '}'; return result; } @@ -1419,10 +1469,7 @@ std::string TgTypeParser::parseGeneralForumTopicUnhidden(const GeneralForumTopic UsersShared::Ptr TgTypeParser::parseJsonAndGetUsersShared(const boost::property_tree::ptree& data) const { auto result(std::make_shared<UsersShared>()); result->requestId = data.get<std::int32_t>("request_id", 0); - result->userIds = parseJsonAndGetArray<std::int64_t>( - [] (const boost::property_tree::ptree& innerData)->std::int64_t { - return innerData.get<std::int64_t>(""); - }, data, "user_ids"); + result->users = parseJsonAndGetArray<SharedUser>(&TgTypeParser::parseJsonAndGetSharedUser, data, "users"); return result; } @@ -1433,10 +1480,7 @@ std::string TgTypeParser::parseUsersShared(const UsersShared::Ptr& object) const std::string result; result += '{'; appendToJson(result, "request_id", object->requestId); - appendToJson(result, "user_ids", parseArray<std::int64_t>( - [] (std::int64_t i)->std::int64_t { - return i; - }, object->userIds)); + appendToJson(result, "users", parseArray(&TgTypeParser::parseSharedUser, object->users)); removeLastComma(result); result += '}'; return result; @@ -1446,6 +1490,9 @@ ChatShared::Ptr TgTypeParser::parseJsonAndGetChatShared(const boost::property_tr auto result(std::make_shared<ChatShared>()); result->requestId = data.get<std::int32_t>("request_id", 0); result->chatId = data.get<std::int64_t>("chat_id", 0); + result->title = data.get<std::string>("title", ""); + result->username = data.get<std::string>("username", ""); + result->photo = parseJsonAndGetArray<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photo"); return result; } @@ -1457,6 +1504,9 @@ std::string TgTypeParser::parseChatShared(const ChatShared::Ptr& object) const { result += '{'; appendToJson(result, "request_id", object->requestId); appendToJson(result, "chat_id", object->chatId); + appendToJson(result, "title", object->title); + appendToJson(result, "username", object->username); + appendToJson(result, "photo", parseArray(&TgTypeParser::parsePhotoSize, object->photo)); removeLastComma(result); result += '}'; return result; @@ -1513,7 +1563,7 @@ std::string TgTypeParser::parseVideoChatStarted(const VideoChatStarted::Ptr& obj } std::string result; result += '{'; - //removeLastComma(result); + // removeLastComma(result); result += '}'; return result; } @@ -1834,6 +1884,9 @@ KeyboardButtonRequestUsers::Ptr TgTypeParser::parseJsonAndGetKeyboardButtonReque result->userIsBot = data.get<bool>("user_is_bot", false); result->userIsPremium = data.get<bool>("user_is_premium", false); result->maxQuantity = data.get<std::uint8_t>("max_quantity", 1); + result->requestName = data.get<bool>("request_name", false); + result->requestUsername = data.get<bool>("request_username", false); + result->requestPhoto = data.get<bool>("request_photo", false); return result; } @@ -1847,6 +1900,9 @@ std::string TgTypeParser::parseKeyboardButtonRequestUsers(const KeyboardButtonRe appendToJson(result, "user_is_bot", object->userIsBot); appendToJson(result, "user_is_premium", object->userIsPremium); appendToJson(result, "max_quantity", object->maxQuantity); + appendToJson(result, "request_name", object->requestName); + appendToJson(result, "request_username", object->requestUsername); + appendToJson(result, "request_photo", object->requestPhoto); removeLastComma(result); result += '}'; return result; @@ -1862,6 +1918,9 @@ KeyboardButtonRequestChat::Ptr TgTypeParser::parseJsonAndGetKeyboardButtonReques result->userAdministratorRights = tryParseJson<ChatAdministratorRights>(&TgTypeParser::parseJsonAndGetChatAdministratorRights, data, "user_administrator_rights"); result->botAdministratorRights = tryParseJson<ChatAdministratorRights>(&TgTypeParser::parseJsonAndGetChatAdministratorRights, data, "bot_administrator_rights"); result->botIsMember = data.get<bool>("bot_is_member", false); + result->requestTitle = data.get<bool>("request_title", false); + result->requestUsername = data.get<bool>("request_username", false); + result->requestPhoto = data.get<bool>("request_photo", false); return result; } @@ -1879,6 +1938,9 @@ std::string TgTypeParser::parseKeyboardButtonRequestChat(const KeyboardButtonReq appendToJson(result, "user_administrator_rights", parseChatAdministratorRights(object->userAdministratorRights)); appendToJson(result, "bot_administrator_rights", parseChatAdministratorRights(object->botAdministratorRights)); appendToJson(result, "bot_is_member", object->botIsMember); + appendToJson(result, "request_title", object->requestTitle); + appendToJson(result, "request_username", object->requestUsername); + appendToJson(result, "request_photo", object->requestPhoto); removeLastComma(result); result += '}'; return result; @@ -2524,6 +2586,110 @@ std::string TgTypeParser::parseChatPermissions(const ChatPermissions::Ptr& objec return result; } +Birthdate::Ptr TgTypeParser::parseJsonAndGetBirthdate(const boost::property_tree::ptree& data) const { + auto result(std::make_shared<Birthdate>()); + result->day = data.get<std::uint8_t>("day", 0); + result->month = data.get<std::uint8_t>("month", 0); + result->year = data.get<std::uint16_t>("year", 0); + return result; +} + +std::string TgTypeParser::parseBirthdate(const Birthdate::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "day", object->day); + appendToJson(result, "month", object->month); + appendToJson(result, "year", object->year); + removeLastComma(result); + result += '}'; + return result; +} + +BusinessIntro::Ptr TgTypeParser::parseJsonAndGetBusinessIntro(const boost::property_tree::ptree& data) const { + auto result(std::make_shared<BusinessIntro>()); + result->title = data.get<std::string>("title", ""); + result->message = data.get<std::string>("message", ""); + result->sticker = tryParseJson<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "sticker"); + return result; +} + +std::string TgTypeParser::parseBusinessIntro(const BusinessIntro::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "title", object->title); + appendToJson(result, "message", object->message); + appendToJson(result, "sticker", parseSticker(object->sticker)); + removeLastComma(result); + result += '}'; + return result; +} + +BusinessLocation::Ptr TgTypeParser::parseJsonAndGetBusinessLocation(const boost::property_tree::ptree& data) const { + auto result(std::make_shared<BusinessLocation>()); + result->address = data.get<std::string>("address", ""); + result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location"); + return result; +} + +std::string TgTypeParser::parseBusinessLocation(const BusinessLocation::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "address", object->address); + appendToJson(result, "location", parseLocation(object->location)); + removeLastComma(result); + result += '}'; + return result; +} + +BusinessOpeningHoursInterval::Ptr TgTypeParser::parseJsonAndGetBusinessOpeningHoursInterval(const boost::property_tree::ptree& data) const { + auto result(std::make_shared<BusinessOpeningHoursInterval>()); + result->openingMinute = data.get<std::int32_t>("opening_minute", 0); + result->closingMinute = data.get<std::int32_t>("closing_minute", 0); + return result; +} + +std::string TgTypeParser::parseBusinessOpeningHoursInterval(const BusinessOpeningHoursInterval::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "opening_minute", object->openingMinute); + appendToJson(result, "closing_minute", object->closingMinute); + removeLastComma(result); + result += '}'; + return result; +} + +BusinessOpeningHours::Ptr TgTypeParser::parseJsonAndGetBusinessOpeningHours(const boost::property_tree::ptree& data) const { + auto result(std::make_shared<BusinessOpeningHours>()); + result->timeZoneName = data.get<std::string>("time_zone_name", ""); + result->openingHours = parseJsonAndGetArray<BusinessOpeningHoursInterval>(&TgTypeParser::parseJsonAndGetBusinessOpeningHoursInterval, data, "opening_hours"); + return result; +} + +std::string TgTypeParser::parseBusinessOpeningHours(const BusinessOpeningHours::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "time_zone_name", object->timeZoneName); + appendToJson(result, "opening_hours", parseArray(&TgTypeParser::parseBusinessOpeningHoursInterval, object->openingHours)); + removeLastComma(result); + result += '}'; + return result; +} + ChatLocation::Ptr TgTypeParser::parseJsonAndGetChatLocation(const boost::property_tree::ptree& data) const { auto result(std::make_shared<ChatLocation>()); result->location = tryParseJson<Location>(&TgTypeParser::parseJsonAndGetLocation, data, "location"); @@ -3251,6 +3417,62 @@ std::string TgTypeParser::parseUserChatBoosts(const UserChatBoosts::Ptr& object) return result; } +BusinessConnection::Ptr TgTypeParser::parseJsonAndGetBusinessConnection(const boost::property_tree::ptree& data) const { + auto result(std::make_shared<BusinessConnection>()); + result->id = data.get<std::string>("id", ""); + result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user"); + result->userChatId = data.get<std::int64_t>("user_chat_id", 0); + result->date = data.get<std::uint32_t>("date", 0); + result->canReply = data.get<bool>("can_reply", false); + result->isEnabled = data.get<bool>("is_enabled", false); + return result; +} + +std::string TgTypeParser::parseBusinessConnection(const BusinessConnection::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "id", object->id); + appendToJson(result, "user", parseUser(object->user)); + appendToJson(result, "user_chat_id", object->userChatId); + appendToJson(result, "date", object->date); + appendToJson(result, "can_reply", object->canReply); + appendToJson(result, "is_enabled", object->isEnabled); + removeLastComma(result); + result += '}'; + return result; +} + +BusinessMessagesDeleted::Ptr TgTypeParser::parseJsonAndGetBusinessMessagesDeleted(const boost::property_tree::ptree& data) const { + auto result(std::make_shared<BusinessMessagesDeleted>()); + result->businessConnectionId = data.get<std::string>("business_connection_id", ""); + result->chat = tryParseJson<Chat>(&TgTypeParser::parseJsonAndGetChat, data, "chat"); + result->messageIds = parseJsonAndGetArray<std::int32_t>( + [] (const boost::property_tree::ptree& innerData)->std::int32_t { + return innerData.get<std::int32_t>(""); + }, data, "message_ids"); + return result; +} + +std::string TgTypeParser::parseBusinessMessagesDeleted(const BusinessMessagesDeleted::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "business_connection_id", object->businessConnectionId); + appendToJson(result, "chat", parseChat(object->chat)); + appendToJson(result, "message_ids", parseArray<std::int32_t>( + [] (std::int32_t i)->std::int32_t { + return i; + }, object->messageIds)); + removeLastComma(result); + result += '}'; + return result; +} + ResponseParameters::Ptr TgTypeParser::parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const { auto result(std::make_shared<ResponseParameters>()); result->migrateToChatId = data.get<std::int64_t>("migrate_to_chat_id", 0); @@ -3511,16 +3733,14 @@ StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const boost::property_tr auto result(std::make_shared<StickerSet>()); result->name = data.get<std::string>("name", ""); result->title = data.get<std::string>("title", ""); - std::string type = data.get<std::string>("type", ""); - if (type == "regular") { - result->type = StickerSet::Type::Regular; - } else if (type == "mask") { - result->type = StickerSet::Type::Mask; - } else if (type == "custom_emoji") { - result->type = StickerSet::Type::CustomEmoji; + std::string stickerType = data.get<std::string>("sticker_type", ""); + if (stickerType == "regular") { + result->stickerType = StickerSet::Type::Regular; + } else if (stickerType == "mask") { + result->stickerType = StickerSet::Type::Mask; + } else if (stickerType == "custom_emoji") { + result->stickerType = StickerSet::Type::CustomEmoji; } - result->isAnimated = data.get<bool>("is_animated", false); - result->isVideo = data.get<bool>("is_video", false); result->stickers = parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "stickers"); result->thumbnail = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumbnail"); return result; @@ -3534,15 +3754,13 @@ std::string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const { result += '{'; appendToJson(result, "name", object->name); appendToJson(result, "title", object->title); - if (object->type == StickerSet::Type::Regular) { - appendToJson(result, "type", "regular"); - } else if (object->type == StickerSet::Type::Mask) { - appendToJson(result, "type", "mask"); - } else if (object->type == StickerSet::Type::CustomEmoji) { - appendToJson(result, "type", "custom_emoji"); + if (object->stickerType == StickerSet::Type::Regular) { + appendToJson(result, "sticker_type", "regular"); + } else if (object->stickerType == StickerSet::Type::Mask) { + appendToJson(result, "sticker_type", "mask"); + } else if (object->stickerType == StickerSet::Type::CustomEmoji) { + appendToJson(result, "sticker_type", "custom_emoji"); } - appendToJson(result, "is_animated", object->isAnimated); - appendToJson(result, "is_video", object->isVideo); appendToJson(result, "stickers", parseArray(&TgTypeParser::parseSticker, object->stickers)); appendToJson(result, "thumbnail", parsePhotoSize(object->thumbnail)); removeLastComma(result); @@ -3577,17 +3795,16 @@ std::string TgTypeParser::parseMaskPosition(const MaskPosition::Ptr& object) con InputSticker::Ptr TgTypeParser::parseJsonAndGetInputSticker(const boost::property_tree::ptree& data) const { auto result(std::make_shared<InputSticker>()); result->sticker = data.get<std::string>("sticker", ""); + result->format = data.get<std::string>("format", ""); result->emojiList = parseJsonAndGetArray<std::string>( [] (const boost::property_tree::ptree& innerData)->std::string { return innerData.get<std::string>(""); - } - , data, "emoji_list"); + }, data, "emoji_list"); result->maskPosition = tryParseJson<MaskPosition>(&TgTypeParser::parseJsonAndGetMaskPosition, data, "mask_position"); result->keywords = parseJsonAndGetArray<std::string>( [] (const boost::property_tree::ptree& innerData)->std::string { return innerData.get<std::string>(""); - } - , data, "keywords"); + }, data, "keywords"); return result; } @@ -3598,6 +3815,7 @@ std::string TgTypeParser::parseInputSticker(const InputSticker::Ptr& object) con std::string result; result += '{'; appendToJson(result, "sticker", object->sticker); + appendToJson(result, "format", object->format); appendToJson(result, "emoji_list", parseArray<std::string>( [] (const std::string& s)->std::string { return s; |