From f3aba5cb3cca0f99f2a39d61acd960a836295593 Mon Sep 17 00:00:00 2001 From: kukin-konstantin Date: Tue, 10 Jan 2017 17:07:34 +0300 Subject: fix ReplyKeyboardMarkup --- src/TgTypeParser.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/TgTypeParser.cpp') 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& item : data.find("keyboard")->second) { - vector array; - for (const pair& 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(&TgTypeParser::parseJsonAndGetKeyboardButton, item.second)); } - result->resizeKeyboard = data.get("resize_keyboard"); - result->oneTimeKeyboard = data.get("one_time_keyboard"); - result->selective = data.get("selective"); + result->resizeKeyboard = data.get("resize_keyboard", false); + result->oneTimeKeyboard = data.get("one_time_keyboard", false); + result->selective = data.get("selective", false); return result; } @@ -462,12 +458,11 @@ std::string TgTypeParser::parseReplyKeyboardMarkup(const ReplyKeyboardMarkup::Pt string result; result += '{'; result += "\"keyboard\":["; - for (vector& item : object->keyboard) { + for (vector& 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 += "],"; -- cgit v1.2.3