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 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'src/Api.cpp') 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)); } -- cgit v1.2.3