Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
command.hpp
1 #ifndef CPPGRAM_COMMAND_HPP
2 #define CPPGRAM_COMMAND_HPP
3 
4 #include <functional>
5 #include <string>
6 
7 #include "cppgram/basic_bot.hpp"
8 #include "cppgram/types/enums.hpp"
9 
10 namespace cppgram
11 {
12 namespace types
13 {
14 class Update;
15 }
16 
17 namespace commands
18 {
25 template <class T> class Command
26 {
27  // static_assert( std::is_base_of<BasicBot<T>, T>::value,
28  //"You can only create a command for bot objects." );
29 
30  public:
32  const EUpdate type;
33 
34  Command()
35  : type( EUpdate::eMessage )
36  {
37  }
38 
47  virtual void callClosure( T &, const types::Update & ) = 0;
48 
54  virtual bool isValid( const types::Update & ) = 0;
55 
56  protected:
62  void setInlineQueryId( std::string &inline_query_id, T &bot )
63  {
64  bot.inline_query_id = inline_query_id;
65  }
66 
72  void setCallbackQueryId( std::string &callback_query_id, T &bot )
73  {
74  bot.callback_query_id = callback_query_id;
75  }
76 };
77 }
78 }
79 
80 #endif
const EUpdate type
type of the update for which the command will be triggered.
Definition: command.hpp:32
Abstract class for bot commands.
Definition: command_handler.hpp:15
void setInlineQueryId(std::string &inline_query_id, T &bot)
Set the inline query id of the bot for using AnswerInlineQuery.
Definition: command.hpp:62
main namespace for Cppgram
void setCallbackQueryId(std::string &callback_query_id, T &bot)
Set the callback query id the current update.
Definition: command.hpp:72