tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
StickerSet.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
9 struct StickerSet {
10 StickerSet() = default;
11 explicit StickerSet(const nl::json& json) {
12 fromJson(json);
13 }
14
16 std::string name;
17
19 std::string title;
20
23
25 bool isAnimated{};
26
28 bool isVideo{};
29
31 std::vector<Ptr<Sticker>> stickers;
32
35
38 nl::json toJson() const {
39 nl::json json = nl::json::object();
40 OBJECT_SERIALIZE_FIELD(json, "name", name);
41 OBJECT_SERIALIZE_FIELD(json, "title", title);
42 json["type"] = Sticker::Type2Str[static_cast<std::size_t>(type)]; // enum
43 OBJECT_SERIALIZE_FIELD(json, "is_animated", isAnimated);
44 OBJECT_SERIALIZE_FIELD(json, "is_video", isVideo);
46 OBJECT_SERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail);
47 return json;
48 }
49
51 void fromJson(const nl::json& json) {
52 OBJECT_DESERIALIZE_FIELD(json, "name", name, "", false);
53 OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
54 type = Sticker::Str2Type(json["type"]); // enum
55 OBJECT_DESERIALIZE_FIELD(json, "is_animated", isAnimated, false, false);
56 OBJECT_DESERIALIZE_FIELD(json, "is_video", isVideo, false, false);
57 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "stickers", stickers, false);
58 OBJECT_DESERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail, true);
59 }
60 };
61}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:27
#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
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:87
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
static constexpr const char * Type2Str[]
Definition Sticker.hpp:29
Type
Enum of possible types of a Sticker.
Definition Sticker.hpp:24
static constexpr Type Str2Type(const std::string &str)
Definition Sticker.hpp:30
This object represents a sticker set. https://core.telegram.org/bots/api#stickerset.
Definition StickerSet.hpp:9
Ptr< PhotoSize > thumbnail
Optional. Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format.
std::string title
Sticker set title.
StickerSet(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
bool isVideo
True, if the sticker set contains video stickers
std::string name
Sticker set name.
Sticker::Type type
Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
bool isAnimated
True, if the sticker set contains animated stickers
nl::json toJson() const
Serializes this object to JSON.
std::vector< Ptr< Sticker > > stickers
List of all set stickers.