Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
callback_query.hpp
1 #ifndef CPPGRAM_CALLBACK_QUERY_HPP
2 #define CPPGRAM_CALLBACK_QUERY_HPP
3 
4 #include <string>
5 
6 #include <json/json.h>
7 
8 #include "message.hpp"
9 
10 namespace cppgram
11 {
12 namespace types
13 {
22 {
25  public:
27  std::string id;
28 
31 
35  std::experimental::optional<Message> message;
36 
39  std::experimental::optional<std::string> inline_message_id;
40 
44  std::string chat_instance;
45 
48  std::experimental::optional<std::string> data,
49 
55 
56  CallbackQuery( Json::Value &json_callback_query )
57  : id( json_callback_query["id"].asString() )
58  , from( json_callback_query["from"] )
59  , chat_instance( json_callback_query["chat_instance"].asString() )
60  {
61  if ( !json_callback_query["message"].isNull() )
62  {
63  message.emplace( Message( json_callback_query["message"] ) );
64  }
65 
66  if ( !json_callback_query["inline_message_id"].isNull() )
67  {
68  inline_message_id.emplace( json_callback_query["inline_message_id"].asString() );
69  }
70 
71  if ( !json_callback_query["data"].isNull() )
72  {
73  data.emplace( json_callback_query["data"].asString() );
74  }
75 
76  if ( !json_callback_query["game_short_name"].isNull() )
77  {
78  game_short_name.emplace( json_callback_query["game_short_name"].asString() );
79  }
80  }
81 };
82 }
83 }
84 
85 #endif
std::experimental::optional< std::string > inline_message_id
Optional. Identifier of the message sent via the bot in inline mode, that originated the query ...
Definition: callback_query.hpp:39
A message send by user.
Definition: message.hpp:36
Data from an inline keyboard button pressed.
Definition: callback_query.hpp:21
std::string chat_instance
Identifier, uniquely corresponding to the chat to which the message with the callback button was sent...
Definition: callback_query.hpp:44
std::experimental::optional< Message > message
Optional. Message with the callback button that originated the query.
Definition: callback_query.hpp:35
std::experimental::optional< std::string > data
Optional. Data associated with the callback button.
Definition: callback_query.hpp:48
main namespace for Cppgram
std::string id
Unique identifier for this query.
Definition: callback_query.hpp:27
std::experimental::optional< std::string > game_short_name
Optional. Short name of a Game to be returned, serves as the unique identifier for the game ...
Definition: callback_query.hpp:48
User from
Sender.
Definition: callback_query.hpp:30
User object.
Definition: user.hpp:20