Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
command_handler.hpp
1 #ifndef CPPGRAM_COMMAND_HANDLER_HPP
2 #define CPPGRAM_COMMAND_HANDLER_HPP
3 
4 #include <string>
5 #include <unordered_map>
6 #include <vector>
7 
8 namespace cppgram
9 {
10 // Forward declarations
11 template <class T> class BasicBot;
12 enum EUpdate : short;
13 namespace commands
14 {
15 template <class T> class Command;
16 }
17 namespace types
18 {
19 class Update;
20 }
21 
26 template <class T> class CommandHandler
27 {
28  template <class Z> friend class BasicBot;
29 
30  // static_assert( std::is_base_of<BasicBot<T>, T>::value,
31  //"You can only create a command for bot objects." );
32 
33  public:
38 
43  CommandHandler( T *bot );
44 
50  CommandHandler( T *bot, const CommandHandler &c );
51 
55  CommandHandler( const CommandHandler &c );
56 
65  CommandHandler &operator=( const CommandHandler &c );
66 
73  CommandHandler &operator=( CommandHandler &&c );
74 
79  void addCommand( commands::Command<T> *new_command );
80 
85  void setCommands( const CommandHandler &c );
86 
87  private:
92  void init( T *bot );
93 
100  bool processCommands( const types::Update &update );
101 
106  T *owner;
107 
114  std::unordered_map<const EUpdate, std::vector<commands::Command<T> *>> commands;
115 };
116 }
117 
118 #include "command_handler_impl.hpp"
119 
120 #endif
Handle bot commands.
Definition: command_handler.hpp:26
contains api methods, update handlers and listener.
Definition: basic_bot.hpp:199
Abstract class for bot commands.
Definition: command_handler.hpp:15
main namespace for Cppgram