diff options
author | Oleg Morozenkov <reo7sp@users.noreply.github.com> | 2017-02-02 16:36:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-02 16:36:56 +0300 |
commit | 1c7d4c17062644d28f485b0ff6cbc213e975ac29 (patch) | |
tree | fbf0ee9ac758736e023abf41c60015d62239cceb /include/tgbot | |
parent | d5144494b6dd30b537664a2888fcda05da0d5531 (diff) | |
parent | c57d27df23aa59058a170701d912645d3ce60810 (diff) |
Merge pull request #38 from ymuv/master
Add initializer_list for register same commands.
Diffstat (limited to 'include/tgbot')
-rw-r--r-- | include/tgbot/EventBroadcaster.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/tgbot/EventBroadcaster.h b/include/tgbot/EventBroadcaster.h index 4378c10..2bb2d2a 100644 --- a/include/tgbot/EventBroadcaster.h +++ b/include/tgbot/EventBroadcaster.h @@ -69,6 +69,18 @@ public: } /** + * 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<std::string>& 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. */ |