Add messageCopyOptions.new_show_caption_above_media.

This commit is contained in:
levlam 2024-05-16 00:04:30 +03:00
parent 718c054d2c
commit ec5e2353c3
4 changed files with 22 additions and 9 deletions

View File

@ -3402,7 +3402,8 @@ messageSendOptions disable_notification:Bool from_background:Bool protect_conten
//@send_copy True, if content of the message needs to be copied without reference to the original sender. Always true if the message is forwarded to a secret chat or is local //@send_copy True, if content of the message needs to be copied without reference to the original sender. Always true if the message is forwarded to a secret chat or is local
//@replace_caption True, if media caption of the message copy needs to be replaced. Ignored if send_copy is false //@replace_caption True, if media caption of the message copy needs to be replaced. Ignored if send_copy is false
//@new_caption New message caption; pass null to copy message without caption. Ignored if replace_caption is false //@new_caption New message caption; pass null to copy message without caption. Ignored if replace_caption is false
messageCopyOptions send_copy:Bool replace_caption:Bool new_caption:formattedText = MessageCopyOptions; //@new_show_caption_above_media True, if new caption must be shown above the animation; otherwise new caption must be shown below the animation; not supported in secret chats. Ignored if replace_caption is false
messageCopyOptions send_copy:Bool replace_caption:Bool new_caption:formattedText new_show_caption_above_media:Bool = MessageCopyOptions;
//@class InputMessageContent @description The content of a message to send //@class InputMessageContent @description The content of a message to send

View File

