diff options
author | JellyBrick <shlee1503@naver.com> | 2018-05-27 22:12:56 +0900 |
---|---|---|
committer | JellyBrick <shlee1503@naver.com> | 2018-05-27 22:12:56 +0900 |
commit | 94f8360629909e93e82417085db8381791c95c7b (patch) | |
tree | 8816bd39559e498bd147ec1ce24bba186c70a8ba /src/TgTypeParser.cpp | |
parent | c81f7d9d7a4fe9dc3b48b92fad633bd5c44b8e74 (diff) |
Bot API 3.2 update
Diffstat (limited to 'src/TgTypeParser.cpp')
-rw-r--r-- | src/TgTypeParser.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index fafe94f..ff2ffe7 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -287,6 +287,8 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const ptree& data) const { result->height = data.get<int32_t>("height"); result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); result->emoji = data.get("emoji", ""); + result->setName = data.get("set_name", ""); + result->maskPosition = tryParseJson<MaskPosition>(&TgTypeParser::parseJsonAndGetMaskPosition, data, "mask_position"); result->fileSize = data.get("file_size", 0); return result; } @@ -308,6 +310,54 @@ string TgTypeParser::parseSticker(const Sticker::Ptr& object) const { return result; } +StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const ptree& data) const { + auto result(make_shared<StickerSet>()); + result->name = data.get("name", ""); + result->title = data.get("title", ""); + result->containsMasks = data.get<bool>("contains_masks", false); + result->stickers = parseJsonAndGetArray<Sticker>(&TgTypeParser::parseJsonAndGetSticker, data, "stickers"); + return result; +} + +string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const { + if (!object) { + return ""; + } + string result; + result += '{'; + appendToJson(result, "name", object->name); + appendToJson(result, "title", object->title); + appendToJson(result, "contains_masks", object->containsMasks); + appendToJson(result, "thumb", parseArray(&TgTypeParser::parseJsonAndGetSticker, object->stickers)); + result.erase(result.length() - 1); + result += '}'; + return result; +} + +MaskPosition::Ptr TgTypeParser::parseJsonAndGetMaskPosition(const ptree& data) const { + auto result(make_shared<MaskPosition>()); + result->point = data.get("point", ""); + result->xShift = data.get<float>("x_shift", 0); + result->yShift = data.get<float>("y_shift", 0); + result->scale = data.get<float>("scale", 0); + return result; +} + +string TgTypeParser::parseMaskPosition(const MaskPosition::Ptr& object) const { + if (!object) { + return ""; + } + string result; + result += '{'; + appendToJson(result, "point", object->point); + appendToJson(result, "x_shift", object->xShift); + appendToJson(result, "y_shift", object->yShift); + appendToJson(result, "scale", object->scale); + result.erase(result.length() - 1); + result += '}'; + return result; +} + Video::Ptr TgTypeParser::parseJsonAndGetVideo(const ptree& data) const { auto result(make_shared<Video>()); result->fileId = data.get<string>("file_id"); @@ -621,6 +671,19 @@ ChatPhoto::Ptr TgTypeParser::parseJsonAndGetChatPhoto(const boost::property_tree return result; } +std::string TgTypeParser::parseChatPhoto(const ChatPhoto::Ptr& object) const { + if (!object) { + return ""; + } + string result; + result += '{'; + appendToJson(result, "small_file_id", object->smallFileId); + appendToJson(result, "big_file_id", object->bigFileId); + result.erase(result.length() - 1); + result += '}'; + return result; +} + ResponseParameters::Ptr TgTypeParser::parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const { auto result(make_shared<ResponseParameters>()); result->migrateToChatId = data.get<int32_t>("migrate_to_chat_id", 0); |