tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
MessageReactionUpdated.hpp
Go to the documentation of this file.
1#pragma once
6
7namespace tgbotxx {
12 explicit MessageReactionUpdated(const nl::json& json) {
13 fromJson(json);
14 }
15
18
20 std::int32_t messageId{};
21
24
27
29 std::time_t date{};
30
32 std::vector<Ptr<ReactionType>> oldReaction;
33
35 std::vector<Ptr<ReactionType>> newReaction;
36
39 nl::json toJson() const {
40 nl::json json = nl::json::object();
41 OBJECT_SERIALIZE_FIELD_PTR(json, "chat", chat);
42 OBJECT_SERIALIZE_FIELD(json, "message_id", messageId);
43 OBJECT_SERIALIZE_FIELD_PTR(json, "user", user);
44 OBJECT_SERIALIZE_FIELD_PTR(json, "actor_chat", actorChat);
45 OBJECT_SERIALIZE_FIELD(json, "date", date);
46 OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "old_reaction", oldReaction);
47 OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "new_reaction", newReaction);
48 return json;
49 }
50
52 void fromJson(const nl::json& json) {
53 OBJECT_DESERIALIZE_FIELD_PTR(json, "chat", chat, false);
54 OBJECT_DESERIALIZE_FIELD(json, "message_id", messageId, 0, false);
55 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, true);
56 OBJECT_DESERIALIZE_FIELD_PTR(json, "actor_chat", actorChat, true);
57 OBJECT_DESERIALIZE_FIELD(json, "date", date, 0, false);
58 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "old_reaction", oldReaction, false);
59 OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "new_reaction", newReaction, false);
60 }
61 };
62}
#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:70
#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
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:87
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object represents a change of a reaction on a message performed by a user. https://core....
Ptr< Chat > chat
The chat containing the message the user reacted to.
std::vector< Ptr< ReactionType > > newReaction
New list of reaction types that have been set by the user.
std::vector< Ptr< ReactionType > > oldReaction
Previous list of reaction types that were set by the user.
std::time_t date
Date of the change in Unix time.
nl::json toJson() const
Serializes this object to JSON.
std::int32_t messageId
Unique identifier of the message inside the chat.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Ptr< Chat > actorChat
Optional. The chat on behalf of which the reaction was changed, if the user is anonymous.
Ptr< User > user
Optional. The user that changed the reaction, if the user isn't anonymous.