summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Morozenkov <reo7sp@users.noreply.github.com>2017-02-02 16:36:56 +0300
committerGitHub <noreply@github.com>2017-02-02 16:36:56 +0300
commit1c7d4c17062644d28f485b0ff6cbc213e975ac29 (patch)
treefbf0ee9ac758736e023abf41c60015d62239cceb
parentd5144494b6dd30b537664a2888fcda05da0d5531 (diff)
parentc57d27df23aa59058a170701d912645d3ce60810 (diff)
Merge pull request #38 from ymuv/master
Add initializer_list for register same commands.
-rw-r--r--include/tgbot/EventBroadcaster.h12
-rw-r--r--src/TgTypeParser.cpp2
2 files changed, 13 insertions, 1 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.
*/
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index 5fa19dd..eeaba5e 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -421,7 +421,7 @@ string TgTypeParser::parseUserProfilePhotos(const UserProfilePhotos::Ptr& object
File::Ptr TgTypeParser::parseJsonAndGetFile(const boost::property_tree::ptree& data) const {
File::Ptr result(new File);
result->fileId = data.get<string>("file_id");
- result->filePath = data.get<int32_t>("file_size", 0);
+ result->fileSize = data.get<int32_t>("file_size", 0);
result->filePath = data.get<string>("file_path", "");
return result;
}