summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tgbot/TgTypeParser.h1
-rw-r--r--src/Api.cpp4
-rw-r--r--src/TgTypeParser.cpp22
3 files changed, 22 insertions, 5 deletions
diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h
index aea4f8b..a24184a 100644
--- a/include/tgbot/TgTypeParser.h
+++ b/include/tgbot/TgTypeParser.h
@@ -118,6 +118,7 @@ public:
User::Ptr parseJsonAndGetUser(const boost::property_tree::ptree& data) const;
std::string parseUser(const User::Ptr& object) const;
MessageEntity::Ptr parseJsonAndGetMessageEntity(const boost::property_tree::ptree& data) const;
+ std::string parseMessageEntity(const MessageEntity::Ptr& object) const;
Message::Ptr parseJsonAndGetMessage(const boost::property_tree::ptree& data) const;
std::string parseMessage(const Message::Ptr& object) const;
PhotoSize::Ptr parseJsonAndGetPhotoSize(const boost::property_tree::ptree& data) const;
diff --git a/src/Api.cpp b/src/Api.cpp
index dfb5dcc..11349e9 100644
--- a/src/Api.cpp
+++ b/src/Api.cpp
@@ -993,7 +993,7 @@ bool Api::unpinChatMessage(int64_t chatId) const {
Message::Ptr Api::setGameScore(int32_t userId, int32_t score, bool force, bool disableEditMessage, int64_t chatId, int32_t messageId, const std::string& inlineMessageId) const {
vector<HttpReqArg> args;
- args.push_back(HttpReqArg("user_id", user_id));
+ args.push_back(HttpReqArg("user_id", userId));
args.push_back(HttpReqArg("score", score));
if (force) {
args.push_back(HttpReqArg("force", force));
@@ -1002,7 +1002,7 @@ Message::Ptr Api::setGameScore(int32_t userId, int32_t score, bool force, bool d
args.push_back(HttpReqArg("disable_edit_message", disableEditMessage));
}
if (chatId){
- args.push_back(HttpReqArg("chat_id", chat_id));
+ args.push_back(HttpReqArg("chat_id", chatId));
}
if (messageId){
args.push_back(HttpReqArg("message_id", messageId));
diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp
index 20ed9a2..ca7547d 100644
--- a/src/TgTypeParser.cpp
+++ b/src/TgTypeParser.cpp
@@ -121,7 +121,23 @@ MessageEntity::Ptr TgTypeParser::parseJsonAndGetMessageEntity(const ptree& data)
result->url = data.get<string>("url", "");
result->user = tryParseJson<User>(&TgTypeParser::parseJsonAndGetUser, data, "user");
return result;
-}
+}
+
+string TgTypeParser::parseMessageEntity(const MessageEntity::Ptr& object) const {
+ if (!object) {
+ return "";
+ }
+ string result;
+ result += '{';
+ appendToJson(result, "type", object->type);
+ appendToJson(result, "offset", object->offset);
+ appendToJson(result, "length", object->length);
+ appendToJson(result, "url", object->url);
+ appendToJson(result, "user", parseUser(object->user));
+ result.erase(result.length() - 1);
+ result += '}';
+ return result;
+}
Message::Ptr TgTypeParser::parseJsonAndGetMessage(const ptree& data) const {
auto result(make_shared<Message>());
@@ -439,9 +455,9 @@ string TgTypeParser::parseGame(const Game::Ptr& object) const {
result += '{';
appendToJson(result, "title", object->title);
appendToJson(result, "description", object->description);
- appendToJson(result, "photo", parseArray<PhotoSize>(&TgTypeParser::parsePhotoSize, object->photo));
+ appendToJson(result, "photo", parseArray(&TgTypeParser::parsePhotoSize, object->photo));
appendToJson(result, "text", object->text);
- appendToJson(result, "text_entities", parseArray<MessageEntity>(&TgTypeParser::parseJsonAndGetMessageEntity, object->textEntities));
+ appendToJson(result, "text_entities", parseArray(&TgTypeParser::parseMessageEntity, object->textEntities));
appendToJson(result, "animation", parseAnimation(object->animation));
result.erase(result.length() - 1);
result += '}';