From d134bf795a293a641655630bdd8ad44b5b70c1ae Mon Sep 17 00:00:00 2001 From: Andrea Giove Date: Sun, 17 Apr 2016 21:10:23 +0200 Subject: Added implementation to Inline Keyboard and added a new event broadcaster --- include/tgbot/EventBroadcaster.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/tgbot/EventBroadcaster.h') 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 MessageListener; typedef std::function InlineQueryListener; typedef std::function ChosenInlineResultListener; + typedef std::function 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 inline void broadcast(const std::vector& listeners, const ObjectType& object) const { @@ -130,12 +144,17 @@ private: broadcast(_onChosenInlineResultListeners, result); } + inline void broadcastCallbackQuery(const CallbackQuery::Ptr& result) const { + broadcast(_onCallbackQueryListeners, result); + } + std::vector _onAnyMessageListeners; std::map _onCommandListeners; std::vector _onUnknownCommandListeners; std::vector _onNonCommandMessageListeners; std::vector _onInlineQueryListeners; std::vector _onChosenInlineResultListeners; + std::vector _onCallbackQueryListeners; }; } -- cgit v1.2.3