mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-12-29 13:45:49 +01:00
Allow to send messages with caption above media.
This commit is contained in:
parent
7d7b4049a4
commit
5f3e2202b7
@ -7879,6 +7879,7 @@ td::Result<td_api::object_ptr<td_api::InputInlineQueryResult>> 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<td_api::ReplyMarkup> reply_markup;
|
||||
@ -7979,8 +7980,9 @@ td::Result<td_api::object_ptr<td_api::InputInlineQueryResult>> Client::get_inlin
|
||||
}
|
||||
|
||||
if (input_message_content == nullptr) {
|
||||
input_message_content = make_object<td_api::inputMessageAnimation>(
|
||||
nullptr, nullptr, td::vector<int32>(), gif_duration, gif_width, gif_height, std::move(caption), false, false);
|
||||
input_message_content =
|
||||
make_object<td_api::inputMessageAnimation>(nullptr, nullptr, td::vector<int32>(), gif_duration, gif_width,
|
||||
gif_height, std::move(caption), show_caption_above_media, false);
|
||||
}
|
||||
return make_object<td_api::inputInlineQueryResultAnimation>(
|
||||
id, title, thumbnail_url, thumbnail_mime_type, gif_url, "image/gif", gif_duration, gif_width, gif_height,
|
||||
@ -8022,7 +8024,7 @@ td::Result<td_api::object_ptr<td_api::InputInlineQueryResult>> Client::get_inlin
|
||||
if (input_message_content == nullptr) {
|
||||
input_message_content =
|
||||
make_object<td_api::inputMessageAnimation>(nullptr, nullptr, td::vector<int32>(), mpeg4_duration, mpeg4_width,
|
||||
mpeg4_height, std::move(caption), false, false);
|
||||
mpeg4_height, std::move(caption), show_caption_above_media, false);
|
||||
}
|
||||
return make_object<td_api::inputInlineQueryResultAnimation>(
|
||||
id, title, thumbnail_url, thumbnail_mime_type, mpeg4_url, "video/mp4", mpeg4_duration, mpeg4_width,
|
||||
@ -8039,8 +8041,8 @@ td::Result<td_api::object_ptr<td_api::InputInlineQueryResult>> Client::get_inlin
|
||||
}
|
||||
|
||||
if (input_message_content == nullptr) {
|
||||
input_message_content = make_object<td_api::inputMessagePhoto>(nullptr, nullptr, td::vector<int32>(), 0, 0,
|
||||
std::move(caption), false, nullptr, false);
|
||||
input_message_content = make_object<td_api::inputMessagePhoto>(
|
||||
nullptr, nullptr, td::vector<int32>(), 0, 0, std::move(caption), show_caption_above_media, nullptr, false);
|
||||
}
|
||||
return make_object<td_api::inputInlineQueryResultPhoto>(id, title, description, thumbnail_url, photo_url,
|
||||
photo_width, photo_height, std::move(reply_markup),
|
||||
@ -8105,9 +8107,9 @@ td::Result<td_api::object_ptr<td_api::InputInlineQueryResult>> Client::get_inlin
|
||||
}
|
||||
|
||||
if (input_message_content == nullptr) {
|
||||
input_message_content =
|
||||
make_object<td_api::inputMessageVideo>(nullptr, nullptr, td::vector<int32>(), video_duration, video_width,
|
||||
video_height, false, std::move(caption), false, nullptr, false);
|
||||
input_message_content = make_object<td_api::inputMessageVideo>(
|
||||
nullptr, nullptr, td::vector<int32>(), video_duration, video_width, video_height, false, std::move(caption),
|
||||
show_caption_above_media, nullptr, false);
|
||||
}
|
||||
return make_object<td_api::inputInlineQueryResultVideo>(id, title, description, thumbnail_url, video_url, mime_type,
|
||||
video_width, video_height, video_duration,
|
||||
@ -9070,6 +9072,7 @@ td::Result<td_api::object_ptr<td_api::InputMessageContent>> 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<td_api::object_ptr<td_api::InputMessageContent>> Client::get_input_me
|
||||
TRY_RESULT(type, object.get_required_string_field("type"));
|
||||
if (type == "photo") {
|
||||
return make_object<td_api::inputMessagePhoto>(std::move(input_file), nullptr, td::vector<int32>(), 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<td_api::object_ptr<td_api::InputMessageContent>> Client::get_input_me
|
||||
|
||||
return make_object<td_api::inputMessageVideo>(std::move(input_file), std::move(input_thumbnail),
|
||||
td::vector<int32>(), 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<td_api::object_ptr<td_api::InputMessageContent>> Client::get_input_me
|
||||
duration = td::clamp(duration, 0, MAX_DURATION);
|
||||
return make_object<td_api::inputMessageAnimation>(std::move(input_file), std::move(input_thumbnail),
|
||||
td::vector<int32>(), 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,10 +9777,11 @@ 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<td_api::inputMessageAnimation>(std::move(animation), std::move(thumbnail), td::vector<int32>(),
|
||||
duration, width, height, std::move(caption), false, has_spoiler),
|
||||
do_send_message(make_object<td_api::inputMessageAnimation>(std::move(animation), std::move(thumbnail),
|
||||
td::vector<int32>(), duration, width, height,
|
||||
std::move(caption), show_caption_above_media, has_spoiler),
|
||||
std::move(query));
|
||||
return td::Status::OK();
|
||||
}
|
||||
@ -9824,9 +9828,11 @@ 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<td_api::inputMessagePhoto>(std::move(photo), nullptr, td::vector<int32>(), 0, 0,
|
||||
std::move(caption), false, nullptr, has_spoiler),
|
||||
do_send_message(
|
||||
make_object<td_api::inputMessagePhoto>(std::move(photo), nullptr, td::vector<int32>(), 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<td_api::inputMessageVideo>(std::move(video), std::move(thumbnail), td::vector<int32>(),
|
||||
duration, width, height, supports_streaming,
|
||||
std::move(caption), false, nullptr, has_spoiler),
|
||||
do_send_message(make_object<td_api::inputMessageVideo>(
|
||||
std::move(video), std::move(thumbnail), td::vector<int32>(), duration, width, height,
|
||||
supports_streaming, std::move(caption), show_caption_above_media, nullptr, has_spoiler),
|
||||
std::move(query));
|
||||
return td::Status::OK();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user