From 707bcac4dd0fffd961dbb325e7d11752ee55392d Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Fri, 9 Sep 2022 17:33:11 +0200 Subject: Update to API 5.7 --- src/Api.cpp | 57 +++++++++++++++++++++++++++------------------------- src/TgTypeParser.cpp | 4 ++++ 2 files changed, 34 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/Api.cpp b/src/Api.cpp index bb63721..9538485 100644 --- a/src/Api.cpp +++ b/src/Api.cpp @@ -1634,27 +1634,28 @@ bool Api::createNewStickerSet(std::int64_t userId, const std::string& emojis, bool containsMasks, MaskPosition::Ptr maskPosition, - boost::variant pngSticker, - boost::variant tgsSticker) const { + boost::variant pngSticker, + InputFile::Ptr tgsSticker, + InputFile::Ptr webmSticker) const { vector args; - args.reserve(8); + args.reserve(9); args.emplace_back("user_id", userId); args.emplace_back("name", name); args.emplace_back("title", title); - args.emplace_back("emojis", emojis); - if (pngSticker.which() == 0 /* InputFile::Ptr */) { + if (pngSticker.which() == 0) { // InputFile::Ptr auto file = boost::get(pngSticker); args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("png_sticker", boost::get(pngSticker)); + } else { // const std::string& + args.emplace_back("png_sticker", boost::get(pngSticker)); } - if (tgsSticker.which() == 0 /* InputFile::Ptr */) { - auto file = boost::get(tgsSticker); - args.emplace_back("tgs_sticker", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("tgs_sticker", boost::get(tgsSticker)); + if (tgsSticker != nullptr) { + args.emplace_back("tgs_sticker", tgsSticker->data, true, tgsSticker->mimeType, tgsSticker->fileName); + } + 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); } @@ -1666,29 +1667,31 @@ bool Api::createNewStickerSet(std::int64_t userId, } bool Api::addStickerToSet(std::int64_t userId, - const std::string& name, - const std::string& emojis, - MaskPosition::Ptr maskPosition, - boost::variant pngSticker, - boost::variant tgsSticker) const { + const std::string& name, + const std::string& emojis, + MaskPosition::Ptr maskPosition, + boost::variant pngSticker, + InputFile::Ptr tgsSticker, + InputFile::Ptr webmSticker) const { vector args; - args.reserve(6); + args.reserve(7); args.emplace_back("user_id", userId); args.emplace_back("name", name); - args.emplace_back("emojis", emojis); - if (pngSticker.which() == 0 /* InputFile::Ptr */) { + + if (pngSticker.which() == 0) { // InputFile::Ptr auto file = boost::get(pngSticker); args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("png_sticker", boost::get(pngSticker)); + } else { // const std::string& + args.emplace_back("png_sticker", boost::get(pngSticker)); } - if (tgsSticker.which() == 0 /* InputFile::Ptr */) { - auto file = boost::get(tgsSticker); - args.emplace_back("tgs_sticker", file->data, true, file->mimeType, file->fileName); - } else /* std::string */ { - args.emplace_back("tgs_sticker", boost::get(tgsSticker)); + if (tgsSticker != nullptr) { + args.emplace_back("tgs_sticker", tgsSticker->data, true, tgsSticker->mimeType, tgsSticker->fileName); } + if (webmSticker != nullptr) { + args.emplace_back("webm_sticker", webmSticker->data, true, webmSticker->mimeType, webmSticker->fileName); + } + 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 85b44e8..daf80c8 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -386,6 +386,7 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const boost::property_tree::pt result->width = data.get("width", 0); result->height = data.get("height", 0); result->isAnimated = data.get("is_animated", false); + result->isVideo = data.get("is_video", false); result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); result->emoji = data.get("emoji", ""); result->setName = data.get("set_name", ""); @@ -405,6 +406,7 @@ std::string TgTypeParser::parseSticker(const Sticker::Ptr& object) const { appendToJson(result, "width", object->width); appendToJson(result, "height", object->height); appendToJson(result, "is_animated", object->isAnimated); + appendToJson(result, "is_video", object->isVideo); appendToJson(result, "thumb", parsePhotoSize(object->thumb)); appendToJson(result, "emoji", object->emoji); appendToJson(result, "set_name", object->setName); @@ -420,6 +422,7 @@ StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const boost::property_tr result->name = data.get("name", ""); result->title = data.get("title", ""); result->isAnimated = data.get("is_animated", false); + result->isVideo = data.get("is_video", false); result->containsMasks = data.get("contains_masks", false); result->stickers = parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetSticker, data, "stickers"); result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); @@ -435,6 +438,7 @@ std::string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const { appendToJson(result, "name", object->name); appendToJson(result, "title", object->title); 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)); -- cgit v1.2.3