summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-09-11 15:13:51 +0200
committerllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-09-11 15:13:51 +0200
commit270612dc36df84fe25d7fa5e59ca20647b1e5da9 (patch)
treea9e6b8b9d653baea4e86d366e38e09f9038a4eda
parent0c3b44cead20fb421bdacaba7613348f7573b282 (diff)
Update to API 6.2
-rw-r--r--README.md4
-rw-r--r--include/tgbot/Api.h17
-rw-r--r--include/tgbot/TgTypeParser.h2
-rw-r--r--include/tgbot/types/Chat.h6
-rw-r--r--include/tgbot/types/MessageEntity.h123
-rw-r--r--include/tgbot/types/Sticker.h20
-rw-r--r--include/tgbot/types/StickerSet.h17
-rw-r--r--src/Api.cpp23
-rw-r--r--src/TgTypeParser.cpp113
9 files changed, 244 insertions, 81 deletions
diff --git a/README.md b/README.md
index 8d7b96d..d3aeb69 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,7 @@ Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
## State
-- [x] Bot API 3.0 ~ 4.9
-- [x] Bot API 5.0 ~ 5.7 (Implemented all APIs except 'Run Your Own Bot API Server')
-- [x] Bot API 6.0 ~ 6.1
+- [x] Bot API 3.0 ~ 6.2
## Sample
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h
index a3f4b37..78fb4fa 100644
--- a/include/tgbot/Api.h
+++ b/include/tgbot/Api.h
@@ -1253,6 +1253,15 @@ public:
StickerSet::Ptr getStickerSet(const std::string& name) const;
/**
+ * @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.
+ *
+ * @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 .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times).
* @param userId User identifier of sticker file owner.
* @param pngSticker Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
@@ -1267,14 +1276,14 @@ public:
* You must use exactly one of the fields pngSticker, tgsSticker, or webmSticker.
*
* @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 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 emojis One or more emoji corresponding to the sticker
- * @param containsMasks Optional. Pass True, if a set of mask stickers should be created
* @param maskPosition Optional. A JSON-serialized object for position where the mask should be placed on faces
* @param pngSticker Optional. PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. 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
* @param tgsSticker Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#animated-sticker-requirements for technical requirements
* @param webmSticker Optional. WEBM video with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/stickers#video-sticker-requirements for technical requirements
+ * @param stickerType Optional. Type of stickers in the set, pass “regular” or “mask”. Custom emoji sticker sets can't be created via the Bot API at the moment. By default, a regular sticker set is created.
*
* @return Returns True on success.
*/
@@ -1282,11 +1291,11 @@ public:
const std::string& name,
const std::string& title,
const std::string& emojis,
- bool containsMasks = false,
MaskPosition::Ptr maskPosition = nullptr,
boost::variant<InputFile::Ptr, const std::string&> pngSticker = "",
InputFile::Ptr tgsSticker = nullptr,
- InputFile::Ptr webmSticker = nullptr) const;
+ InputFile::Ptr webmSticker = nullptr,
+ const std::string& stickerType = "") const;
/**
* @brief Use this method to add a new sticker to a set created by the bot.
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index db29f3d..cef1b60 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -727,10 +727,8 @@ private:
}
}
-
void appendToJson(std::string& json, const std::string& varName, const std::string& value) const;
};
-
}
#endif //TGBOT_TGTYPEPARSER_H
diff --git a/include/tgbot/types/Chat.h b/include/tgbot/types/Chat.h
index 931427e..4a3f761 100644
--- a/include/tgbot/types/Chat.h
+++ b/include/tgbot/types/Chat.h
@@ -82,6 +82,12 @@ public:
bool hasPrivateForwards;
/**
+ * @brief Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat.
+ * Returned only in Api::getChat.
+ */
+ bool hasRestrictedVoiceAndVideoMessages;
+
+ /**
* @brief Optional. True, if users need to join the supergroup before they can send messages.
* Returned only in Api::getChat.
*/
diff --git a/include/tgbot/types/MessageEntity.h b/include/tgbot/types/MessageEntity.h
index d1384e7..960e1a7 100644
--- a/include/tgbot/types/MessageEntity.h
+++ b/include/tgbot/types/MessageEntity.h
@@ -1,55 +1,68 @@
-#ifndef TGBOT_MESSAGEENTITY_H
-#define TGBOT_MESSAGEENTITY_H
-
-#include "tgbot/types/User.h"
-
-#include <cstdint>
-#include <memory>
-#include <string>
-
-namespace TgBot {
-
-/**
- * @brief This object represents one special entity in a text message.
- * For example, hashtags, usernames, URLs, etc.
- *
- * @ingroup types
- */
-class MessageEntity {
-public:
- typedef std::shared_ptr<MessageEntity> Ptr;
-
- /**
- * @brief Type of the entity.
- * Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames)
- */
- std::string type;
-
- /**
- * @brief Offset in UTF-16 code units to the start of the entity
- */
- std::int32_t offset;
-
- /**
- * @brief Length of the entity in UTF-16 code units
- */
- std::int32_t length;
-
- /**
- * @brief Optional. For “text_link” only, url that will be opened after user taps on the text
- */
- std::string url;
-
- /**
- * @brief Optional. For “text_mention” only, the mentioned user
- */
- User::Ptr user;
-
- /**
- * @brief Optional. For “pre” only, the programming language of the entity text
- */
- std::string language;
-};
-}
-
-#endif //TGBOT_MESSAGEENTITY_H
+#ifndef TGBOT_MESSAGEENTITY_H
+#define TGBOT_MESSAGEENTITY_H
+
+#include "tgbot/types/User.h"
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+namespace TgBot {
+
+/**
+ * @brief This object represents one special entity in a text message.
+ * For example, hashtags, usernames, URLs, etc.
+ *
+ * @ingroup types
+ */
+class MessageEntity {
+public:
+ typedef std::shared_ptr<MessageEntity> Ptr;
+
+ /**
+ * @brief Enum of possible types.
+ */
+ enum class Type {
+ Mention, Hashtag, Cashtag, BotCommand, Url, Email, PhoneNumber, Bold, Italic, Underline, Strikethrough, Spoiler, Code, Pre, TextLink, TextMention, CustomEmoji
+ };
+
+ /**
+ * @brief Type of the entity.
+ * Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers)
+ */
+ Type type;
+
+ /**
+ * @brief Offset in UTF-16 code units to the start of the entity
+ */
+ std::int32_t offset;
+
+ /**
+ * @brief Length of the entity in UTF-16 code units
+ */
+ std::int32_t length;
+
+ /**
+ * @brief Optional. For “text_link” only, URL that will be opened after user taps on the text
+ */
+ std::string url;
+
+ /**
+ * @brief Optional. For “text_mention” only, the mentioned user
+ */
+ User::Ptr user;
+
+ /**
+ * @brief Optional. For “pre” only, the programming language of the entity text
+ */
+ std::string language;
+
+ /**
+ * @brief Optional. For “custom_emoji” only, unique identifier of the custom emoji.
+ * Use Api::getCustomEmojiStickers to get full information about the sticker
+ */
+ std::string customEmojiId;
+};
+}
+
+#endif //TGBOT_MESSAGEENTITY_H
diff --git a/include/tgbot/types/Sticker.h b/include/tgbot/types/Sticker.h
index 0d14ba4..7ec0140 100644
--- a/include/tgbot/types/Sticker.h
+++ b/include/tgbot/types/Sticker.h
@@ -22,6 +22,13 @@ public:
typedef std::shared_ptr<Sticker> Ptr;
/**
+ * @brief Enum of possible types of a sticker.
+ */
+ enum class Type {
+ Regular, Mask, CustomEmoji
+ };
+
+ /**
* @brief Identifier for this file, which can be used to download or reuse the file
*/
std::string fileId;
@@ -33,6 +40,12 @@ public:
std::string fileUniqueId;
/**
+ * @brief Type of the sticker, currently one of “regular”, “mask”, “custom_emoji”.
+ * The type of the sticker is independent from its format, which is determined by the fields isAnimated and isVideo.
+ */
+ Type type;
+
+ /**
* @brief Sticker width
*/
std::int32_t width;
@@ -68,7 +81,7 @@ public:
std::string setName;
/**
- * @brief Optional. Premium animation for the sticker, if the sticker is premium
+ * @brief Optional. For premium regular stickers, premium animation for the sticker
*/
File::Ptr premiumAnimation;
@@ -78,6 +91,11 @@ public:
MaskPosition::Ptr maskPosition;
/**
+ * @brief Optional. For custom emoji stickers, unique identifier of the custom emoji
+ */
+ std::string customEmojiId;
+
+ /**
* @brief Optional. File size in bytes
*/
std::int32_t fileSize;
diff --git a/include/tgbot/types/StickerSet.h b/include/tgbot/types/StickerSet.h
index 0ef940f..006b1d1 100644
--- a/include/tgbot/types/StickerSet.h
+++ b/include/tgbot/types/StickerSet.h
@@ -20,6 +20,13 @@ public:
typedef std::shared_ptr<StickerSet> Ptr;
/**
+ * @brief Enum of possible types of a sticker.
+ */
+ enum class Type {
+ Regular, Mask, CustomEmoji
+ };
+
+ /**
* @brief Sticker set name
*/
std::string name;
@@ -30,6 +37,11 @@ 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;
@@ -40,11 +52,6 @@ public:
bool isVideo;
/**
- * @brief True, if the sticker set contains masks
- */
- bool containsMasks;
-
- /**
* @brief List of all set stickers
*/
std::vector<Sticker::Ptr> stickers;
diff --git a/src/Api.cpp b/src/Api.cpp
index 8d5ef2d..4107a4e 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -1676,6 +1676,17 @@ StickerSet::Ptr Api::getStickerSet(const string& name) const {
return _tgTypeParser.parseJsonAndGetStickerSet(sendRequest("getStickerSet", args));
}
+std::vector<Sticker::Ptr> Api::getCustomEmojiStickers(const std::vector<std::string>& customEmojiIds) const {
+ vector<HttpReqArg> args;
+ args.reserve(1);
+
+ args.emplace_back("custom_emoji_ids", _tgTypeParser.parseArray<std::string>([] (const std::string& customEmojiId) -> std::string {
+ return "\"" + StringTools::urlEncode(customEmojiId) + "\"";
+ }, customEmojiIds));
+
+ return _tgTypeParser.parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, sendRequest("getCustomEmojiStickers", args));
+}
+
File::Ptr Api::uploadStickerFile(std::int64_t userId, const InputFile::Ptr pngSticker) const {
vector<HttpReqArg> args;
args.reserve(2);
@@ -1688,13 +1699,13 @@ bool Api::createNewStickerSet(std::int64_t userId,
const std::string& name,
const std::string& title,
const std::string& emojis,
- bool containsMasks,
MaskPosition::Ptr maskPosition,
boost::variant<InputFile::Ptr, const std::string&> pngSticker,
InputFile::Ptr tgsSticker,
- InputFile::Ptr webmSticker) const {
+ InputFile::Ptr webmSticker,
+ const std::string& stickerType) const {
vector<HttpReqArg> args;
- args.reserve(9);
+ args.reserve(10);
args.emplace_back("user_id", userId);
args.emplace_back("name", name);
@@ -1711,10 +1722,10 @@ bool Api::createNewStickerSet(std::int64_t userId,
if (webmSticker != nullptr) {
args.emplace_back("webm_sticker", webmSticker->data, true, webmSticker->mimeType, webmSticker->fileName);
}
- args.emplace_back("emojis", emojis);
- if (containsMasks) {
- args.emplace_back("contains_mask", containsMasks);
+ if (!stickerType.empty()) {
+ args.emplace_back("sticker_type", stickerType);
}
+ args.emplace_back("emojis", emojis);
if (maskPosition != nullptr) {
args.emplace_back("mask_position", _tgTypeParser.parseMaskPosition(maskPosition));
}
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index e6a4317..d251da6 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -25,6 +25,7 @@ Chat::Ptr TgTypeParser::parseJsonAndGetChat(const boost::property_tree::ptree& d
result->photo = tryParseJson<ChatPhoto>(&TgTypeParser::parseJsonAndGetChatPhoto, data, "photo");
result->bio = data.get<std::string>("bio", "");
result->hasPrivateForwards = data.get<bool>("has_private_forwards", false);
+ result->hasRestrictedVoiceAndVideoMessages = data.get<bool>("has_restricted_voice_and_video_messages", false);
result->joinToSendMessages = data.get<bool>("join_to_send_messages", false);
result->joinByRequest = data.get<bool>("join_by_request", false);
result->description = data.get<std::string>("description", "");
@@ -64,6 +65,7 @@ std::string TgTypeParser::parseChat(const Chat::Ptr& object) const {
appendToJson(result, "photo", parseChatPhoto(object->photo));
appendToJson(result, "bio", object->bio);
appendToJson(result, "has_private_forwards", object->hasPrivateForwards);
+ appendToJson(result, "has_restricted_voice_and_video_messages", object->hasRestrictedVoiceAndVideoMessages);
appendToJson(result, "join_to_send_messages", object->joinToSendMessages);
appendToJson(result, "join_by_request", object->joinByRequest);
appendToJson(result, "description", object->description);
@@ -122,12 +124,48 @@ std::string TgTypeParser::parseUser(const User::Ptr& object) const {
MessageEntity::Ptr TgTypeParser::parseJsonAndGetMessageEntity(const boost::property_tree::ptree& data) const{
auto result(std::make_shared<MessageEntity>());
- result->type = data.get<std::string>("type", "");
+ std::string type = data.get<std::string>("type", "");
+ if (type == "mention") {
+ result->type = MessageEntity::Type::Mention;
+ } else if (type == "hashtag") {
+ result->type = MessageEntity::Type::Hashtag;
+ } else if (type == "cashtag") {
+ result->type = MessageEntity::Type::Cashtag;
+ } else if (type == "bot_command") {
+ result->type = MessageEntity::Type::BotCommand;
+ } else if (type == "url") {
+ result->type = MessageEntity::Type::Url;
+ } else if (type == "email") {
+ result->type = MessageEntity::Type::Email;
+ } else if (type == "phone_number") {
+ result->type = MessageEntity::Type::PhoneNumber;
+ } else if (type == "bold") {
+ result->type = MessageEntity::Type::Bold;
+ } else if (type == "italic") {
+ result->type = MessageEntity::Type::Italic;
+ } else if (type == "underline") {
+ result->type = MessageEntity::Type::Underline;
+ } else if (type == "strikethrough") {
+ result->type = MessageEntity::Type::Strikethrough;
+ } else if (type == "spoiler") {
+ result->type = MessageEntity::Type::Spoiler;
+ } else if (type == "code") {
+ result->type = MessageEntity::Type::Code;
+ } else if (type == "pre") {
+ result->type = MessageEntity::Type::Pre;
+ } else if (type == "text_link") {
+ result->type = MessageEntity::Type::TextLink;
+ } else if (type == "text_mention") {
+ result->type = MessageEntity::Type::TextMention;
+ } else if (type == "custom_emoji") {
+ result->type = MessageEntity::Type::CustomEmoji;
+ }
result->offset = data.get<std::int32_t>("offset", 0);
result->length = data.get<std::int32_t>("length", 0);
result->url = data.get<std::string>("url", "");
result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user");
result->language = data.get<std::string>("language", "");
+ result->customEmojiId = data.get<std::string>("custom_emoji_id", "");
return result;
}
@@ -137,12 +175,47 @@ std::string TgTypeParser::parseMessageEntity(const MessageEntity::Ptr& object) c
}
std::string result;
result += '{';
- appendToJson(result, "type", object->type);
+ if (object->type == MessageEntity::Type::Mention) {
+ appendToJson(result, "type", "mention");
+ } else if (object->type == MessageEntity::Type::Hashtag) {
+ appendToJson(result, "type", "hashtag");
+ } else if (object->type == MessageEntity::Type::Cashtag) {
+ appendToJson(result, "type", "cashtag");
+ } else if (object->type == MessageEntity::Type::BotCommand) {
+ appendToJson(result, "type", "bot_command");
+ } else if (object->type == MessageEntity::Type::Url) {
+ appendToJson(result, "type", "url");
+ } else if (object->type == MessageEntity::Type::Email) {
+ appendToJson(result, "type", "email");
+ } else if (object->type == MessageEntity::Type::PhoneNumber) {
+ appendToJson(result, "type", "phone_number");
+ } else if (object->type == MessageEntity::Type::Bold) {
+ appendToJson(result, "type", "bold");
+ } else if (object->type == MessageEntity::Type::Italic) {
+ appendToJson(result, "type", "italic");
+ } else if (object->type == MessageEntity::Type::Underline) {
+ appendToJson(result, "type", "underline");
+ } else if (object->type == MessageEntity::Type::Strikethrough) {
+ appendToJson(result, "type", "strikethrough");
+ } else if (object->type == MessageEntity::Type::Spoiler) {
+ appendToJson(result, "type", "spoiler");
+ } else if (object->type == MessageEntity::Type::Code) {
+ appendToJson(result, "type", "code");
+ } else if (object->type == MessageEntity::Type::Pre) {
+ appendToJson(result, "type", "pre");
+ } else if (object->type == MessageEntity::Type::TextLink) {
+ appendToJson(result, "type", "text_link");
+ } else if (object->type == MessageEntity::Type::TextMention) {
+ appendToJson(result, "type", "text_mention");
+ } else if (object->type == MessageEntity::Type::CustomEmoji) {
+ appendToJson(result, "type", "custom_emoji");
+ }
appendToJson(result, "offset", object->offset);
appendToJson(result, "length", object->length);
appendToJson(result, "url", object->url);
appendToJson(result, "user", parseUser(object->user));
- appendToJson(result, "language", object->url);
+ appendToJson(result, "language", object->language);
+ appendToJson(result, "custom_emoji_id", object->customEmojiId);
removeLastComma(result);
result += '}';
return result;
@@ -393,6 +466,14 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const boost::property_tree::pt
auto result(std::make_shared<Sticker>());
result->fileId = data.get<std::string>("file_id", "");
result->fileUniqueId = data.get<std::string>("file_unique_id", "");
+ std::string type = data.get<std::string>("type", "");
+ if (type == "regular") {
+ result->type = Sticker::Type::Regular;
+ } else if (type == "mask") {
+ result->type = Sticker::Type::Mask;
+ } else if (type == "custom_emoji") {
+ result->type = Sticker::Type::CustomEmoji;
+ }
result->width = data.get<std::int32_t>("width", 0);
result->height = data.get<std::int32_t>("height", 0);
result->isAnimated = data.get<bool>("is_animated", false);
@@ -402,6 +483,7 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const boost::property_tree::pt
result->setName = data.get<std::string>("set_name", "");
result->premiumAnimation = tryParseJson<File>(&TgTypeParser::parseJsonAndGetFile, data, "premium_animation");
result->maskPosition = tryParseJson<MaskPosition>(&TgTypeParser::parseJsonAndGetMaskPosition, data, "mask_position");
+ result->customEmojiId = data.get<std::string>("custom_emoji_id", "");
result->fileSize = data.get<std::int32_t>("file_size", 0);
return result;
}
@@ -414,6 +496,13 @@ std::string TgTypeParser::parseSticker(const Sticker::Ptr& object) const {
result += '{';
appendToJson(result, "file_id", object->fileId);
appendToJson(result, "file_unique_id", object->fileUniqueId);
+ if (object->type == Sticker::Type::Regular) {
+ appendToJson(result, "type", "regular");
+ } else if (object->type == Sticker::Type::Mask) {
+ appendToJson(result, "type", "mask");
+ } else if (object->type == Sticker::Type::CustomEmoji) {
+ appendToJson(result, "type", "custom_emoji");
+ }
appendToJson(result, "width", object->width);
appendToJson(result, "height", object->height);
appendToJson(result, "is_animated", object->isAnimated);
@@ -423,6 +512,7 @@ std::string TgTypeParser::parseSticker(const Sticker::Ptr& object) const {
appendToJson(result, "set_name", object->setName);
appendToJson(result, "premium_animation", parseFile(object->premiumAnimation));
appendToJson(result, "mask_position", parseMaskPosition(object->maskPosition));
+ appendToJson(result, "custom_emoji_id", object->customEmojiId);
appendToJson(result, "file_size", object->fileSize);
removeLastComma(result);
result += '}';
@@ -433,9 +523,16 @@ 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;
+ }
result->isAnimated = data.get<bool>("is_animated", false);
result->isVideo = data.get<bool>("is_video", false);
- result->containsMasks = data.get<bool>("contains_masks", false);
result->stickers = parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "stickers");
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
return result;
@@ -449,9 +546,15 @@ 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");
+ }
appendToJson(result, "is_animated", object->isAnimated);
appendToJson(result, "is_video", object->isVideo);
- appendToJson(result, "contains_masks", object->containsMasks);
appendToJson(result, "stickers", parseArray(&TgTypeParser::parseSticker, object->stickers));
appendToJson(result, "thumb", parsePhotoSize(object->thumb));
removeLastComma(result);