Add class inputTextQuote.

This commit is contained in:
levlam 2023-11-28 18:16:04 +03:00
parent c9e83daec6
commit c5288258d4
6 changed files with 34 additions and 26 deletions

View File

@ -1245,6 +1245,12 @@ messageSendingStatePending sending_id:int32 = MessageSendingState;
messageSendingStateFailed error:error can_retry:Bool need_another_sender:Bool need_another_reply_quote:Bool need_drop_reply:Bool retry_after:double = MessageSendingState;
//@description Describes manually chosen quote from another message
//@text Text of the quote; 0-getOption("message_reply_quote_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Spoiler, and CustomEmoji entities are allowed to be kept and must be kept in the quote
//@position Quote position in the original message in UTF-16 code units
inputTextQuote text:formattedText position:int32 = InputTextQuote;
//@class MessageReplyTo @description Contains information about the message or the story a message is replying to
//@description Describes a message replied by a given message
@ -1269,10 +1275,8 @@ messageReplyToStory story_sender_chat_id:int53 story_id:int32 = MessageReplyTo;
//@description Describes a message to be replied
//@chat_id The identifier of the chat to which the message to be replied belongs; pass 0 if the message to be replied is in the same chat. Must always be 0 for replies in secret chats. A message can be replied in another chat or topic only if message.can_be_replied_in_another_chat
//@message_id The identifier of the message to be replied in the same or the specified chat
//@quote Manually chosen quote from the message to be replied; pass null if none; 0-getOption("message_reply_quote_length_max") characters. Must always be null for replies in secret chats.
//-Only Bold, Italic, Underline, Strikethrough, Spoiler, and CustomEmoji entities are allowed to be kept and must be kept in the quote
//@quote_position Quote position in UTF-16 code units
inputMessageReplyToMessage chat_id:int53 message_id:int53 quote:formattedText quote_position:int32 = InputMessageReplyTo;
//@quote Quote from the message to be replied; pass null if none. Must always be null for replies in secret chats
inputMessageReplyToMessage chat_id:int53 message_id:int53 quote:inputTextQuote = InputMessageReplyTo;
//@description Describes a story to be replied @story_sender_chat_id The identifier of the sender of the story. Currently, stories can be replied only in the sender's chat @story_id The identifier of the story
inputMessageReplyToStory story_sender_chat_id:int53 story_id:int32 = InputMessageReplyTo;
@ -7148,8 +7152,7 @@ forwardMessages chat_id:int53 message_thread_id:int53 from_chat_id:int53 message
//@chat_id Identifier of the chat to send messages
//@message_ids Identifiers of the messages to resend. Message identifiers must be in a strictly increasing order
//@quote New manually chosen quote from the message to be replied; pass null if none. Ignored if more than one message is re-sent, or if messageSendingStateFailed.need_another_reply_quote == false
//@quote_position New quote position in UTF-16 code units
resendMessages chat_id:int53 message_ids:vector<int53> quote:formattedText quote_position:int32 = Messages;
resendMessages chat_id:int53 message_ids:vector<int53> quote:inputTextQuote = Messages;
//@description Adds a local message to a chat. The message is persistent across application restarts only if the message database is used. Returns the added message
//@chat_id Target chat

View File

