diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 20b98b1..8963645 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -7879,6 +7879,7 @@ td::Result> Client::get_inlin TRY_RESULT(parse_mode, object.get_optional_string_field("parse_mode")); auto entities = object.extract_field("caption_entities"); TRY_RESULT(caption, get_formatted_text(std::move(input_caption), std::move(parse_mode), std::move(entities))); + TRY_RESULT(show_caption_above_media, object.get_optional_bool_field("show_caption_above_media")); TRY_RESULT(reply_markup_object, object.extract_optional_field("reply_markup", td::JsonValue::Type::Object)); object_ptr reply_markup; @@ -7979,8 +7980,9 @@ td::Result> Client::get_inlin } if (input_message_content == nullptr) { - input_message_content = make_object( - nullptr, nullptr, td::vector(), gif_duration, gif_width, gif_height, std::move(caption), false, false); + input_message_content = + make_object(nullptr, nullptr, td::vector(), gif_duration, gif_width, + gif_height, std::move(caption), show_caption_above_media, false); } return make_object( id, title, thumbnail_url, thumbnail_mime_type, gif_url, "image/gif", gif_duration, gif_width, gif_height, @@ -8022,7 +8024,7 @@ td::Result> Client::get_inlin if (input_message_content == nullptr) { input_message_content = make_object(nullptr, nullptr, td::vector(), mpeg4_duration, mpeg4_width, - mpeg4_height, std::move(caption), false, false); + mpeg4_height, std::move(caption), show_caption_above_media, false); } return make_object( id, title, thumbnail_url, thumbnail_mime_type, mpeg4_url, "video/mp4", mpeg4_duration, mpeg4_width, @@ -8039,8 +8041,8 @@ td::Result> Client::get_inlin } if (input_message_content == nullptr) { - input_message_content = make_object(nullptr, nullptr, td::vector(), 0, 0, - std::move(caption), false, nullptr, false); + input_message_content = make_object( + nullptr, nullptr, td::vector(), 0, 0, std::move(caption), show_caption_above_media, nullptr, false); } return make_object(id, title, description, thumbnail_url, photo_url, photo_width, photo_height, std::move(reply_markup), @@ -8105,9 +8107,9 @@ td::Result> Client::get_inlin } if (input_message_content == nullptr) { - input_message_content = - make_object(nullptr, nullptr, td::vector(), video_duration, video_width, - video_height, false, std::move(caption), false, nullptr, false); + input_message_content = make_object( + nullptr, nullptr, td::vector(), video_duration, video_width, video_height, false, std::move(caption), + show_caption_above_media, nullptr, false); } return make_object(id, title, description, thumbnail_url, video_url, mime_type, video_width, video_height, video_duration, @@ -9070,6 +9072,7 @@ td::Result> Client::get_input_me TRY_RESULT(parse_mode, object.get_optional_string_field("parse_mode")); auto entities = object.extract_field("caption_entities"); TRY_RESULT(caption, get_formatted_text(std::move(input_caption), std::move(parse_mode), std::move(entities))); + TRY_RESULT(show_caption_above_media, object.get_optional_bool_field("show_caption_above_media")); TRY_RESULT(has_spoiler, object.get_optional_bool_field("has_spoiler")); TRY_RESULT(media, object.get_optional_string_field("media")); @@ -9097,7 +9100,7 @@ td::Result> Client::get_input_me TRY_RESULT(type, object.get_required_string_field("type")); if (type == "photo") { return make_object(std::move(input_file), nullptr, td::vector(), 0, 0, - std::move(caption), false, nullptr, has_spoiler); + std::move(caption), show_caption_above_media, nullptr, has_spoiler); } if (type == "video") { TRY_RESULT(width, object.get_optional_int_field("width")); @@ -9110,7 +9113,7 @@ td::Result> Client::get_input_me return make_object(std::move(input_file), std::move(input_thumbnail), td::vector(), duration, width, height, supports_streaming, - std::move(caption), false, nullptr, has_spoiler); + std::move(caption), show_caption_above_media, nullptr, has_spoiler); } if (for_album && type == "animation") { return td::Status::Error(PSLICE() << "type \"" << type << "\" can't be used in sendMediaGroup"); @@ -9124,7 +9127,7 @@ td::Result> Client::get_input_me duration = td::clamp(duration, 0, MAX_DURATION); return make_object(std::move(input_file), std::move(input_thumbnail), td::vector(), duration, width, height, std::move(caption), - false, has_spoiler); + show_caption_above_media, has_spoiler); } if (type == "audio") { TRY_RESULT(duration, object.get_optional_int_field("duration")); @@ -9774,11 +9777,12 @@ td::Status Client::process_send_animation_query(PromisedQueryPtr &query) { int32 width = get_integer_arg(query.get(), "width", 0, 0, MAX_LENGTH); int32 height = get_integer_arg(query.get(), "height", 0, 0, MAX_LENGTH); TRY_RESULT(caption, get_caption(query.get())); + auto show_caption_above_media = to_bool(query->arg("show_caption_above_media")); auto has_spoiler = to_bool(query->arg("has_spoiler")); - do_send_message( - make_object(std::move(animation), std::move(thumbnail), td::vector(), - duration, width, height, std::move(caption), false, has_spoiler), - std::move(query)); + do_send_message(make_object(std::move(animation), std::move(thumbnail), + td::vector(), duration, width, height, + std::move(caption), show_caption_above_media, has_spoiler), + std::move(query)); return td::Status::OK(); } @@ -9824,10 +9828,12 @@ td::Status Client::process_send_photo_query(PromisedQueryPtr &query) { return td::Status::Error(400, "There is no photo in the request"); } TRY_RESULT(caption, get_caption(query.get())); + auto show_caption_above_media = to_bool(query->arg("show_caption_above_media")); auto has_spoiler = to_bool(query->arg("has_spoiler")); - do_send_message(make_object(std::move(photo), nullptr, td::vector(), 0, 0, - std::move(caption), false, nullptr, has_spoiler), - std::move(query)); + do_send_message( + make_object(std::move(photo), nullptr, td::vector(), 0, 0, std::move(caption), + show_caption_above_media, nullptr, has_spoiler), + std::move(query)); return td::Status::OK(); } @@ -9853,10 +9859,11 @@ td::Status Client::process_send_video_query(PromisedQueryPtr &query) { int32 height = get_integer_arg(query.get(), "height", 0, 0, MAX_LENGTH); bool supports_streaming = to_bool(query->arg("supports_streaming")); TRY_RESULT(caption, get_caption(query.get())); + auto show_caption_above_media = to_bool(query->arg("show_caption_above_media")); auto has_spoiler = to_bool(query->arg("has_spoiler")); - do_send_message(make_object(std::move(video), std::move(thumbnail), td::vector(), - duration, width, height, supports_streaming, - std::move(caption), false, nullptr, has_spoiler), + do_send_message(make_object( + std::move(video), std::move(thumbnail), td::vector(), duration, width, height, + supports_streaming, std::move(caption), show_caption_above_media, nullptr, has_spoiler), std::move(query)); return td::Status::OK(); }