Cppgram
1.0.0
Easy and modern C++14 Telegram Bot API wrapper
|
An helper class to create inline keyboard. More...
#include <keyboard.hpp>
Public Member Functions | |
Keyboard () | |
Default constructor for the function. More... | |
bool | addButton (const std::string &text, const std::string &data, const EButton &button_type) |
Add a button by passing directly the data. More... | |
bool | addButton (const types::KeyboardButton &new_button) |
Add a button by passing a KeyboardButton. More... | |
bool | addButton (const std::vector< types::KeyboardButton > &new_buttons) |
Add button by passing a vector of KeyboardButton. More... | |
unsigned short | changeRow () |
The button will be added to the next row from now on. More... | |
void | clearKeyboard () |
Clear the inline keyboard of the object. | |
void | get (std::string &reply_markup, const bool &clear_keyboard=true) |
Get keyboard as string. More... | |
Private Attributes | |
Json::FastWriter | writer |
Get keyboard as Json. More... | |
An helper class to create inline keyboard.
Create inline keyboard, get the reply markup with getKeyboard and pass this to api methods. Each method will check for errors (like missing text in button that will result in an API error). The buttons will be added in the same row in sequence; when the (Telegram) limit of 8 buttons in a row is reached, the buttons will be added to the next row. To change row manually call changeRow().
Keyboard | ( | ) |
Default constructor for the function.
bool addButton | ( | const std::string & | text, |
const std::string & | data, | ||
const EButton & | button_type | ||
) |
Add a button by passing directly the data.
text | Text label |
data | Data of the button (depends on the type) |
buttonType | Type of the button |
bool addButton | ( | const types::KeyboardButton & | new_button | ) |
Add a button by passing a KeyboardButton.
newButton | The button to add |
bool addButton | ( | const std::vector< types::KeyboardButton > & | new_buttons | ) |
Add button by passing a vector of KeyboardButton.
newButtons |
unsigned short changeRow | ( | ) |
The button will be added to the next row from now on.
void get | ( | std::string & | reply_markup, |
const bool & | clear_keyboard = true |
||
) |
Get keyboard as string.
Pass a string that will be filled with the keyboard
reply_markup | The string that will be filled |
clearKeyboard | Clear keyboard after passing it |
|
private |
Get keyboard as Json.
This method has to be used in answerInlineQuery, cause it accepts only non JSON-serialized value