From 7b72d7a35fce82049fa63444b0ce5f2a3fc22129 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:43:12 +0200 Subject: Update to Bot API 6.6 --- src/TgTypeParser.cpp | 198 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 134 insertions(+), 64 deletions(-) (limited to 'src/TgTypeParser.cpp') diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 9e04851..efd1c08 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -531,7 +531,7 @@ Animation::Ptr TgTypeParser::parseJsonAndGetAnimation(const boost::property_tree result->width = data.get("width", 0); result->height = data.get("height", 0); result->duration = data.get("duration", 0); - result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); + result->thumbnail = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumbnail"); result->fileName = data.get("file_name", ""); result->mimeType = data.get("mime_type", ""); result->fileSize = data.get("file_size", 0); @@ -549,7 +549,7 @@ std::string TgTypeParser::parseAnimation(const Animation::Ptr& object) const { appendToJson(result, "width", object->width); appendToJson(result, "height", object->height); appendToJson(result, "duration", object->duration); - appendToJson(result, "thumb", parsePhotoSize(object->thumb)); + appendToJson(result, "thumbnail", parsePhotoSize(object->thumbnail)); appendToJson(result, "file_name", object->fileName); appendToJson(result, "mime_type", object->mimeType); appendToJson(result, "file_size", object->fileSize); @@ -568,7 +568,7 @@ Audio::Ptr TgTypeParser::parseJsonAndGetAudio(const boost::property_tree::ptree& result->fileName = data.get("file_name", ""); result->mimeType = data.get("mime_type", ""); result->fileSize = data.get("file_size", 0); - result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); + result->thumbnail = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumbnail"); return result; } @@ -586,7 +586,7 @@ std::string TgTypeParser::parseAudio(const Audio::Ptr& object) const { appendToJson(result, "file_name", object->fileName); appendToJson(result, "mime_type", object->mimeType); appendToJson(result, "file_size", object->fileSize); - appendToJson(result, "thumb", parsePhotoSize(object->thumb)); + appendToJson(result, "thumbnail", parsePhotoSize(object->thumbnail)); removeLastComma(result); result += '}'; return result; @@ -596,7 +596,7 @@ Document::Ptr TgTypeParser::parseJsonAndGetDocument(const boost::property_tree:: auto result(std::make_shared()); result->fileId = data.get("file_id", ""); result->fileUniqueId = data.get("file_unique_id", ""); - result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); + result->thumbnail = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumbnail"); result->fileName = data.get("file_name", ""); result->mimeType = data.get("mime_type", ""); result->fileSize = data.get("file_size", 0); @@ -611,7 +611,7 @@ std::string TgTypeParser::parseDocument(const Document::Ptr& object) const { result += '{'; appendToJson(result, "file_id", object->fileId); appendToJson(result, "file_unique_id", object->fileUniqueId); - appendToJson(result, "thumb", parsePhotoSize(object->thumb)); + appendToJson(result, "thumbnail", parsePhotoSize(object->thumbnail)); appendToJson(result, "file_name", object->fileName); appendToJson(result, "mime_type", object->mimeType); appendToJson(result, "file_size", object->fileSize); @@ -627,7 +627,7 @@ Video::Ptr TgTypeParser::parseJsonAndGetVideo(const boost::property_tree::ptree& result->width = data.get("width", 0); result->height = data.get("height", 0); result->duration = data.get("duration", 0); - result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); + result->thumbnail = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumbnail"); result->fileName = data.get("file_name", ""); result->mimeType = data.get("mime_type", ""); result->fileSize = data.get("file_size", 0); @@ -645,7 +645,7 @@ std::string TgTypeParser::parseVideo(const Video::Ptr& object) const { appendToJson(result, "width", object->width); appendToJson(result, "height", object->height); appendToJson(result, "duration", object->duration); - appendToJson(result, "thumb", parsePhotoSize(object->thumb)); + appendToJson(result, "thumbnail", parsePhotoSize(object->thumbnail)); appendToJson(result, "file_name", object->fileName); appendToJson(result, "mime_type", object->mimeType); appendToJson(result, "file_size", object->fileSize); @@ -660,7 +660,7 @@ VideoNote::Ptr TgTypeParser::parseJsonAndGetVideoNote(const boost::property_tree result->fileUniqueId = data.get("file_unique_id", ""); result->length = data.get("length", 0); result->duration = data.get("duration", 0); - result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); + result->thumbnail = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumbnail"); result->fileSize = data.get("file_size", 0); return result; } @@ -675,7 +675,7 @@ std::string TgTypeParser::parseVideoNote(const VideoNote::Ptr& object) const { appendToJson(result, "file_unique_id", object->fileUniqueId); appendToJson(result, "length", object->length); appendToJson(result, "duration", object->duration); - appendToJson(result, "thumb", parsePhotoSize(object->thumb)); + appendToJson(result, "thumbnail", parsePhotoSize(object->thumbnail)); appendToJson(result, "file_size", object->fileSize); removeLastComma(result); result += '}'; @@ -2220,6 +2220,36 @@ std::string TgTypeParser::parseBotCommandScopeChatMember(const BotCommandScopeCh return result; } +BotDescription::Ptr TgTypeParser::parseJsonAndGetBotDescription(const boost::property_tree::ptree& data) const { + auto result(std::make_shared()); + result->description = data.get("description", ""); + return result; +} + +std::string TgTypeParser::parseBotDescription(const BotDescription::Ptr& object) const { + std::string result; + result += '{'; + appendToJson(result, "description", object->description); + removeLastComma(result); + result += '}'; + return result; +} + +BotShortDescription::Ptr TgTypeParser::parseJsonAndGetBotShortDescription(const boost::property_tree::ptree& data) const { + auto result(std::make_shared()); + result->shortDescription = data.get("short_description", ""); + return result; +} + +std::string TgTypeParser::parseBotShortDescription(const BotShortDescription::Ptr& object) const { + std::string result; + result += '{'; + appendToJson(result, "short_description", object->shortDescription); + removeLastComma(result); + result += '}'; + return result; +} + MenuButton::Ptr TgTypeParser::parseJsonAndGetMenuButton(const boost::property_tree::ptree& data) const { std::string type = data.get("type", ""); MenuButton::Ptr result; @@ -2413,7 +2443,7 @@ std::string TgTypeParser::parseInputMediaPhoto(const InputMediaPhoto::Ptr& objec InputMediaVideo::Ptr TgTypeParser::parseJsonAndGetInputMediaVideo(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGetInputMedia(). auto result(std::make_shared()); - result->thumb = data.get("thumb", ""); + result->thumbnail = data.get("thumbnail", ""); result->width = data.get("width", 0); result->height = data.get("height", 0); result->duration = data.get("duration", 0); @@ -2429,7 +2459,7 @@ std::string TgTypeParser::parseInputMediaVideo(const InputMediaVideo::Ptr& objec // This function will be called by parseInputMedia(), so I don't add // curly brackets to the result std::string. std::string result; - appendToJson(result, "thumb", object->thumb); + appendToJson(result, "thumbnail", object->thumbnail); appendToJson(result, "width", object->width); appendToJson(result, "height", object->height); appendToJson(result, "duration", object->duration); @@ -2442,7 +2472,7 @@ std::string TgTypeParser::parseInputMediaVideo(const InputMediaVideo::Ptr& objec InputMediaAnimation::Ptr TgTypeParser::parseJsonAndGetInputMediaAnimation(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGetInputMedia(). auto result(std::make_shared()); - result->thumb = data.get("thumb", ""); + result->thumbnail = data.get("thumbnail", ""); result->width = data.get("width", 0); result->height = data.get("height", 0); result->duration = data.get("duration", 0); @@ -2457,7 +2487,7 @@ std::string TgTypeParser::parseInputMediaAnimation(const InputMediaAnimation::Pt // This function will be called by parseInputMedia(), so I don't add // curly brackets to the result std::string. std::string result; - appendToJson(result, "thumb", object->thumb); + appendToJson(result, "thumbnail", object->thumbnail); appendToJson(result, "width", object->width); appendToJson(result, "height", object->height); appendToJson(result, "duration", object->duration); @@ -2469,7 +2499,7 @@ std::string TgTypeParser::parseInputMediaAnimation(const InputMediaAnimation::Pt InputMediaAudio::Ptr TgTypeParser::parseJsonAndGetInputMediaAudio(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGetInputMedia(). auto result(std::make_shared()); - result->thumb = data.get("thumb", ""); + result->thumbnail = data.get("thumbnail", ""); result->duration = data.get("duration", 0); result->performer = data.get("performer", ""); result->title = data.get("title", ""); @@ -2483,7 +2513,7 @@ std::string TgTypeParser::parseInputMediaAudio(const InputMediaAudio::Ptr& objec // This function will be called by parseInputMedia(), so I don't add // curly brackets to the result std::string. std::string result; - appendToJson(result, "thumb", object->thumb); + appendToJson(result, "thumbnail", object->thumbnail); appendToJson(result, "duration", object->duration); appendToJson(result, "performer", object->performer); appendToJson(result, "title", object->title); @@ -2494,7 +2524,7 @@ std::string TgTypeParser::parseInputMediaAudio(const InputMediaAudio::Ptr& objec InputMediaDocument::Ptr TgTypeParser::parseJsonAndGetInputMediaDocument(const boost::property_tree::ptree& data) const { // NOTE: This function will be called by parseJsonAndGetInputMedia(). auto result(std::make_shared()); - result->thumb = data.get("thumb", ""); + result->thumbnail = data.get("thumbnail", ""); result->disableContentTypeDetection = data.get("disable_content_type_detection", false); return result; } @@ -2506,7 +2536,7 @@ std::string TgTypeParser::parseInputMediaDocument(const InputMediaDocument::Ptr& // This function will be called by parseInputMedia(), so I don't add // curly brackets to the result std::string. std::string result; - appendToJson(result, "thumb", object->thumb); + appendToJson(result, "thumbnail", object->thumbnail); appendToJson(result, "disable_content_type_detection", object->disableContentTypeDetection); // The last comma will be erased by parseInputMedia(). return result; @@ -2528,12 +2558,13 @@ Sticker::Ptr TgTypeParser::parseJsonAndGetSticker(const boost::property_tree::pt result->height = data.get("height", 0); result->isAnimated = data.get("is_animated", false); result->isVideo = data.get("is_video", false); - result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); + result->thumbnail = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumbnail"); result->emoji = data.get("emoji", ""); result->setName = data.get("set_name", ""); result->premiumAnimation = tryParseJson(&TgTypeParser::parseJsonAndGetFile, data, "premium_animation"); result->maskPosition = tryParseJson(&TgTypeParser::parseJsonAndGetMaskPosition, data, "mask_position"); result->customEmojiId = data.get("custom_emoji_id", ""); + result->needsRepainting = data.get("needs_repainting", true); result->fileSize = data.get("file_size", 0); return result; } @@ -2557,12 +2588,13 @@ std::string TgTypeParser::parseSticker(const Sticker::Ptr& object) const { appendToJson(result, "height", object->height); appendToJson(result, "is_animated", object->isAnimated); appendToJson(result, "is_video", object->isVideo); - appendToJson(result, "thumb", parsePhotoSize(object->thumb)); + appendToJson(result, "thumbnail", parsePhotoSize(object->thumbnail)); appendToJson(result, "emoji", object->emoji); appendToJson(result, "set_name", object->setName); appendToJson(result, "premium_animation", parseFile(object->premiumAnimation)); appendToJson(result, "mask_position", parseMaskPosition(object->maskPosition)); appendToJson(result, "custom_emoji_id", object->customEmojiId); + appendToJson(result, "needs_repainting", object->needsRepainting); appendToJson(result, "file_size", object->fileSize); removeLastComma(result); result += '}'; @@ -2584,7 +2616,7 @@ StickerSet::Ptr TgTypeParser::parseJsonAndGetStickerSet(const boost::property_tr result->isAnimated = data.get("is_animated", false); result->isVideo = data.get("is_video", false); result->stickers = parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetSticker, data, "stickers"); - result->thumb = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumb"); + result->thumbnail = tryParseJson(&TgTypeParser::parseJsonAndGetPhotoSize, data, "thumbnail"); return result; } @@ -2606,7 +2638,7 @@ std::string TgTypeParser::parseStickerSet(const StickerSet::Ptr& object) const { appendToJson(result, "is_animated", object->isAnimated); appendToJson(result, "is_video", object->isVideo); appendToJson(result, "stickers", parseArray(&TgTypeParser::parseSticker, object->stickers)); - appendToJson(result, "thumb", parsePhotoSize(object->thumb)); + appendToJson(result, "thumbnail", parsePhotoSize(object->thumbnail)); removeLastComma(result); result += '}'; return result; @@ -2636,6 +2668,44 @@ std::string TgTypeParser::parseMaskPosition(const MaskPosition::Ptr& object) con return result; } +InputSticker::Ptr TgTypeParser::parseJsonAndGetInputSticker(const boost::property_tree::ptree& data) const { + auto result(std::make_shared()); + result->sticker = data.get("sticker", ""); + result->emojiList = parseJsonAndGetArray( + [] (const boost::property_tree::ptree& innerData)->std::string { + return innerData.get(""); + } + , data, "emoji_list"); + result->maskPosition = tryParseJson(&TgTypeParser::parseJsonAndGetMaskPosition, data, "mask_position"); + result->keywords = parseJsonAndGetArray( + [] (const boost::property_tree::ptree& innerData)->std::string { + return innerData.get(""); + } + , data, "keywords"); + return result; +} + +std::string TgTypeParser::parseInputSticker(const InputSticker::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "sticker", object->sticker); + appendToJson(result, "emoji_list", parseArray( + [] (const std::string& s)->std::string { + return s; + }, object->emojiList)); + appendToJson(result, "mask_position", parseMaskPosition(object->maskPosition)); + appendToJson(result, "keywords", parseArray( + [] (const std::string& s)->std::string { + return s; + }, object->keywords)); + removeLastComma(result); + result += '}'; + return result; +} + InlineQuery::Ptr TgTypeParser::parseJsonAndGetInlineQuery(const boost::property_tree::ptree& data) const { auto result(std::make_shared()); result->id = data.get("id", ""); @@ -2784,9 +2854,9 @@ InlineQueryResultArticle::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultArti result->url = data.get("url", ""); result->hideUrl = data.get("hide_url", false); result->description = data.get("description", ""); - result->thumbUrl = data.get("thumb_url", ""); - result->thumbWidth = data.get("thumb_width", 0); - result->thumbHeight = data.get("thumb_height", 0); + result->thumbnailUrl = data.get("thumbnail_url", ""); + result->thumbnailWidth = data.get("thumbnail_width", 0); + result->thumbnailHeight = data.get("thumbnail_height", 0); return result; } @@ -2802,9 +2872,9 @@ std::string TgTypeParser::parseInlineQueryResultArticle(const InlineQueryResultA appendToJson(result, "url", object->url); appendToJson(result, "hide_url", object->hideUrl); appendToJson(result, "description", object->description); - appendToJson(result, "thumb_url", object->thumbUrl); - appendToJson(result, "thumb_width", object->thumbWidth); - appendToJson(result, "thumb_height", object->thumbHeight); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); + appendToJson(result, "thumbnail_width", object->thumbnailWidth); + appendToJson(result, "thumbnail_height", object->thumbnailHeight); // The last comma will be erased by parseInlineQueryResult(). return result; } @@ -2813,7 +2883,7 @@ InlineQueryResultPhoto::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultPhoto( // NOTE: This function will be called by parseJsonAndGetInlineQueryResult(). auto result(std::make_shared()); result->photoUrl = data.get("photo_url", ""); - result->thumbUrl = data.get("thumb_url", ""); + result->thumbnailUrl = data.get("thumbnail_url", ""); result->photoWidth = data.get("photo_width", 0); result->photoHeight = data.get("photo_height", 0); result->title = data.get("title", ""); @@ -2833,7 +2903,7 @@ std::string TgTypeParser::parseInlineQueryResultPhoto(const InlineQueryResultPho // curly brackets to the result std::string. std::string result; appendToJson(result, "photo_url", object->photoUrl); - appendToJson(result, "thumb_url", object->thumbUrl); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); appendToJson(result, "photo_width", object->photoWidth); appendToJson(result, "photo_height", object->photoHeight); appendToJson(result, "title", object->title); @@ -2853,8 +2923,8 @@ InlineQueryResultGif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultGif(cons result->gifWidth = data.get("gif_width", 0); result->gifHeight = data.get("gif_height", 0); result->gifDuration = data.get("gif_duration", 0); - result->thumbUrl = data.get("thumb_url", ""); - result->thumbMimeType = data.get("thumb_mime_type", ""); + result->thumbnailUrl = data.get("thumbnail_url", ""); + result->thumbnailMimeType = data.get("thumbnail_mime_type", ""); result->title = data.get("title", ""); result->caption = data.get("caption", ""); result->parseMode = data.get("parse_mode", ""); @@ -2874,8 +2944,8 @@ std::string TgTypeParser::parseInlineQueryResultGif(const InlineQueryResultGif:: appendToJson(result, "gif_width", object->gifWidth); appendToJson(result, "gif_height", object->gifHeight); appendToJson(result, "gif_duration", object->gifDuration); - appendToJson(result, "thumb_url", object->thumbUrl); - appendToJson(result, "thumb_mime_type", object->thumbMimeType); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); + appendToJson(result, "thumbnail_mime_type", object->thumbnailMimeType); appendToJson(result, "title", object->title); appendToJson(result, "caption", object->caption); appendToJson(result, "parse_mode", object->parseMode); @@ -2892,8 +2962,8 @@ InlineQueryResultMpeg4Gif::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultMpe result->mpeg4Width = data.get("mpeg4_width", 0); result->mpeg4Height = data.get("mpeg4_height", 0); result->mpeg4Duration = data.get("mpeg4_duration", 0); - result->thumbUrl = data.get("thumb_url", ""); - result->thumbMimeType = data.get("thumb_mime_type", ""); + result->thumbnailUrl = data.get("thumbnail_url", ""); + result->thumbnailMimeType = data.get("thumbnail_mime_type", ""); result->title = data.get("title", ""); result->caption = data.get("caption", ""); result->parseMode = data.get("parse_mode", ""); @@ -2913,8 +2983,8 @@ std::string TgTypeParser::parseInlineQueryResultMpeg4Gif(const InlineQueryResult appendToJson(result, "mpeg4_width", object->mpeg4Width); appendToJson(result, "mpeg4_height", object->mpeg4Height); appendToJson(result, "mpeg4_duration", object->mpeg4Duration); - appendToJson(result, "thumb_url", object->thumbUrl); - appendToJson(result, "thumb_mime_type", object->thumbMimeType); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); + appendToJson(result, "thumbnail_mime_type", object->thumbnailMimeType); appendToJson(result, "title", object->title); appendToJson(result, "caption", object->caption); appendToJson(result, "parse_mode", object->parseMode); @@ -2929,7 +2999,7 @@ InlineQueryResultVideo::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVideo( auto result(std::make_shared()); result->videoUrl = data.get("video_url", ""); result->mimeType = data.get("mime_type", ""); - result->thumbUrl = data.get("thumb_url", ""); + result->thumbnailUrl = data.get("thumbnail_url", ""); result->title = data.get("title", ""); result->caption = data.get("caption", ""); result->parseMode = data.get("parse_mode", ""); @@ -2951,7 +3021,7 @@ std::string TgTypeParser::parseInlineQueryResultVideo(const InlineQueryResultVid std::string result; appendToJson(result, "video_url", object->videoUrl); appendToJson(result, "mime_type", object->mimeType); - appendToJson(result, "thumb_url", object->thumbUrl); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); appendToJson(result, "title", object->title); appendToJson(result, "caption", object->caption); appendToJson(result, "parse_mode", object->parseMode); @@ -3040,9 +3110,9 @@ InlineQueryResultDocument::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultDoc result->mimeType = data.get("mime_type", ""); result->description = data.get("description", ""); result->inputMessageContent = tryParseJson(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content"); - result->thumbUrl = data.get("thumb_url", ""); - result->thumbWidth = data.get("thumb_width", 0); - result->thumbHeight = data.get("thumb_height", 0); + result->thumbnailUrl = data.get("thumbnail_url", ""); + result->thumbnailWidth = data.get("thumbnail_width", 0); + result->thumbnailHeight = data.get("thumbnail_height", 0); return result; } @@ -3061,9 +3131,9 @@ std::string TgTypeParser::parseInlineQueryResultDocument(const InlineQueryResult appendToJson(result, "mime_type", object->mimeType); appendToJson(result, "description", object->description); appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent)); - appendToJson(result, "thumb_url", object->thumbUrl); - appendToJson(result, "thumb_width", object->thumbWidth); - appendToJson(result, "thumb_height", object->thumbHeight); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); + appendToJson(result, "thumbnail_width", object->thumbnailWidth); + appendToJson(result, "thumbnail_height", object->thumbnailHeight); // The last comma will be erased by parseInlineQueryResult(). return result; } @@ -3079,9 +3149,9 @@ InlineQueryResultLocation::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultLoc result->heading = data.get("heading", 0); result->proximityAlertRadius = data.get("proximity_alert_radius", 0); result->inputMessageContent = tryParseJson(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content"); - result->thumbUrl = data.get("thumb_url", ""); - result->thumbWidth = data.get("thumb_width", 0); - result->thumbHeight = data.get("thumb_height", 0); + result->thumbnailUrl = data.get("thumbnail_url", ""); + result->thumbnailWidth = data.get("thumbnail_width", 0); + result->thumbnailHeight = data.get("thumbnail_height", 0); return result; } @@ -3100,9 +3170,9 @@ std::string TgTypeParser::parseInlineQueryResultLocation(const InlineQueryResult appendToJson(result, "heading", object->heading); appendToJson(result, "proximity_alert_radius", object->proximityAlertRadius); appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent)); - appendToJson(result, "thumb_url", object->thumbUrl); - appendToJson(result, "thumb_width", object->thumbWidth); - appendToJson(result, "thumb_height", object->thumbHeight); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); + appendToJson(result, "thumbnail_width", object->thumbnailWidth); + appendToJson(result, "thumbnail_height", object->thumbnailHeight); // The last comma will be erased by parseInlineQueryResult(). return result; } @@ -3119,9 +3189,9 @@ InlineQueryResultVenue::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultVenue( result->googlePlaceId = data.get("google_place_id", ""); result->googlePlaceType = data.get("google_place_type", ""); result->inputMessageContent = tryParseJson(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content"); - result->thumbUrl = data.get("thumb_url", ""); - result->thumbWidth = data.get("thumb_width", 0); - result->thumbHeight = data.get("thumb_height", 0); + result->thumbnailUrl = data.get("thumbnail_url", ""); + result->thumbnailWidth = data.get("thumbnail_width", 0); + result->thumbnailHeight = data.get("thumbnail_height", 0); return result; } @@ -3141,9 +3211,9 @@ std::string TgTypeParser::parseInlineQueryResultVenue(const InlineQueryResultVen appendToJson(result, "google_place_id", object->googlePlaceId); appendToJson(result, "google_place_type", object->googlePlaceType); appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent)); - appendToJson(result, "thumb_url", object->thumbUrl); - appendToJson(result, "thumb_width", object->thumbWidth); - appendToJson(result, "thumb_height", object->thumbHeight); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); + appendToJson(result, "thumbnail_width", object->thumbnailWidth); + appendToJson(result, "thumbnail_height", object->thumbnailHeight); // The last comma will be erased by parseInlineQueryResult(). return result; } @@ -3156,9 +3226,9 @@ InlineQueryResultContact::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultCont result->lastName = data.get("last_name", ""); result->vcard = data.get("vcard", ""); result->inputMessageContent = tryParseJson(&TgTypeParser::parseJsonAndGetInputMessageContent, data, "input_message_content"); - result->thumbUrl = data.get("thumb_url", ""); - result->thumbWidth = data.get("thumb_width", 0); - result->thumbHeight = data.get("thumb_height", 0); + result->thumbnailUrl = data.get("thumbnail_url", ""); + result->thumbnailWidth = data.get("thumbnail_width", 0); + result->thumbnailHeight = data.get("thumbnail_height", 0); return result; } @@ -3174,9 +3244,9 @@ std::string TgTypeParser::parseInlineQueryResultContact(const InlineQueryResultC appendToJson(result, "last_name", object->lastName); appendToJson(result, "vcard", object->vcard); appendToJson(result, "input_message_content", parseInputMessageContent(object->inputMessageContent)); - appendToJson(result, "thumb_url", object->thumbUrl); - appendToJson(result, "thumb_width", object->thumbWidth); - appendToJson(result, "thumb_height", object->thumbHeight); + appendToJson(result, "thumbnail_url", object->thumbnailUrl); + appendToJson(result, "thumbnail_width", object->thumbnailWidth); + appendToJson(result, "thumbnail_height", object->thumbnailHeight); // The last comma will be erased by parseInlineQueryResult(). return result; } -- cgit v1.2.3 From fbeb025e21fad2fa1fb6cd5ae186eabf9a349091 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Mon, 15 Apr 2024 01:24:12 +0200 Subject: Update to Bot API 6.7 --- src/TgTypeParser.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) (limited to 'src/TgTypeParser.cpp') diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index efd1c08..76a4add 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -1109,6 +1109,7 @@ std::string TgTypeParser::parseChatShared(const ChatShared::Ptr& object) const { WriteAccessAllowed::Ptr TgTypeParser::parseJsonAndGetWriteAccessAllowed(const boost::property_tree::ptree& data) const { auto result(std::make_shared()); + result->webAppName = data.get("web_app_name", ""); return result; } @@ -1118,7 +1119,8 @@ std::string TgTypeParser::parseWriteAccessAllowed(const WriteAccessAllowed::Ptr& } std::string result; result += '{'; - //removeLastComma(result); + appendToJson(result, "web_app_name", object->webAppName); + removeLastComma(result); result += '}'; return result; } @@ -1456,10 +1458,12 @@ InlineKeyboardButton::Ptr TgTypeParser::parseJsonAndGetInlineKeyboardButton(cons result->loginUrl = tryParseJson(&TgTypeParser::parseJsonAndGetLoginUrl, data, "login_url"); result->switchInlineQuery = data.get("switch_inline_query", ""); result->switchInlineQueryCurrentChat = data.get("switch_inline_query_current_chat", ""); + result->switchInlineQueryChosenChat = tryParseJson(&TgTypeParser::parseJsonAndGetSwitchInlineQueryChosenChat, data, "switch_inline_query_chosen_chat"); result->callbackGame = tryParseJson(&TgTypeParser::parseJsonAndGetCallbackGame, data, "callback_game"); result->pay = data.get("pay", false); return result; } + std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton::Ptr& object) const { if (!object) { return ""; @@ -1473,6 +1477,7 @@ std::string TgTypeParser::parseInlineKeyboardButton(const InlineKeyboardButton:: appendToJson(result, "login_url", parseLoginUrl(object->loginUrl)); appendToJson(result, "switch_inline_query", object->switchInlineQuery); appendToJson(result, "switch_inline_query_current_chat", object->switchInlineQueryCurrentChat); + appendToJson(result, "switch_inline_query_chosen_chat", parseSwitchInlineQueryChosenChat(object->switchInlineQueryChosenChat)); appendToJson(result, "callback_game", parseCallbackGame(object->callbackGame)); appendToJson(result, "pay", object->pay); removeLastComma(result); @@ -1504,6 +1509,32 @@ std::string TgTypeParser::parseLoginUrl(const LoginUrl::Ptr& object) const { return result; } +SwitchInlineQueryChosenChat::Ptr TgTypeParser::parseJsonAndGetSwitchInlineQueryChosenChat(const boost::property_tree::ptree& data) const { + auto result(std::make_shared()); + result->query = data.get("query", ""); + result->allowUserChats = data.get("allow_user_chats", false); + result->allowBotChats = data.get("allow_bot_chats", false); + result->allowGroupChats = data.get("allow_group_chats", false); + result->allowChannelChats = data.get("allow_channel_chats", false); + return result; +} + +std::string TgTypeParser::parseSwitchInlineQueryChosenChat(const SwitchInlineQueryChosenChat::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "query", object->query); + appendToJson(result, "allow_user_chats", object->allowUserChats); + appendToJson(result, "allow_bot_chats", object->allowBotChats); + appendToJson(result, "allow_group_chats", object->allowGroupChats); + appendToJson(result, "allow_channel_chats", object->allowChannelChats); + removeLastComma(result); + result += '}'; + return result; +} + CallbackQuery::Ptr TgTypeParser::parseJsonAndGetCallbackQuery(const boost::property_tree::ptree& data) const { auto result(std::make_shared()); result->id = data.get("id"); @@ -1880,10 +1911,11 @@ ChatMemberUpdated::Ptr TgTypeParser::parseJsonAndGetChatMemberUpdated(const boos 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->date = data.get("date", 0); result->oldChatMember = tryParseJson(&TgTypeParser::parseJsonAndGetChatMember, data, "old_chat_member"); result->newChatMember = tryParseJson(&TgTypeParser::parseJsonAndGetChatMember, data, "new_chat_member"); result->inviteLink = tryParseJson(&TgTypeParser::parseJsonAndGetChatInviteLink, data, "invite_link"); + result->viaChatFolderInviteLink = data.get("via_chat_folder_invite_link", false); return result; } @@ -1899,6 +1931,7 @@ std::string TgTypeParser::parseChatMemberUpdated(const ChatMemberUpdated::Ptr& o appendToJson(result, "old_chat_member", parseChatMember(object->oldChatMember)); appendToJson(result, "new_chat_member", parseChatMember(object->newChatMember)); appendToJson(result, "invite_link", parseChatInviteLink(object->inviteLink)); + appendToJson(result, "via_chat_folder_invite_link", object->viaChatFolderInviteLink); removeLastComma(result); result += '}'; return result; @@ -2220,6 +2253,21 @@ std::string TgTypeParser::parseBotCommandScopeChatMember(const BotCommandScopeCh return result; } +BotName::Ptr TgTypeParser::parseJsonAndGetBotName(const boost::property_tree::ptree& data) const { + auto result(std::make_shared()); + result->name = data.get("name", ""); + return result; +} + +std::string TgTypeParser::parseBotName(const BotName::Ptr& object) const { + std::string result; + result += '{'; + appendToJson(result, "name", object->name); + removeLastComma(result); + result += '}'; + return result; +} + BotDescription::Ptr TgTypeParser::parseJsonAndGetBotDescription(const boost::property_tree::ptree& data) const { auto result(std::make_shared()); result->description = data.get("description", ""); @@ -2734,6 +2782,28 @@ std::string TgTypeParser::parseInlineQuery(const InlineQuery::Ptr& object) const return result; } +InlineQueryResultsButton::Ptr TgTypeParser::parseJsonAndGetInlineQueryResultsButton(const boost::property_tree::ptree& data) const { + auto result(std::make_shared()); + result->text = data.get("text", ""); + result->webApp = tryParseJson(&TgTypeParser::parseJsonAndGetWebAppInfo, data, "web_app"); + result->startParameter = data.get("start_parameter", ""); + return result; +} + +std::string TgTypeParser::parseInlineQueryResultsButton(const InlineQueryResultsButton::Ptr& object) const { + if (!object) { + return ""; + } + std::string result; + result += '{'; + appendToJson(result, "text", object->text); + appendToJson(result, "web_app", parseWebAppInfo(object->webApp)); + appendToJson(result, "start_parameter", object->startParameter); + removeLastComma(result); + result += '}'; + return result; +} + InlineQueryResult::Ptr TgTypeParser::parseJsonAndGetInlineQueryResult(const boost::property_tree::ptree& data) const { std::string type = data.get("type", ""); InlineQueryResult::Ptr result; -- cgit v1.2.3 From 5aaaa79ee2441dd36a3af4e1c869717bf9b2c927 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:46:10 +0200 Subject: Update to Bot API 6.8 --- src/TgTypeParser.cpp | 61 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 18 deletions(-) (limited to 'src/TgTypeParser.cpp') diff --git a/src/TgTypeParser.cpp b/src/TgTypeParser.cpp index 76a4add..86a25c1 100644 --- a/src/TgTypeParser.cpp +++ b/src/TgTypeParser.cpp @@ -152,6 +152,7 @@ Chat::Ptr TgTypeParser::parseJsonAndGetChat(const boost::property_tree::ptree& d return innerData.get(""); }, data, "active_usernames"); result->emojiStatusCustomEmojiId = data.get("emoji_status_custom_emoji_id", ""); + result->emojiStatusExpirationDate = data.get("emoji_status_expiration_date", 0); result->bio = data.get("bio", ""); result->hasPrivateForwards = data.get("has_private_forwards", false); result->hasRestrictedVoiceAndVideoMessages = data.get("has_restricted_voice_and_video_messages", false); @@ -200,6 +201,7 @@ std::string TgTypeParser::parseChat(const Chat::Ptr& object) const { return s; }, object->activeUsernames)); appendToJson(result, "emoji_status_custom_emoji_id", object->emojiStatusCustomEmojiId); + appendToJson(result, "emoji_status_expiration_date", object->emojiStatusExpirationDate); appendToJson(result, "bio", object->bio); appendToJson(result, "has_private_forwards", object->hasPrivateForwards); appendToJson(result, "has_restricted_voice_and_video_messages", object->hasRestrictedVoiceAndVideoMessages); @@ -229,19 +231,19 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const boost::property_tree::pt result->messageThreadId = data.get("message_thread_id", 0); result->from = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "from"); result->senderChat = tryParseJson(&TgTypeParser::parseJsonAndGetChat, data, "sender_chat"); - result->date = data.get("date", 0); + result->date = data.get("date", 0); result->chat = parseJsonAndGetChat(data.find("chat")->second); result->forwardFrom = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "forward_from"); result->forwardFromChat = tryParseJson(&TgTypeParser::parseJsonAndGetChat, data, "forward_from_chat"); result->forwardFromMessageId = data.get("forward_from_message_id", 0); result->forwardSignature = data.get("forward_signature", ""); result->forwardSenderName = data.get("forward_sender_name", ""); - result->forwardDate = data.get("forward_date", 0); + result->forwardDate = data.get("forward_date", 0); result->isTopicMessage = data.get("is_topic_message", false); result->isAutomaticForward = data.get("is_automatic_forward", false); result->replyToMessage = tryParseJson(&TgTypeParser::parseJsonAndGetMessage, data, "reply_to_message"); result->viaBot = tryParseJson(&TgTypeParser::parseJsonAndGetUser, data, "via_bot"); - result->editDate = data.get("edit_date", 0); + result->editDate = data.get("edit_date", 0); result->hasProtectedContent = data.get("has_protected_content", false); result->mediaGroupId = data.get("media_group_id", ""); result->authorSignature = data.get("author_signature", ""); @@ -252,6 +254,7 @@ Message::Ptr TgTypeParser::parseJsonAndGetMessage(const boost::property_tree::pt result->document = tryParseJson(&TgTypeParser::parseJsonAndGetDocument, data, "document"); result->photo = parseJsonAndGetArray(&TgTypeParser::parseJsonAndGetPhotoSize, data, "photo"); result->sticker = tryParseJson(&TgTypeParser::parseJsonAndGetSticker, data, "sticker"); + result->story = tryParseJson(&TgTypeParser::parseJsonAndGetStory, data, "story"); result->video = tryParseJson