From 1deb50e9db6e1b668af8c993b449d59f001c8977 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Sun, 27 May 2018 16:35:52 +0900 Subject: Bot API 3.1 update --- src/TgTypeParser.cpp | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src/TgTypeParser.cpp') diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index c442600..9a48de5 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -50,6 +50,12 @@ Chat::Ptr TgTypeParser::parseJsonAndGetChat(const ptree& data) const { result->firstName = data.get("first_name", ""); result->lastName = data.get("last_name", ""); result->allMembersAreAdministrators = data.get("all_members_are_administrators", false); + result->photo = tryParseJson(&TgTypeParser::parseJsonAndGetChatPhoto, data, "photo"); + result->description = data.get("description", ""); + result->inviteLink = data.get("invite_link", ""); + result->pinnedMessage = tryParseJson(&TgTypeParser::parseJsonAndGetMessage, data, "pinned_message"); + result->stickerSetName = data.get("sticker_set_name", ""); + result->canSetStickerSet = data.get("can_set_sticker_set", false); return result; } @@ -107,10 +113,10 @@ string TgTypeParser::parseUser(const User::Ptr& object) const { MessageEntity::Ptr TgTypeParser::parseJsonAndGetEntity(const ptree& data) const{ auto result(make_shared()); - result->type=data.get("type"); - result->offset=data.get("offset"); - result->length=data.get("length"); - result->url=data.get("url", ""); + result->type = data.get("type"); + result->offset = data.get("offset"); + result->length = data.get("length"); + result->url = data.get("url", ""); result->user = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "user"); return result; } @@ -571,7 +577,21 @@ std::string TgTypeParser::parseForceReply(const ForceReply::Ptr& object) const { ChatMember::Ptr TgTypeParser::parseJsonAndGetChatMember(const boost::property_tree::ptree& data) const { auto result(make_shared()); result->user = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "user"); - result->status = data.get("status"); + result->status = data.get("status", ""); + result->untilDate = data.get("until_date", 0); + result->canBeEdited = data.get("can_be_edited", false); + result->canChangeInfo = data.get("can_change_info", false); + result->canPostMessages = data.get("can_post_messages", false); + result->canEditMessages = data.get("can_edit_messages", false); + result->canDeleteMessages = data.get("can_delete_messages", false); + result->canInviteUsers = data.get("can_invite_users", false); + result->canRestrictMembers = data.get("can_restrict_members", false); + result->canPinMessages = data.get("can_pin_messages", false); + result->canPromoteMembers = data.get("can_promote_messages", false); + result->canSendMessages = data.get("can_send_messages", false); + result->canSendMediaMessages = data.get("can_send_media_messages", false); + result->canSendOtherMessages = data.get("can_send_other_messages", false); + result->canAddWebPagePreviews = data.get("can_add_web_page_previews", false); return result; } @@ -588,6 +608,13 @@ std::string TgTypeParser::parseChatMember(const ChatMember::Ptr& object) const { return result; } +ChatPhoto::Ptr TgTypeParser::parseJsonAndGetChatPhoto(const boost::property_tree::ptree& data) const { + auto result(make_shared()); + result->smallFileId = data.get("small_file_id", ""); + result->bigFileId = data.get("big_file_id", ""); + return result; +} + ResponseParameters::Ptr TgTypeParser::parseJsonAndGetResponseParameters(const boost::property_tree::ptree& data) const { auto result(make_shared()); result->migrateToChatId = data.get("migrate_to_chat_id", 0); -- cgit v1.2.3