diff options
author | kukin-konstantin <kukin.konstantin@gmail.com> | 2017-01-10 17:07:34 +0300 |
---|---|---|
committer | kukin-konstantin <kukin.konstantin@gmail.com> | 2017-01-10 17:07:34 +0300 |
commit | f3aba5cb3cca0f99f2a39d61acd960a836295593 (patch) | |
tree | e265993fc4382aadb87eb1ecfd3baa48e4dfa72e /src/TgTypeParser.cpp | |
parent | 429dd74b583e0ac52d50142be493cba532ca017d (diff) |
fix ReplyKeyboardMarkup
Diffstat (limited to 'src/TgTypeParser.cpp')
-rw-r--r-- | src/TgTypeParser.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 45124e2..0952d75 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -442,16 +442,12 @@ string TgTypeParser::parseFile(const File::Ptr& object) const { ReplyKeyboardMarkup::Ptr TgTypeParser::parseJsonAndGetReplyKeyboardMarkup(const boost::property_tree::ptree& data) const { ReplyKeyboardMarkup::Ptr result(new ReplyKeyboardMarkup); - for (const pair<const string, ptree>& item : data.find("keyboard")->second) { - vector<string> array; - for (const pair<const string, ptree>& innerItem : item.second) { - array.push_back(innerItem.second.data()); - } - result->keyboard.push_back(array); + for (const boost::property_tree::ptree::value_type& item : data.find("keyboard")->second){ + result->keyboard.push_back(parseJsonAndGetArray<KeyboardButton>(&TgTypeParser::parseJsonAndGetKeyboardButton, item.second)); } - result->resizeKeyboard = data.get<bool>("resize_keyboard"); - result->oneTimeKeyboard = data.get<bool>("one_time_keyboard"); - result->selective = data.get<bool>("selective"); + result->resizeKeyboard = data.get<bool>("resize_keyboard", false); + result->oneTimeKeyboard = data.get<bool>("one_time_keyboard", false); + result->selective = data.get<bool>("selective", false); return result; } @@ -462,12 +458,11 @@ std::string TgTypeParser::parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Pt string result; result += '{'; result += "\"keyboard\":["; - for (vector<string>& item : object->keyboard) { + for (vector<KeyboardButton::Ptr>& item : object->keyboard) { result += '['; - for (string& innerItem : item) { - result += '"'; - result += innerItem; - result += "\","; + for (KeyboardButton::Ptr& innerItem : item) { + result += parseKeyboardButton(innerItem); + result += ','; } result.erase(result.length() - 1); result += "],"; |