diff options
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 += "],"; |