tgbotxx  1.1.6.9
Telegram Bot C++ Library
tgbotxx::KeyboardButton Struct Reference

This object represents one button of the reply keyboard. For simple text buttons, String can be used instead of this object to specify the button text. The optional fields web_app, request_user, request_chat, request_contact, request_location, and request_poll are mutually exclusive. https://core.telegram.org/bots/api#keyboardbutton. More...

#include <KeyboardButton.hpp>

Public Member Functions

 KeyboardButton ()=default
 
 KeyboardButton (const nl::json &json)
 
nl::json toJson () const
 Serializes this object to JSON. More...
 
void fromJson (const nl::json &json)
 Deserializes this object from JSON. More...
 

Public Attributes

std::string text
 Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed. More...
 
Ptr< KeyboardButtonRequestUserrequestUser
 Optional. If specified, pressing the button will open a list of suitable users. Tapping on any user will send their identifier to the bot in a “user_shared” service message. More...
 
Ptr< KeyboardButtonRequestChatrequestChat
 Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. More...
 
bool requestContact {}
 Optional. If True, the user's phone number will be sent as a contact when the button is pressed. More...
 
bool requestLocation {}
 Optional. If True, the user's current location will be sent when the button is pressed. More...
 
Ptr< KeyboardButtonPollTyperequestPoll
 Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. More...
 
Ptr< WebAppInfowebApp
 Optional. If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. More...
 

Detailed Description

This object represents one button of the reply keyboard. For simple text buttons, String can be used instead of this object to specify the button text. The optional fields web_app, request_user, request_chat, request_contact, request_location, and request_poll are mutually exclusive. https://core.telegram.org/bots/api#keyboardbutton.

Note
request_contact and request_location options will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.
request_poll option will only work in Telegram versions released after 23 January, 2020. Older clients will display unsupported message.
web_app option will only work in Telegram versions released after 16 April, 2022. Older clients will display unsupported message.
request_user and request_chat options will only work in Telegram versions released after 3 February, 2023. Older clients will display unsupported message.

Definition at line 17 of file KeyboardButton.hpp.

Constructor & Destructor Documentation

◆ KeyboardButton() [1/2]

tgbotxx::KeyboardButton::KeyboardButton ( )
default

◆ KeyboardButton() [2/2]

tgbotxx::KeyboardButton::KeyboardButton ( const nl::json &  json)
inlineexplicit

Definition at line 19 of file KeyboardButton.hpp.

Member Function Documentation

◆ fromJson()

void tgbotxx::KeyboardButton::fromJson ( const nl::json &  json)
inline

Deserializes this object from JSON.

Definition at line 69 of file KeyboardButton.hpp.

◆ toJson()

nl::json tgbotxx::KeyboardButton::toJson ( ) const
inline

Serializes this object to JSON.

Returns
JSON representation of this object

Definition at line 56 of file KeyboardButton.hpp.

Member Data Documentation

◆ requestChat

Ptr<KeyboardButtonRequestChat> tgbotxx::KeyboardButton::requestChat

Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a “chat_shared” service message.

Note
Available in private chats only.

Definition at line 34 of file KeyboardButton.hpp.

◆ requestContact

bool tgbotxx::KeyboardButton::requestContact {}

Optional. If True, the user's phone number will be sent as a contact when the button is pressed.

Note
Available in private chats only.

Definition at line 38 of file KeyboardButton.hpp.

◆ requestLocation

bool tgbotxx::KeyboardButton::requestLocation {}

Optional. If True, the user's current location will be sent when the button is pressed.

Note
Available in private chats only.

Definition at line 42 of file KeyboardButton.hpp.

◆ requestPoll

Ptr<KeyboardButtonPollType> tgbotxx::KeyboardButton::requestPoll

Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed.

Note
Available in private chats only.

Definition at line 46 of file KeyboardButton.hpp.

◆ requestUser

Ptr<KeyboardButtonRequestUser> tgbotxx::KeyboardButton::requestUser

Optional. If specified, pressing the button will open a list of suitable users. Tapping on any user will send their identifier to the bot in a “user_shared” service message.

Note
Available in private chats only.

Definition at line 29 of file KeyboardButton.hpp.

◆ text

std::string tgbotxx::KeyboardButton::text

Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed.

Definition at line 24 of file KeyboardButton.hpp.

◆ webApp

Ptr<WebAppInfo> tgbotxx::KeyboardButton::webApp

Optional. If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message.

Note
Available in private chats only.

Definition at line 51 of file KeyboardButton.hpp.


The documentation for this struct was generated from the following file: