1 #ifndef TGBOT_REGISTER_CB_H 2 #define TGBOT_REGISTER_CB_H 4 #include "methods/api.h" 6 #include "utils/str_match.h" 17 template<
typename __TypeUpdate>
19 std::function<void(const __TypeUpdate, const methods::Api &)>;
28 using ChosenInlineResultCallback =
35 using __Command_Tuple =
36 std::tuple<
const char *,
37 std::function<bool(const std::string &, const char *)>,
40 const std::vector<std::string>)> >;
44 MessageCallback messageCallback;
45 InlineQueryCallback inlineQueryCallback;
46 ChosenInlineResultCallback chosenInlineResultCallback;
47 CallbackQueryCallback callbackQueryCallback;
48 ShippingQueryCallback shippingQueryCallback;
49 PreCheckoutQueryCallback preCheckoutQueryCallback;
50 MessageCallback editedMessageCallback;
51 MessageCallback editedChannelPostCallback;
52 MessageCallback channelPostCallback;
53 std::vector<__Command_Tuple> commandCallback;
65 inline void callback(
bool (&matcherCallback)(
const std::string &,
69 const std::vector<std::string>),
70 const char *matchWord,
const char sep =
' ') {
71 commandCallback.emplace_back(matchWord, matcherCallback, sep,
callback);
84 inline void callback(
bool (&matcherCallback)(
const std::string &,
const char *),
86 const std::vector<std::string>)>
88 const char *matchWord,
const char sep =
' ') {
89 commandCallback.emplace_back(matchWord, matcherCallback, sep,
callback);
101 inline void callback(std::function<
bool(
const std::string &,
102 const char *)> matcherCallback,
105 const std::vector<std::string>),
106 const char *matchWord,
const char sep =
' ') {
108 commandCallback.emplace_back(matchWord, matcherCallback, sep,
callback);
121 inline void callback(std::function<
bool(
const std::string &,
122 const char *)> matcherCallback,
124 const std::vector<std::string>)>
callback,
125 const char *matchWord,
const char sep =
' ') {
127 commandCallback.emplace_back(matchWord, matcherCallback, sep,
callback);
168 chosenInlineResultCallback =
callback;
176 chosenInlineResultCallback =
callback;
219 preCheckoutQueryCallback =
callback;
227 preCheckoutQueryCallback =
callback;
238 const types::UpdateType &which) {
239 if (which == types::UpdateType::EDITED_MESSAGE)
241 else if (which == types::UpdateType::EDITED_CHANNEL_POST)
242 editedChannelPostCallback =
callback;
243 else if (which == types::UpdateType::CHANNEL_POST)
254 const types::UpdateType updateType) {
255 switch (updateType) {
256 case types::UpdateType::EDITED_MESSAGE:
259 case types::UpdateType::EDITED_CHANNEL_POST:
260 editedChannelPostCallback =
callback;
262 case types::UpdateType::CHANNEL_POST:
void callback(CallbackQueryCallback callback)
Callback query update callback.
Definition: register_callback.h:192
void callback(void(&callback)(const types::Message, const methods::Api &), const types::UpdateType &which)
Multiple-options update callback.
Definition: register_callback.h:236
void callback(ShippingQueryCallback callback)
Shipping query update callback.
Definition: register_callback.h:209
registers and holds callbacks for each type of update
Definition: register_callback.h:24
void callback(MessageCallback callback)
Message update callback.
Definition: register_callback.h:143
void callback(bool(&matcherCallback)(const std::string &, const char *), std::function< void(const types::Message, const methods::Api &, const std::vector< std::string >)> callback, const char *matchWord, const char sep= ' ')
std::function wrapper callback overload, associate with command (ability to use lambdas ...
Definition: register_callback.h:84
void callback(bool(&matcherCallback)(const std::string &, const char *), void(&callback)(const types::Message, const methods::Api &, const std::vector< std::string >), const char *matchWord, const char sep= ' ')
C-style function pointer callback overload, associate with command.
Definition: register_callback.h:65
void callback(ChosenInlineResultCallback callback)
Definition: register_callback.h:171
void callback(void(&callback)(const types::Message, const methods::Api &))
Message update callback.
Definition: register_callback.h:134
Main tgbot namespace.
Definition: bot.h:13
void callback(MessageCallback callback, const types::UpdateType updateType)
Multiple-options update callback.
Definition: register_callback.h:253
void callback(PreCheckoutQueryCallback callback)
Pre checkout query update callback.
Definition: register_callback.h:226
void callback(void(&callback)(const types::ShippingQuery, const methods::Api &))
Shipping query update callback.
Definition: register_callback.h:200
void callback(std::function< bool(const std::string &, const char *)> matcherCallback, void(&callback)(const types::Message, const methods::Api &, const std::vector< std::string >), const char *matchWord, const char sep= ' ')
C-style function pointer callback overload, associate with command.
Definition: register_callback.h:101
void callback(void(&callback)(const types::ChosenInlineResult, const methods::Api &))
Chosen inline result update callback.
Definition: register_callback.h:166
void callback(void(&callback)(const types::CallbackQuery, const methods::Api &))
Callback query update callback.
Definition: register_callback.h:183
void callback(void(&callback)(const types::InlineQuery, const methods::Api &))
Inline query update callback.
Definition: register_callback.h:149
void callback(std::function< bool(const std::string &, const char *)> matcherCallback, std::function< void(const types::Message, const methods::Api &, const std::vector< std::string >)> callback, const char *matchWord, const char sep= ' ')
std::function wrapper callback overload, associate with command (ability to use lambdas ...
Definition: register_callback.h:121
std::function< void(const __TypeUpdate, const methods::Api &)> __T_UpdateCallback
refer to RegisterCallback::callback() function (overloads)
Definition: register_callback.h:19
void callback(InlineQueryCallback callback)
Inline query update callback.
Definition: register_callback.h:158
Contains Telegram bot API methods.
Definition: api.h:19
void callback(void(&callback)(const types::PreCheckoutQuery, const methods::Api &))
Pre checkout query update callback.
Definition: register_callback.h:217