tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
ReactionType.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
9 struct ReactionType {
10 ReactionType() = default;
11 explicit ReactionType(const nl::json& json) {
12 _fromJson(json);
13 }
14 virtual ~ReactionType() = default;
15
17 std::string type;
18
19
22 virtual nl::json toJson() const {
23 nl::json json = nl::json::object();
24 OBJECT_SERIALIZE_FIELD(json, "type", type);
25 return json;
26 }
27
29 virtual void fromJson(const nl::json& json) {
30 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
31 }
32
33 private:
34 void _fromJson(const nl::json& json) {
35 fromJson(json);
36 }
37 };
38
43 ReactionType::type = "emoji";
44 }
45 explicit ReactionTypeEmoji(const nl::json& json) {
47 ReactionType::type = "emoji";
48 }
49
55 std::string emoji;
56
57
58 nl::json toJson() const override {
59 nl::json json = ReactionType::toJson();
60 OBJECT_SERIALIZE_FIELD(json, "emoji", emoji);
61 return json;
62 }
63 void fromJson(const nl::json& json) override {
65 OBJECT_DESERIALIZE_FIELD(json, "emoji", emoji, "", false);
66 }
67 };
68
73 ReactionType::type = "custom_emoji";
74 }
75 explicit ReactionTypeCustomEmoji(const nl::json& json) {
77 ReactionType::type = "custom_emoji";
78 }
79
81 std::string customEmojiId;
82
83
84 nl::json toJson() const override {
85 nl::json json = ReactionType::toJson();
86 OBJECT_SERIALIZE_FIELD(json, "custom_emoji_id", customEmojiId);
87 return json;
88 }
89 void fromJson(const nl::json& json) override {
91 OBJECT_DESERIALIZE_FIELD(json, "custom_emoji_id", customEmojiId, "", false);
92 }
93 };
94}
#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
The reaction is based on a custom emoji. https://core.telegram.org/bots/api#reactiontypecustomemoji.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
std::string customEmojiId
Custom emoji identifier.
nl::json toJson() const override
Serializes this object to JSON.
ReactionTypeCustomEmoji(const nl::json &json)
The reaction is based on an emoji. https://core.telegram.org/bots/api#reactiontypeemoji.
ReactionTypeEmoji(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
std::string emoji
Reaction emoji. Currently,it can be one of "👍", "👎", "❤", "🔥", "🥰", "👏", "😁", "🤔",...
This object describes the type of a reaction. Currently, it can be one of:
virtual void fromJson(const nl::json &json)
Deserializes this object from JSON.
virtual nl::json toJson() const
Serializes this object to JSON.
std::string type
Type of the reaction, one of “emoji”, "custom_emoji.
virtual ~ReactionType()=default
ReactionType(const nl::json &json)