tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
InlineKeyboardButton.hpp
Go to the documentation of this file.
1#pragma once
7
8namespace tgbotxx {
13 explicit InlineKeyboardButton(const nl::json& json) {
14 fromJson(json);
15 }
16
18 std::string text;
19
23 std::string url;
24
26 std::string callbackData;
27
32
36
40 std::string switchInlineQuery;
41
47
51
56
60 bool pay{};
61
64 nl::json toJson() const {
65 nl::json json = nl::json::object();
66 OBJECT_SERIALIZE_FIELD(json, "text", text);
67 OBJECT_SERIALIZE_FIELD(json, "url", url);
68 OBJECT_SERIALIZE_FIELD(json, "callback_data", callbackData);
69 OBJECT_SERIALIZE_FIELD_PTR(json, "web_app", webApp);
70 OBJECT_SERIALIZE_FIELD_PTR(json, "login_url", loginUrl);
71 OBJECT_SERIALIZE_FIELD(json, "switch_inline_query", switchInlineQuery);
72 OBJECT_SERIALIZE_FIELD(json, "switch_inline_query_current_chat", switchInlineQueryCurrentChat);
73 OBJECT_SERIALIZE_FIELD_PTR(json, "switch_inline_query_chosen_chat", switchInlineQueryChosenChat);
74 OBJECT_SERIALIZE_FIELD_PTR(json, "callback_game", callbackGame);
75 OBJECT_SERIALIZE_FIELD(json, "pay", pay);
76 return json;
77 }
78
80 void fromJson(const nl::json& json) {
81 OBJECT_DESERIALIZE_FIELD(json, "text", text, "", false);
82 OBJECT_DESERIALIZE_FIELD(json, "url", url, "", true);
83 OBJECT_DESERIALIZE_FIELD(json, "callback_data", callbackData, "", true);
84 OBJECT_DESERIALIZE_FIELD_PTR(json, "web_app", webApp, true);
85 OBJECT_DESERIALIZE_FIELD_PTR(json, "login_url", loginUrl, true);
86 OBJECT_DESERIALIZE_FIELD(json, "switch_inline_query", switchInlineQuery, "", true);
87 OBJECT_DESERIALIZE_FIELD(json, "switch_inline_query_current_chat", switchInlineQueryCurrentChat, "", true);
88 OBJECT_DESERIALIZE_FIELD_PTR(json, "switch_inline_query_chosen_chat", switchInlineQueryChosenChat, true);
89 OBJECT_DESERIALIZE_FIELD_PTR(json, "callback_game", callbackGame, true);
90 OBJECT_DESERIALIZE_FIELD(json, "pay", pay, false, true);
91 }
92 };
93}
#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 one button of an inline keyboard. You must use exactly one of the optional fie...
InlineKeyboardButton(const nl::json &json)
std::string url
Optional. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?...
bool pay
Optional. Specify True, to send a Pay button.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Ptr< CallbackGame > callbackGame
Optional. Description of the game that will be launched when the user presses the button.
std::string callbackData
Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
std::string switchInlineQuery
Optional. If set, pressing the button will prompt the user to select one of their chats,...
Ptr< SwitchInlineQueryChosenChat > switchInlineQueryChosenChat
Optional. If set, pressing the button will prompt the user to select one of their chats of the specif...
Ptr< LoginUrl > loginUrl
Optional. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the...
nl::json toJson() const
Serializes this object to JSON.
std::string switchInlineQueryCurrentChat
Optional. If set, pressing the button will insert the bot's username and the specified inline query i...
Ptr< WebAppInfo > webApp
Optional. Description of the Web App that will be launched when the user presses the button....
std::string text
Label text on the button.