diff options
author | Andrea Giove <andreagiove@outlook.com> | 2016-04-17 21:10:23 +0200 |
---|---|---|
committer | Andrea Giove <andreagiove@outlook.com> | 2016-04-17 21:10:23 +0200 |
commit | d134bf795a293a641655630bdd8ad44b5b70c1ae (patch) | |
tree | 740a4c04dd2394150148b1c4bb1323bc2ba86d4b /include/tgbot/EventBroadcaster.h | |
parent | 730407e8df5031d19a097be4e3e597f2f3b868fd (diff) |
Added implementation to Inline Keyboard and added a new event broadcaster
Diffstat (limited to 'include/tgbot/EventBroadcaster.h')
-rw-r--r-- | include/tgbot/EventBroadcaster.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/tgbot/EventBroadcaster.h b/include/tgbot/EventBroadcaster.h index d97dbbb..12daef3 100644 --- a/include/tgbot/EventBroadcaster.h +++ b/include/tgbot/EventBroadcaster.h @@ -31,6 +31,7 @@ #include "tgbot/types/Message.h" #include "tgbot/types/InlineQuery.h" #include "tgbot/types/ChosenInlineResult.h" +#include "tgbot/types/CallbackQuery.h" namespace TgBot { @@ -48,6 +49,7 @@ public: typedef std::function<void (const Message::Ptr&)> MessageListener; typedef std::function<void (const InlineQuery::Ptr&)> InlineQueryListener; typedef std::function<void (const ChosenInlineResult::Ptr&)> ChosenInlineResultListener; + typedef std::function<void (const CallbackQuery::Ptr&)> CallbackQueryListener; /** * Registers listener which receives all messages which the bot can ever receive. @@ -82,14 +84,26 @@ public: _onNonCommandMessageListeners.push_back(listener); } + /** + * Registers listener which receives all the inline query. + * @param listener Listener. + */ inline void onInlineQuery(const InlineQueryListener& listener) { _onInlineQueryListeners.push_back(listener); } + /** + * Registers listener which receives all the chosen inline result. + * @param listener Listener. + */ inline void onChosenInlineResult(const ChosenInlineResultListener& listener){ _onChosenInlineResultListeners.push_back(listener); } + inline void onCallbackQuery(const CallbackQueryListener& listener){ + _onCallbackQueryListeners.push_back(listener); + } + private: template<typename ListenerType, typename ObjectType> inline void broadcast(const std::vector<ListenerType>& listeners, const ObjectType& object) const { @@ -130,12 +144,17 @@ private: broadcast<ChosenInlineResultListener, ChosenInlineResult::Ptr>(_onChosenInlineResultListeners, result); } + inline void broadcastCallbackQuery(const CallbackQuery::Ptr& result) const { + broadcast<CallbackQueryListener, CallbackQuery::Ptr>(_onCallbackQueryListeners, result); + } + std::vector<MessageListener> _onAnyMessageListeners; std::map<std::string, MessageListener> _onCommandListeners; std::vector<MessageListener> _onUnknownCommandListeners; std::vector<MessageListener> _onNonCommandMessageListeners; std::vector<InlineQueryListener> _onInlineQueryListeners; std::vector<ChosenInlineResultListener> _onChosenInlineResultListeners; + std::vector<CallbackQueryListener> _onCallbackQueryListeners; }; } |