tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
InputSticker.hpp
Go to the documentation of this file.
1#pragma once
2#include <cpr/file.h>
5#include <variant>
6
7namespace tgbotxx {
10 struct InputSticker {
11 InputSticker() = default;
12 explicit InputSticker(const nl::json& json) {
14 }
15
21 std::variant<std::monostate, cpr::File, std::string> sticker{};
22
24 std::string format;
25
27 std::vector<std::string> emojiList;
28
31
34 std::vector<std::string> keywords;
35
38 nl::json toJson() const {
39 nl::json json = nl::json::object();
40 if (not std::holds_alternative<std::monostate>(sticker)) {
41 // sticker variant
42 if (std::holds_alternative<cpr::File>(sticker))
43 json["sticker"] = std::get<cpr::File>(sticker).filepath;
44 else
45 json["sticker"] = std::get<std::string>(sticker);
46 }
51 return json;
52 }
53
55 void fromJson(const nl::json& json) {
56 // sticker variant, we can't get a local file from remote, so it's always a URL or file id std::string.
57 OBJECT_DESERIALIZE_FIELD(json, "sticker", std::get<std::string>(sticker), "", false);
58 OBJECT_DESERIALIZE_FIELD(json, "format", format, "", false);
59 OBJECT_DESERIALIZE_FIELD(json, "emoji_list", emojiList, std::vector<std::string>(), false);
60 OBJECT_DESERIALIZE_FIELD_PTR(json, "mask_position", maskPosition, true);
61 OBJECT_DESERIALIZE_FIELD(json, "keywords", keywords, std::vector<std::string>(), true);
62 }
63 };
64}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:72
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:46
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object describes a sticker to be added to a sticker set. https://core.telegram....
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Ptr< MaskPosition > maskPosition
Optional. Position where the mask should be placed on faces. For “mask” stickers only.
std::string format
Format of the added sticker, must be one of “static” for a .WEBP or .PNG image, “animated” for a ....
std::variant< std::monostate, cpr::File, std::string > sticker
The added sticker.
nl::json toJson() const
Serializes this object to JSON.
InputSticker(const nl::json &json)
std::vector< std::string > emojiList
List of 1-20 emoji associated with the sticker.
std::vector< std::string > keywords
Optional. List of 0-20 search keywords for the sticker with total length of up to 64 characters....