tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
CallbackQuery.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <nlohmann/json.hpp>
7
8namespace nl = nlohmann;
9
10namespace tgbotxx {
17 CallbackQuery() = default;
18 explicit CallbackQuery(const nl::json& json) {
19 fromJson(json);
20 }
21
23 std::string id;
24
27
31
33 std::string inlineMessageId;
34
37 std::string chatInstance;
38
41 std::string data;
42
44 std::string gameShortName;
45
48 nl::json toJson() const {
49 nl::json json = nl::json::object();
50 OBJECT_SERIALIZE_FIELD(json, "id", id);
51 OBJECT_SERIALIZE_FIELD_PTR(json, "from", from);
52 OBJECT_SERIALIZE_FIELD_PTR(json, "message", message);
53 OBJECT_SERIALIZE_FIELD(json, "inline_message_id", inlineMessageId);
54 OBJECT_SERIALIZE_FIELD(json, "chat_instance", chatInstance);
55 OBJECT_SERIALIZE_FIELD(json, "data", data);
56 OBJECT_SERIALIZE_FIELD(json, "game_short_name", gameShortName);
57 return json;
58 }
59
61 void fromJson(const nl::json& json) {
62 OBJECT_DESERIALIZE_FIELD(json, "id", id, "", false);
63 OBJECT_DESERIALIZE_FIELD_PTR(json, "from", from, false);
64 OBJECT_DESERIALIZE_FIELD_PTR(json, "message", message, true);
65 OBJECT_DESERIALIZE_FIELD(json, "inline_message_id", inlineMessageId, "", true);
66 OBJECT_DESERIALIZE_FIELD(json, "chat_instance", chatInstance, "", false);
67 OBJECT_DESERIALIZE_FIELD(json, "data", data, "", true);
68 OBJECT_DESERIALIZE_FIELD(json, "game_short_name", gameShortName, "", true);
69 }
70 };
71}
#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: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
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object represents an incoming callback query from a callback button in an inline keyboard....
std::string inlineMessageId
Optional. Identifier of the message sent via the bot in inline mode, that originated the query.
Ptr< User > from
Sender.
std::string gameShortName
Optional. Short name of a Game to be returned, serves as the unique identifier for the game.
std::string data
Optional. Data associated with the callback button.
std::string chatInstance
Global identifier, uniquely corresponding to the chat to which the message with the callback button w...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string id
Unique identifier for this query.
nl::json toJson() const
Serializes this object to JSON.
Ptr< Message > message
Optional. Message with the callback button that originated the query.
CallbackQuery(const nl::json &json)