@ -148,13 +148,13 @@ td_api::object_ptr<td_api::InputMessageReplyTo> MessageInputReplyTo::get_input_m
if (!message_id_.is_valid() && !message_id_.is_valid_scheduled()) {
return nullptr;
}
td_api::object_ptr<td_api::formattedText> quote;
td_api::object_ptr<td_api::inputTextQuote> quote;
if (!quote_.text.empty()) {
quote = get_formatted_text_object(quote_, true, -1);
quote = td_api::make_object<td_api::inputTextQuote>(get_formatted_text_object(quote_, true, -1), quote_position_);
}
return td_api::make_object<td_api::inputMessageReplyToMessage>(
td->messages_manager_->get_chat_id_object(dialog_id_, "inputMessageReplyToMessage"), message_id_.get(),
std::move(quote), quote_position_);
std::move(quote));
}
MessageId MessageInputReplyTo::get_same_chat_reply_to_message_id() const {

View File

@ -24658,11 +24658,13 @@ MessageInputReplyTo MessagesManager::get_message_input_reply_to(
}
FormattedText quote;
int32 quote_position = 0;
auto r_quote = get_formatted_text(td_, get_my_dialog_id(), std::move(reply_to_message->quote_),
td_->auth_manager_->is_bot(), true, true, true);
if (r_quote.is_ok() && d->dialog_id.get_type() != DialogType::SecretChat) {
quote = r_quote.move_as_ok();
quote_position = reply_to_message->quote_position_;
if (reply_to_message->quote_ != nullptr) {
auto r_quote = get_formatted_text(td_, get_my_dialog_id(), std::move(reply_to_message->quote_->text_),
td_->auth_manager_->is_bot(), true, true, true);
if (r_quote.is_ok() && d->dialog_id.get_type() != DialogType::SecretChat) {
quote = r_quote.move_as_ok();
quote_position = reply_to_message->quote_->position_;
}
}
const Message *m = get_message_force(reply_d, message_id, "get_message_input_reply_to 2");
if (m == nullptr || m->message_id.is_yet_unsent() ||
@ -28401,8 +28403,7 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
}
Result<vector<MessageId>> MessagesManager::resend_messages(DialogId dialog_id, vector<MessageId> message_ids,
td_api::object_ptr<td_api::formattedText> &&quote,
int32 quote_position) {
td_api::object_ptr<td_api::inputTextQuote> &&quote) {
if (message_ids.empty()) {
return Status::Error(400, "There are no messages to resend");
}
@ -28498,10 +28499,10 @@ Result<vector<MessageId>> MessagesManager::resend_messages(DialogId dialog_id, v
if (need_another_reply_quote && message_ids.size() == 1 && quote != nullptr) {
CHECK(message->input_reply_to.is_valid());
CHECK(message->input_reply_to.has_quote()); // checked in on_send_message_fail
auto r_quote =
get_formatted_text(td_, get_my_dialog_id(), std::move(quote), td_->auth_manager_->is_bot(), true, true, true);
auto r_quote = get_formatted_text(td_, get_my_dialog_id(), std::move(quote->text_), td_->auth_manager_->is_bot(),
true, true, true);
if (r_quote.is_ok()) {
message->input_reply_to.set_quote(r_quote.move_as_ok(), quote_position);
message->input_reply_to.set_quote(r_quote.move_as_ok(), quote->position_);
}
} else if (need_drop_reply) {
message->input_reply_to = {};

View File

@ -470,8 +470,7 @@ class MessagesManager final : public Actor {
vector<MessageCopyOptions> &&copy_options) TD_WARN_UNUSED_RESULT;
Result<vector<MessageId>> resend_messages(DialogId dialog_id, vector<MessageId> message_ids,
td_api::object_ptr<td_api::formattedText> &&quote,
int32 quote_position) TD_WARN_UNUSED_RESULT;
td_api::object_ptr<td_api::inputTextQuote> &&quote) TD_WARN_UNUSED_RESULT;
void set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Promise<Unit> &&promise);

View File

@ -5934,7 +5934,7 @@ void Td::on_request(uint64 id, td_api::forwardMessages &request) {
void Td::on_request(uint64 id, td_api::resendMessages &request) {
DialogId dialog_id(request.chat_id_);
auto r_message_ids = messages_manager_->resend_messages(dialog_id, MessageId::get_message_ids(request.message_ids_),
std::move(request.quote_), request.quote_position_);
std::move(request.quote_));
if (r_message_ids.is_error()) {
return send_closure(actor_id(this), &Td::send_error, id, r_message_ids.move_as_error());
}

View File

@ -925,8 +925,12 @@ class CliClient final : public Actor {
td_api::object_ptr<td_api::InputMessageReplyTo> get_input_message_reply_to() const {
if (reply_message_id_ != 0) {
return td_api::make_object<td_api::inputMessageReplyToMessage>(
reply_chat_id_, reply_message_id_, as_formatted_text(reply_quote_), reply_quote_position_);
td_api::object_ptr<td_api::inputTextQuote> quote;
if (!reply_quote_.empty()) {
quote = td_api::make_object<td_api::inputTextQuote>(as_formatted_text(reply_quote_), reply_quote_position_);
}
return td_api::make_object<td_api::inputMessageReplyToMessage>(reply_chat_id_, reply_message_id_,
std::move(quote));
}
if (reply_user_id_ != 0 || reply_story_id_ != 0) {
return td_api::make_object<td_api::inputMessageReplyToStory>(reply_user_id_, reply_story_id_);
@ -3728,8 +3732,9 @@ class CliClient final : public Actor {
string quote;
int32 quote_position;
get_args(args, chat_id, message_ids, quote, quote_position);
send_request(td_api::make_object<td_api::resendMessages>(chat_id, as_message_ids(message_ids),
as_formatted_text(quote), quote_position));
send_request(td_api::make_object<td_api::resendMessages>(
chat_id, as_message_ids(message_ids),
td_api::make_object<td_api::inputTextQuote>(as_formatted_text(quote), quote_position)));
} else if (op == "csc" || op == "CreateSecretChat") {
send_request(td_api::make_object<td_api::createSecretChat>(as_secret_chat_id(args)));
} else if (op == "cnsc" || op == "CreateNewSecretChat") {