From 5a72b4b1fc89d9b6033f929d9bf4f6e30d7f9698 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 4 Sep 2022 20:59:46 +0200 Subject: Update to API 5.4 --- src/TgTypeParser.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/TgTypeParser.cpp') diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 330278a..ed75e21 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -997,6 +997,7 @@ Update::Ptr TgTypeParser::parseJsonAndGetUpdate(const boost::property_tree::ptre result->pollAnswer = tryParseJson(&TgTypeParser::parseJsonAndGetPollAnswer, data, "poll_answer"); result->myChatMember = tryParseJson(&TgTypeParser::parseJsonAndGetChatMemberUpdated, data, "my_chat_member"); result->chatMember = tryParseJson(&TgTypeParser::parseJsonAndGetChatMemberUpdated, data, "chat_member"); + result->chatJoinRequest = tryParseJson(&TgTypeParser::parseJsonAndGetChatJoinRequest, data, "chat_join_request"); return result; } @@ -1020,6 +1021,7 @@ std::string TgTypeParser::parseUpdate(const Update::Ptr& object) const { appendToJson(result, "poll_answer", parsePollAnswer(object->pollAnswer)); appendToJson(result, "my_chat_member", parseChatMemberUpdated(object->myChatMember)); appendToJson(result, "chat_member", parseChatMemberUpdated(object->chatMember)); + appendToJson(result, "chat_join_request", parseChatJoinRequest(object->chatJoinRequest)); removeLastComma(result); result += '}'; return result; @@ -1598,6 +1600,32 @@ std::string TgTypeParser::parseChatMemberUpdated(const ChatMemberUpdated::Ptr& o return result; } +ChatJoinRequest::Ptr TgTypeParser::parseJsonAndGetChatJoinRequest(const boost::property_tree::ptree& data) const { + auto result(std::make_shared()); + result->chat = tryParseJson(&TgTypeParser::parseJsonAndGetChat, data, "chat"); + result->from = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "from"); + result->date = data.get("date", 0); + result->bio = data.get("bio", ""); + result->inviteLink = tryParseJson(&TgTypeParser::parseJsonAndGetChatInviteLink, data, "invite_link"); + return result; +} + +std::string TgTypeParser::parseChatJoinRequest(const ChatJoinRequest::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "chat", parseChat(object->chat)); + appendToJson(result, "from", parseUser(object->from)); + appendToJson(result, "date", object->date); + appendToJson(result, "bio", object->bio); + appendToJson(result, "invite_link", parseChatInviteLink(object->inviteLink)); + removeLastComma(result); + result += '}'; + return result; +} + ChatPhoto::Ptr TgTypeParser::parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const { auto result(std::make_shared()); result->smallFileId = data.get("small_file_id", ""); @@ -1626,10 +1654,13 @@ ChatInviteLink::Ptr TgTypeParser::parseJsonAndGetChatInviteLink(const boost::pro auto result(std::make_shared()); result->inviteLink = data.get("invite_link", ""); result->creator = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "creator"); + result->createsJoinRequest = data.get("creates_join_request", false); result->isPrimary = data.get("is_primary", false); result->isRevoked = data.get("is_revoked", false); + result->name = data.get("name", ""); result->expireDate = data.get("expire_date", 0); result->memberLimit = data.get("member_limit", 0); + result->pendingJoinRequestCount = data.get("pending_join_request_count", 0); return result; } @@ -1641,10 +1672,13 @@ std::string TgTypeParser::parseChatInviteLink(const ChatInviteLink::Ptr& object) result += '{'; appendToJson(result, "invite_link", object->inviteLink); appendToJson(result, "creator", parseUser(object->creator)); + appendToJson(result, "creates_join_request", object->createsJoinRequest); appendToJson(result, "is_primary", object->isPrimary); appendToJson(result, "is_revoked", object->isRevoked); + appendToJson(result, "name", object->name); appendToJson(result, "expire_date", object->expireDate); appendToJson(result, "member_limit", object->memberLimit); + appendToJson(result, "pending_join_request_count", object->pendingJoinRequestCount); removeLastComma(result); result += '}'; return result; -- cgit v1.2.3