tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
BackgroundType.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
15 BackgroundType() = default;
16 explicit BackgroundType(const nl::json& json) {
18 }
19 virtual ~BackgroundType() = default;
20
22 std::string type;
23
24 virtual nl::json toJson() const {
25 nl::json json = nl::json::object();
27 return json;
28 }
29
30 virtual void fromJson(const nl::json& json) {
31 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
32 }
33 };
34
39 type = "fill";
40 }
41 explicit BackgroundTypeFill(const nl::json& json) {
43 }
44
47
49 std::int32_t darkThemeDimming{};
50
51 nl::json toJson() const override {
52 nl::json json = BackgroundType::toJson();
54 OBJECT_SERIALIZE_FIELD(json, "dark_theme_dimming", darkThemeDimming);
55 return json;
56 }
57
58 void fromJson(const nl::json& json) override {
60 OBJECT_DESERIALIZE_FIELD_PTR(json, "fill", fill, false);
61 OBJECT_DESERIALIZE_FIELD(json, "dark_theme_dimming", darkThemeDimming, 0, false);
62 }
63 };
64
69 type = "wallpaper";
70 }
74
77
79 std::int32_t darkThemeDimming{};
80
82 bool isBlurred{};
83
85 bool isMoving{};
86
87 nl::json toJson() const override {
88 nl::json json = BackgroundType::toJson();
90 OBJECT_SERIALIZE_FIELD(json, "dark_theme_dimming", darkThemeDimming);
93 return json;
94 }
95
96 void fromJson(const nl::json& json) override {
98 OBJECT_DESERIALIZE_FIELD_PTR(json, "document", document, false);
99 OBJECT_DESERIALIZE_FIELD(json, "dark_theme_dimming", darkThemeDimming, 0, false);
100 OBJECT_DESERIALIZE_FIELD(json, "is_blurred", isBlurred, false, true);
101 OBJECT_DESERIALIZE_FIELD(json, "is_moving", isMoving, false, true);
102 }
103 };
104
109 type = "pattern";
110 }
111 explicit BackgroundTypePattern(const nl::json& json) {
113 }
114
117
120
122 std::int32_t intensity{};
123
126
128 bool isMoving{};
129
130 nl::json toJson() const override {
131 nl::json json = BackgroundType::toJson();
135 OBJECT_SERIALIZE_FIELD(json, "is_inverted", isInverted);
136 OBJECT_SERIALIZE_FIELD(json, "is_moving", isMoving);
137 return json;
138 }
139
140 void fromJson(const nl::json& json) override {
142 OBJECT_DESERIALIZE_FIELD_PTR(json, "document", document, false);
143 OBJECT_DESERIALIZE_FIELD_PTR(json, "fill", fill, false);
144 OBJECT_DESERIALIZE_FIELD(json, "intensity", intensity, 0, false);
145 OBJECT_DESERIALIZE_FIELD(json, "is_inverted", isInverted, false, true);
146 OBJECT_DESERIALIZE_FIELD(json, "is_moving", isMoving, false, true);
147 }
148 };
149
154 type = "chat_theme";
155 }
159
161 std::string themeName;
162
163 nl::json toJson() const override {
164 nl::json json = BackgroundType::toJson();
165 OBJECT_SERIALIZE_FIELD(json, "theme_name", themeName);
166 return json;
167 }
168
169 void fromJson(const nl::json& json) override {
171 OBJECT_DESERIALIZE_FIELD(json, "theme_name", themeName, "", false);
172 }
173 };
174
175}
#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
The background is taken directly from a built-in chat theme. https://core.telegram....
void fromJson(const nl::json &json) override
nl::json toJson() const override
std::string themeName
Name of the chat theme, which is usually an emoji.
BackgroundTypeChatTheme(const nl::json &json)
The background is automatically filled based on the selected colors. https://core....
Ptr< BackgroundFill > fill
The background fill.
std::int32_t darkThemeDimming
Dimming of the background in dark themes, as a percentage; 0-100.
void fromJson(const nl::json &json) override
nl::json toJson() const override
BackgroundTypeFill(const nl::json &json)
This object describes the type of a background. It can be one of:
virtual void fromJson(const nl::json &json)
virtual nl::json toJson() const
BackgroundType(const nl::json &json)
virtual ~BackgroundType()=default
std::string type
Type of the background, one of "fill", "wallpaper", "pattern", "chat_theme".
The background is a PNG or TGV pattern combined with a fill. https://core.telegram....
Ptr< Document > document
Document with the pattern.
bool isMoving
Optional. True, if the background moves slightly when the device is tilted.
void fromJson(const nl::json &json) override
Ptr< BackgroundFill > fill
The background fill that is combined with the pattern.
nl::json toJson() const override
BackgroundTypePattern(const nl::json &json)
std::int32_t intensity
Intensity of the pattern when it is shown above the filled background; 0-100.
bool isInverted
Optional. True, if the background fill must be applied only to the pattern itself....
The background is a wallpaper in JPEG format. https://core.telegram.org/bots/api#backgroundtypewallpa...
bool isMoving
Optional. True, if the background moves slightly when the device is tilted.
void fromJson(const nl::json &json) override
std::int32_t darkThemeDimming
Dimming of the background in dark themes, as a percentage; 0-100.
nl::json toJson() const override
bool isBlurred
Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with r...
Ptr< Document > document
Document with the wallpaper.
BackgroundTypeWallpaper(const nl::json &json)