From c57d27df23aa59058a170701d912645d3ce60810 Mon Sep 17 00:00:00 2001 From: ymuv Date: Thu, 2 Feb 2017 00:07:43 +0200 Subject: Add initializer_list for register same commands. Fix file size mistake. --- include/tgbot/EventBroadcaster.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/tgbot/EventBroadcaster.h b/include/tgbot/EventBroadcaster.h index 12daef3..ebcf72a 100644 --- a/include/tgbot/EventBroadcaster.h +++ b/include/tgbot/EventBroadcaster.h @@ -68,6 +68,18 @@ public: _onCommandListeners[commandName] = listener; } + /** + * Registers listener which receives all messages with commands (messages with leading '/' char). + * @param commandsList Commands names which listener can handle. + * @param listener Listener. + */ + inline void onCommand(const std::initializer_list& commandsList, const MessageListener& listener) { + for (const auto& command : commandsList) + { + _onCommandListeners[command] = listener; + } + } + /** * Registers listener which receives all messages with commands (messages with leading '/' char) which haven't been handled by other listeners. * @param listener Listener. -- cgit v1.2.3