From 94f8360629909e93e82417085db8381791c95c7b Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 27 May 2018 22:12:56 +0900 Subject: Bot API 3.2 update --- src/TgTypeParser.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'src/TgTypeParser.cpp') 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("height"); result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); result->emoji = data.get("emoji", ""); + result->setName = data.get("set_name", ""); + result->maskPosition = tryParseJson(&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()); + result->name = data.get("name", ""); + result->title = data.get("title", ""); + result->containsMasks = data.get("contains_masks", false); + result->stickers = parseJsonAndGetArray(&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()); + result->point = data.get("point", ""); + result->xShift = data.get("x_shift", 0); + result->yShift = data.get("y_shift", 0); + result->scale = data.get("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