@ -18,6 +18,7 @@ namespace td {
struct MessageCopyOptions { struct MessageCopyOptions {
bool send_copy = false; bool send_copy = false;
bool replace_caption = false; bool replace_caption = false;
bool new_invert_media = false;
FormattedText new_caption; FormattedText new_caption;
MessageInputReplyTo input_reply_to; MessageInputReplyTo input_reply_to;
unique_ptr<ReplyMarkup> reply_markup; unique_ptr<ReplyMarkup> reply_markup;
@ -41,7 +42,8 @@ inline StringBuilder &operator<<(StringBuilder &string_builder, MessageCopyOptio
if (copy_options.send_copy) { if (copy_options.send_copy) {
string_builder << "CopyOptions[replace_caption = " << copy_options.replace_caption; string_builder << "CopyOptions[replace_caption = " << copy_options.replace_caption;
if (copy_options.replace_caption) { if (copy_options.replace_caption) {
string_builder << ", new_caption = " << copy_options.new_caption; string_builder << ", new_caption = " << copy_options.new_caption
<< ", new_show_caption_above_media = " << copy_options.new_invert_media;
} }
if (copy_options.input_reply_to.is_valid()) { if (copy_options.input_reply_to.is_valid()) {
string_builder << ", in reply to " << copy_options.input_reply_to; string_builder << ", in reply to " << copy_options.input_reply_to;

View File

@ -23598,6 +23598,10 @@ Result<InputMessageContent> MessagesManager::process_input_message_content(
return Status::Error(400, "Message copying is restricted"); return Status::Error(400, "Message copying is restricted");
} }
auto new_invert_media =
copy_options.replace_caption && is_allowed_invert_caption_message_content(copied_message->content->get_type())
? copy_options.new_invert_media
: copied_message->invert_media;
unique_ptr<MessageContent> content = dup_message_content(td_, dialog_id, copied_message->content.get(), unique_ptr<MessageContent> content = dup_message_content(td_, dialog_id, copied_message->content.get(),
MessageContentDupType::Copy, std::move(copy_options)); MessageContentDupType::Copy, std::move(copy_options));
if (content == nullptr) { if (content == nullptr) {
@ -23605,7 +23609,7 @@ Result<InputMessageContent> MessagesManager::process_input_message_content(
} }
return InputMessageContent(std::move(content), get_message_disable_web_page_preview(copied_message), return InputMessageContent(std::move(content), get_message_disable_web_page_preview(copied_message),
copied_message->invert_media, false, MessageSelfDestructType(), UserId(), new_invert_media, false, MessageSelfDestructType(), UserId(),
copied_message->send_emoji); copied_message->send_emoji);
} }
@ -23630,6 +23634,7 @@ Result<MessageCopyOptions> MessagesManager::process_message_copy_options(
if (result.replace_caption) { if (result.replace_caption) {
TRY_RESULT_ASSIGN(result.new_caption, get_formatted_text(td_, dialog_id, std::move(options->new_caption_), TRY_RESULT_ASSIGN(result.new_caption, get_formatted_text(td_, dialog_id, std::move(options->new_caption_),
td_->auth_manager_->is_bot(), true, false, false)); td_->auth_manager_->is_bot(), true, false, false));
result.new_invert_media = options->new_show_caption_above_media_;
} }
return std::move(result); return std::move(result);
} }
@ -26293,6 +26298,10 @@ Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messag
: MessageContentDupType::Forward; : MessageContentDupType::Forward;
auto input_reply_to = std::move(copy_options[i].input_reply_to); auto input_reply_to = std::move(copy_options[i].input_reply_to);
auto reply_markup = std::move(copy_options[i].reply_markup); auto reply_markup = std::move(copy_options[i].reply_markup);
auto new_invert_media = is_local_copy && copy_options[i].replace_caption &&
is_allowed_invert_caption_message_content(forwarded_message->content->get_type())
? copy_options[i].new_invert_media
: forwarded_message->invert_media;
unique_ptr<MessageContent> content = unique_ptr<MessageContent> content =
dup_message_content(td_, to_dialog_id, forwarded_message->content.get(), type, std::move(copy_options[i])); dup_message_content(td_, to_dialog_id, forwarded_message->content.get(), type, std::move(copy_options[i]));
if (content == nullptr) { if (content == nullptr) {
@ -26335,13 +26344,13 @@ Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messag
if (is_local_copy) { if (is_local_copy) {
auto original_reply_to_message_id = auto original_reply_to_message_id =
forwarded_message->replied_message_info.get_same_chat_reply_to_message_id(true); forwarded_message->replied_message_info.get_same_chat_reply_to_message_id(true);
copied_messages.push_back( copied_messages.push_back({std::move(content), std::move(input_reply_to), forwarded_message->message_id,
{std::move(content), std::move(input_reply_to), forwarded_message->message_id, original_reply_to_message_id, original_reply_to_message_id, std::move(reply_markup),
std::move(reply_markup), forwarded_message->media_album_id, forwarded_message->media_album_id,
get_message_disable_web_page_preview(forwarded_message), forwarded_message->invert_media, i}); get_message_disable_web_page_preview(forwarded_message), new_invert_media, i});
} else { } else {
forwarded_message_contents.push_back( forwarded_message_contents.push_back(
{std::move(content), forwarded_message->invert_media, forwarded_message->media_album_id, i}); {std::move(content), new_invert_media, forwarded_message->media_album_id, i});
} }
} }
result.top_thread_message_id = top_thread_message_id; result.top_thread_message_id = top_thread_message_id;

View File

@ -5290,7 +5290,8 @@ class CliClient final : public Actor {
get_args(args, chat_id, from_chat_id, from_message_id); get_args(args, chat_id, from_chat_id, from_message_id);
td_api::object_ptr<td_api::messageCopyOptions> copy_options; td_api::object_ptr<td_api::messageCopyOptions> copy_options;
if (op == "scopy") { if (op == "scopy") {
copy_options = td_api::make_object<td_api::messageCopyOptions>(true, rand_bool(), as_caption("_as_d")); copy_options = td_api::make_object<td_api::messageCopyOptions>(true, rand_bool(), as_caption("_as_d"),
show_caption_above_media_);
} }
send_message(chat_id, td_api::make_object<td_api::inputMessageForwarded>(from_chat_id, from_message_id, true, send_message(chat_id, td_api::make_object<td_api::inputMessageForwarded>(from_chat_id, from_message_id, true,
std::move(copy_options))); std::move(copy_options)));