tgbotxx 1.1.6.9
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
16 std::string type;
17
18
21 virtual nl::json toJson() const {
22 nl::json json = nl::json::object();
23 OBJECT_SERIALIZE_FIELD(json, "type", type);
24 return json;
25 }
26
28 virtual void fromJson(const nl::json& json) {
29 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
30 }
31
32 private:
33 void _fromJson(const nl::json& json) {
34 fromJson(json);
35 }
36 };
37
42 ReactionType::type = "emoji";
43 }
44 explicit ReactionTypeEmoji(const nl::json& json) {
46 ReactionType::type = "emoji";
47 }
48
54 std::string emoji;
55
56
57 nl::json toJson() const override {
58 nl::json json = ReactionTypeEmoji::toJson();
59 OBJECT_SERIALIZE_FIELD(json, "emoji", emoji);
60 return json;
61 }
62 void fromJson(const nl::json& json) override {
64 OBJECT_DESERIALIZE_FIELD(json, "emoji", emoji, "", false);
65 }
66 };
67
72 ReactionType::type = "custom_emoji";
73 }
74 explicit ReactionTypeCustomEmoji(const nl::json& json) {
76 ReactionType::type = "custom_emoji";
77 }
78
80 std::string customEmojiId;
81
82
83 nl::json toJson() const override {
84 nl::json json = ReactionType::toJson();
85 OBJECT_SERIALIZE_FIELD(json, "custom_emoji_id", customEmojiId);
86 return json;
87 }
88 void fromJson(const nl::json& json) override {
90 OBJECT_DESERIALIZE_FIELD(json, "custom_emoji_id", customEmojiId, "", false);
91 }
92 };
93}
#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
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.
ReactionType(const nl::json &json)