tgbotxx 1.1.6.9
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) {
13 fromJson(json);
14 }
15
21 std::variant<cpr::File, std::string> sticker{""};
22
24 std::vector<std::string> emojiList;
25
28
31 std::vector<std::string> keywords;
32
35 nl::json toJson() const {
36 nl::json json = nl::json::object();
37 // sticker variant
38 if (auto idx = sticker.index(); idx == 0)
39 json["sticker"] = std::get<cpr::File>(sticker).filepath;
40 else if (idx == 1)
41 json["sticker"] = std::get<std::string>(sticker);
42 OBJECT_SERIALIZE_FIELD(json, "emoji_list", emojiList);
43 OBJECT_SERIALIZE_FIELD_PTR(json, "mask_position", maskPosition);
44 OBJECT_SERIALIZE_FIELD(json, "keywords", keywords);
45 return json;
46 }
47
49 void fromJson(const nl::json& json) {
50 // sticker variant, we can't get a local file from remote, so it's always a URL or file id std::string.
51 OBJECT_DESERIALIZE_FIELD(json, "sticker", std::get<std::string>(sticker), "", false);
52 OBJECT_DESERIALIZE_FIELD(json, "emoji_list", emojiList, std::vector<std::string>(), false);
53 OBJECT_DESERIALIZE_FIELD_PTR(json, "mask_position", maskPosition, true);
54 OBJECT_DESERIALIZE_FIELD(json, "keywords", keywords, std::vector<std::string>(), true);
55 }
56 };
57}
#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:70
#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:44
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.
std::variant< cpr::File, std::string > sticker
The added sticker.
Ptr< MaskPosition > maskPosition
Optional. Position where the mask should be placed on faces. For “mask” stickers only.
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....