tgbotxx 1.1.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
InlineKeyboardButton.hpp
Go to the documentation of this file.
1#pragma once
8
9namespace tgbotxx {
15 explicit InlineKeyboardButton(const nl::json& json) {
16 fromJson(json);
17 }
18
20 std::string text;
21
25 std::string url;
26
28 std::string callbackData;
29
34
38
43 std::string switchInlineQuery;
44
50
55
58
62
65 bool pay{};
66
69 nl::json toJson() const {
70 nl::json json = nl::json::object();
71 OBJECT_SERIALIZE_FIELD(json, "text", text);
72 OBJECT_SERIALIZE_FIELD(json, "url", url);
73 OBJECT_SERIALIZE_FIELD(json, "callback_data", callbackData);
74 OBJECT_SERIALIZE_FIELD_PTR(json, "web_app", webApp);
75 OBJECT_SERIALIZE_FIELD_PTR(json, "login_url", loginUrl);
76 OBJECT_SERIALIZE_FIELD(json, "switch_inline_query", switchInlineQuery);
77 OBJECT_SERIALIZE_FIELD(json, "switch_inline_query_current_chat", switchInlineQueryCurrentChat);
78 OBJECT_SERIALIZE_FIELD_PTR(json, "switch_inline_query_chosen_chat", switchInlineQueryChosenChat);
79 OBJECT_SERIALIZE_FIELD_PTR(json, "copy_text", copyText);
80 OBJECT_SERIALIZE_FIELD_PTR(json, "callback_game", callbackGame);
81 OBJECT_SERIALIZE_FIELD(json, "pay", pay);
82 return json;
83 }
84
86 void fromJson(const nl::json& json) {
87 OBJECT_DESERIALIZE_FIELD(json, "text", text, "", false);
88 OBJECT_DESERIALIZE_FIELD(json, "url", url, "", true);
89 OBJECT_DESERIALIZE_FIELD(json, "callback_data", callbackData, "", true);
90 OBJECT_DESERIALIZE_FIELD_PTR(json, "web_app", webApp, true);
91 OBJECT_DESERIALIZE_FIELD_PTR(json, "login_url", loginUrl, true);
92 OBJECT_DESERIALIZE_FIELD(json, "switch_inline_query", switchInlineQuery, "", true);
93 OBJECT_DESERIALIZE_FIELD(json, "switch_inline_query_current_chat", switchInlineQueryCurrentChat, "", true);
94 OBJECT_DESERIALIZE_FIELD_PTR(json, "switch_inline_query_chosen_chat", switchInlineQueryChosenChat, true);
95 OBJECT_DESERIALIZE_FIELD_PTR(json, "copy_text", copyText, true);
96 OBJECT_DESERIALIZE_FIELD_PTR(json, "callback_game", callbackGame, true);
97 OBJECT_DESERIALIZE_FIELD(json, "pay", pay, false, true);
98 }
99 };
100
101}
#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:72
#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
This object represents one button of an inline keyboard. Exactly one of the optional fields must be u...
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. Substrings “⭐” and “XTR” in the buttons's text will be ...
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 the button is pressed,...
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.
Ptr< CopyTextButton > copyText
Optional. Description of the button that copies the specified text to the clipboard.