tgbotxx 1.1.9.2
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 std::vector<Ptr<Sticker>> stickers;
26
29
32 nl::json toJson() const {
33 nl::json json = nl::json::object();
34 OBJECT_SERIALIZE_FIELD(json, "name", name);
35 OBJECT_SERIALIZE_FIELD(json, "title", title);
38 OBJECT_SERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail);
39 return json;
40 }
41
43 void fromJson(const nl::json& json) {
44 OBJECT_DESERIALIZE_FIELD(json, "name", name, "", false);
45 OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
46 stickerType = Sticker::StringToType(json["sticker_type"]).value(); // enum
47 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "stickers", stickers, false);
48 OBJECT_DESERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail, true);
49 }
50 };
51}
#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: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
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:89
#define OBJECT_SERIALIZE_FIELD_ENUM(json, enum_name, json_field, field)
Definition Object.hpp:42
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
static std::optional< Type > StringToType(const std::string &str) noexcept
Converts string to an enum Type.
Definition Sticker.hpp:37
Type
Enum of possible types of Type.
Definition Sticker.hpp:24
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.
Sticker::Type stickerType
Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
StickerSet(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string name
Sticker set name.
nl::json toJson() const
Serializes this object to JSON.
std::vector< Ptr< Sticker > > stickers
List of all set stickers.