Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
keyboard_button.hpp
1 #ifndef CPPGRAM_KEYBOARD_BUTTON_HPP
2 #define CPPGRAM_KEYBOARD_BUTTON_HPP
3 
4 #include <string>
5 
6 #include <json/json.h>
7 
8 #include "enums.hpp"
9 
10 namespace cppgram
11 {
12 namespace types
13 {
22 {
25  public:
27  std::string text,
28 
30  data;
31 
34 
42  KeyboardButton( const std::string &text, const std::string &data, const EButton &button_type )
43  : text( text )
44  , data( data )
45  , button_type( button_type )
46  {
47  }
48 
54  KeyboardButton( Json::Value &json_button )
55  : text( json_button["text"].asString() )
56  {
57  if ( !json_button["callback_data"].isNull() )
58  {
59  data = json_button["callback_data"].asString();
60  button_type = EButton::CallbackData;
61  }
62  else if ( !json_button["url"].isNull() )
63  {
64  data = json_button["url"].asString();
65  button_type = EButton::URL;
66  }
67  else if ( !json_button["switch_inline_query"].isNull() )
68  {
69  data = json_button["switch_inline_query"].asString();
70  button_type = EButton::SwitchInlineQuery;
71  }
72  }
73 };
74 }
75 }
76 
77 #endif
Definition: enums.hpp:86
std::string data
Data of the json_button (depends on type)
Definition: keyboard_button.hpp:27
KeyboardButton(Json::Value &json_button)
Constructor by JSON.
Definition: keyboard_button.hpp:54
Definition: enums.hpp:89
KeyboardButton(const std::string &text, const std::string &data, const EButton &button_type)
Constructor by parameters.
Definition: keyboard_button.hpp:42
EButton button_type
Type of the json_button.
Definition: keyboard_button.hpp:33
EButton
Type of the inlineKeyboardButton to add in the reply markup.
Definition: enums.hpp:80
main namespace for Cppgram
std::string text
Label text of the json_button.
Definition: keyboard_button.hpp:27
Definition: enums.hpp:83
Class for creating Inline keyboard json_button.
Definition: keyboard_button.hpp:21