summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Api.cpp57
-rw-r--r--src/TgTypeParser.cpp4
2 files changed, 34 insertions, 27 deletions
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<InputFile::Ptr, std::string> pngSticker,
- boost::variant<InputFile::Ptr, std::string> tgsSticker) const {
+ boost::variant<InputFile::Ptr, const std::string&> pngSticker,
+ InputFile::Ptr tgsSticker,
+ InputFile::Ptr webmSticker) const {
vector<HttpReqArg> 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<InputFile::Ptr>(pngSticker);
args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("png_sticker", boost::get<std::string>(pngSticker));
+ } else { // const std::string&
+ args.emplace_back("png_sticker", boost::get<const std::string&>(pngSticker));
}
- if (tgsSticker.which() == 0 /* InputFile::Ptr */) {
- auto file = boost::get<InputFile::Ptr>(tgsSticker);
- args.emplace_back("tgs_sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("tgs_sticker", boost::get<std::string>(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<InputFile::Ptr, std::string> pngSticker,
- boost::variant<InputFile::Ptr, std::string> tgsSticker) const {
+ const std::string& name,
+ const std::string& emojis,
+ MaskPosition::Ptr maskPosition,
+ boost::variant<InputFile::Ptr, const std::string&> pngSticker,
+ InputFile::Ptr tgsSticker,
+ InputFile::Ptr webmSticker) const {
vector<HttpReqArg> 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<InputFile::Ptr>(pngSticker);
args.emplace_back("png_sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("png_sticker", boost::get<std::string>(pngSticker));
+ } else { // const std::string&
+ args.emplace_back("png_sticker", boost::get<const std::string&>(pngSticker));
}
- if (tgsSticker.which() == 0 /* InputFile::Ptr */) {
- auto file = boost::get<InputFile::Ptr>(tgsSticker);
- args.emplace_back("tgs_sticker", file->data, true, file->mimeType, file->fileName);
- } else /* std::string */ {
- args.emplace_back("tgs_sticker", boost::get<std::string>(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<std::int32_t>("width", 0);
result->height = data.get<std::int32_t>("height", 0);
result->isAnimated = data.get<bool>("is_animated", false);
+ result->isVideo = data.get<bool>("is_video", false);
result->thumb = tryParseJson<PhotoSize>(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb");
result->emoji = data.get<std::string>("emoji", "");
result->setName = data.get<std::string>("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<std::string>("name", "");
result->title = data.get<std::string>("title", "");
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");
@@ -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));