tgbotxx 1.2.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) {
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();
25 return json;
26 }
27
29 virtual void fromJson(const nl::json& json) {
30 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
31 }
32 };
33
38 type = "emoji";
39 }
40 explicit ReactionTypeEmoji(const nl::json& json) {
42 }
43
49 std::string emoji;
50
51
52 [[nodiscard]] nl::json toJson() const override {
53 nl::json json = ReactionType::toJson();
55 return json;
56 }
57 void fromJson(const nl::json& json) override {
59 OBJECT_DESERIALIZE_FIELD(json, "emoji", emoji, "", false);
60 }
61 };
62
67 type = "custom_emoji";
68 }
72
74 std::string customEmojiId;
75
76
77 [[nodiscard]] nl::json toJson() const override {
78 nl::json json = ReactionType::toJson();
79 OBJECT_SERIALIZE_FIELD(json, "custom_emoji_id", customEmojiId);
80 return json;
81 }
82 void fromJson(const nl::json& json) override {
84 OBJECT_DESERIALIZE_FIELD(json, "custom_emoji_id", customEmojiId, "", false);
85 }
86 };
87}
#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 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)