Introduce common SendMessageOptions for send message requests.

GitOrigin-RevId: 3cef644b80ec3641a9f15de7a5af13f90a9c7d94
This commit is contained in:
levlam 2019-12-06 02:32:23 +03:00
parent 797a117b60
commit a3301ae07c
8 changed files with 125 additions and 80 deletions

View File

@ -1487,6 +1487,12 @@ messageSchedulingStateSendAtDate send_date:int32 = MessageSchedulingState;
messageSchedulingStateSendWhenOnline = MessageSchedulingState;
//@description Options to be used when a message is send
//@disable_notification Pass true to disable notification for the message. Must be false if the message is sent to a secret chat
//@from_background Pass true if the message is sent from the background
sendMessageOptions disable_notification:Bool from_background:Bool = SendMessageOptions;
//@class InputMessageContent @description The content of a message to send
//@description A text message @text Formatted text to be sent; 1-GetOption("message_text_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Code, Pre, PreCode, TextUrl and MentionName entities are allowed to be specified manually
@ -3253,33 +3259,36 @@ getMessageLink chat_id:int53 message_id:int53 = HttpUrl;
getMessageLinkInfo url:string = MessageLinkInfo;
//@description Sends a message. Returns the sent message @chat_id Target chat @reply_to_message_id Identifier of the message to reply to or 0
//@disable_notification Pass true to disable notification for the message. Not supported in secret chats @from_background Pass true if the message is sent from the background
//@description Sends a message. Returns the sent message
//@chat_id Target chat @reply_to_message_id Identifier of the message to reply to or 0
//@options Options to be used to send the message
//@reply_markup Markup for replying to the message; for bots only @input_message_content The content of the message to be sent
sendMessage chat_id:int53 reply_to_message_id:int53 disable_notification:Bool from_background:Bool reply_markup:ReplyMarkup input_message_content:InputMessageContent = Message;
sendMessage chat_id:int53 reply_to_message_id:int53 options:sendMessageOptions reply_markup:ReplyMarkup input_message_content:InputMessageContent = Message;
//@description Sends messages grouped together into an album. Currently only photo and video messages can be grouped into an album. Returns sent messages @chat_id Target chat @reply_to_message_id Identifier of a message to reply to or 0
//@disable_notification Pass true to disable notification for the messages. Not supported in secret chats @from_background Pass true if the messages are sent from the background
//@description Sends messages grouped together into an album. Currently only photo and video messages can be grouped into an album. Returns sent messages
//@chat_id Target chat @reply_to_message_id Identifier of a message to reply to or 0
//@options Options to be used to send the messages
//@input_message_contents Contents of messages to be sent
sendMessageAlbum chat_id:int53 reply_to_message_id:int53 disable_notification:Bool from_background:Bool input_message_contents:vector<InputMessageContent> = Messages;
sendMessageAlbum chat_id:int53 reply_to_message_id:int53 options:sendMessageOptions input_message_contents:vector<InputMessageContent> = Messages;
//@description Invites a bot to a chat (if it is not yet a member) and sends it the /start command. Bots can't be invited to a private chat other than the chat with the bot. Bots can't be invited to channels (although they can be added as admins) and secret chats. Returns the sent message
//@bot_user_id Identifier of the bot @chat_id Identifier of the target chat @parameter A hidden parameter sent to the bot for deep linking purposes (https://core.telegram.org/bots#deep-linking)
sendBotStartMessage bot_user_id:int32 chat_id:int53 parameter:string = Message;
//@description Sends the result of an inline query as a message. Returns the sent message. Always clears a chat draft message @chat_id Target chat @reply_to_message_id Identifier of a message to reply to or 0
//@disable_notification Pass true to disable notification for the message. Not supported in secret chats @from_background Pass true if the message is sent from background
//@description Sends the result of an inline query as a message. Returns the sent message. Always clears a chat draft message
//@chat_id Target chat @reply_to_message_id Identifier of a message to reply to or 0
//@options Options to be used to send the message
//@query_id Identifier of the inline query @result_id Identifier of the inline result
//@hide_via_bot If true, there will be no mention of a bot, via which the message is sent. Can be used only for bots GetOption("animation_search_bot_username"), GetOption("photo_search_bot_username") and GetOption("venue_search_bot_username")
sendInlineQueryResultMessage chat_id:int53 reply_to_message_id:int53 disable_notification:Bool from_background:Bool query_id:int64 result_id:string hide_via_bot:Bool = Message;
sendInlineQueryResultMessage chat_id:int53 reply_to_message_id:int53 options:sendMessageOptions query_id:int64 result_id:string hide_via_bot:Bool = Message;
//@description Forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can't be forwarded, null will be returned instead of the message
//@chat_id Identifier of the chat to which to forward messages @from_chat_id Identifier of the chat from which to forward messages @message_ids Identifiers of the messages to forward
//@disable_notification Pass true to disable notification for the message, doesn't work if messages are forwarded to a secret chat @from_background Pass true if the messages are sent from the background
//@options Options to be used to send the messages
//@as_album True, if the messages should be grouped into an album after forwarding. For this to work, no more than 10 messages may be forwarded, and all of them must be photo or video messages
//@send_copy True, if content of the messages needs to be copied without links to the original messages. Always true if the messages are forwarded to a secret chat
//@remove_caption True, if media captions of message copies needs to be removed. Ignored if send_copy is false
forwardMessages chat_id:int53 from_chat_id:int53 message_ids:vector<int53> disable_notification:Bool from_background:Bool as_album:Bool send_copy:Bool remove_caption:Bool = Messages;
forwardMessages chat_id:int53 from_chat_id:int53 message_ids:vector<int53> options:sendMessageOptions as_album:Bool send_copy:Bool remove_caption:Bool = Messages;
//@description Resends messages which failed to send. Can be called only for messages for which messageSendingStateFailed.can_retry is true and after specified in messageSendingStateFailed.retry_after time passed.
//-If a message is re-sent, the corresponding failed to send message is deleted. Returns the sent messages in the same order as the message identifiers passed in message_ids. If a message can't be re-sent, null will be returned instead of the message

Binary file not shown.

View File

@ -17280,7 +17280,7 @@ tl_object_ptr<td_api::messages> MessagesManager::get_messages_object(
}
MessagesManager::Message *MessagesManager::get_message_to_send(Dialog *d, MessageId reply_to_message_id,
bool disable_notification, bool from_background,
const SendMessageOptions &options,
unique_ptr<MessageContent> &&content,
bool *need_update_dialog_pos,
unique_ptr<MessageForwardInfo> forward_info) {
@ -17313,13 +17313,13 @@ MessagesManager::Message *MessagesManager::get_message_to_send(Dialog *d, Messag
m->reply_to_message_id = reply_to_message_id;
m->is_channel_post = is_channel_post;
m->is_outgoing = is_scheduled || dialog_id != DialogId(my_id);
m->from_background = from_background;
m->from_background = options.from_background;
m->views = is_channel_post ? 1 : 0;
m->content = std::move(content);
m->forward_info = std::move(forward_info);
if (td_->auth_manager_->is_bot() || disable_notification) {
m->disable_notification = disable_notification;
if (td_->auth_manager_->is_bot() || options.disable_notification) {
m->disable_notification = options.disable_notification;
} else {
auto notification_settings = get_dialog_notification_settings(dialog_id, true);
CHECK(notification_settings != nullptr);
@ -17846,7 +17846,7 @@ class MessagesManager::SendMessageLogEvent {
};
Result<MessageId> MessagesManager::send_message(DialogId dialog_id, MessageId reply_to_message_id,
bool disable_notification, bool from_background,
tl_object_ptr<td_api::sendMessageOptions> &&options,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) {
if (input_message_content == nullptr) {
@ -17857,8 +17857,8 @@ Result<MessageId> MessagesManager::send_message(DialogId dialog_id, MessageId re
if (input_message_content->get_id() == td_api::inputMessageForwarded::ID) {
auto input_message = static_cast<const td_api::inputMessageForwarded *>(input_message_content.get());
return forward_message(dialog_id, DialogId(input_message->from_chat_id_), MessageId(input_message->message_id_),
disable_notification, from_background, input_message->in_game_share_,
input_message->send_copy_, input_message->remove_caption_);
std::move(options), input_message->in_game_share_, input_message->send_copy_,
input_message->remove_caption_);
}
Dialog *d = get_dialog_force(dialog_id);
@ -17869,13 +17869,14 @@ Result<MessageId> MessagesManager::send_message(DialogId dialog_id, MessageId re
TRY_STATUS(can_send_message(dialog_id));
TRY_RESULT(message_reply_markup, get_dialog_reply_markup(dialog_id, std::move(reply_markup)));
TRY_RESULT(message_content, process_input_message_content(dialog_id, std::move(input_message_content)));
TRY_RESULT(send_message_options, process_send_message_options(dialog_id, std::move(options)));
// there must be no errors after get_message_to_send call
bool need_update_dialog_pos = false;
Message *m = get_message_to_send(
d, get_reply_to_message_id(d, reply_to_message_id), disable_notification, from_background,
dup_message_content(td_, dialog_id, message_content.content.get(), false), &need_update_dialog_pos);
Message *m = get_message_to_send(d, get_reply_to_message_id(d, reply_to_message_id), send_message_options,
dup_message_content(td_, dialog_id, message_content.content.get(), false),
&need_update_dialog_pos);
m->reply_markup = std::move(message_reply_markup);
m->via_bot_user_id = message_content.via_bot_user_id;
m->disable_web_page_preview = message_content.disable_web_page_preview;
@ -17958,6 +17959,22 @@ Result<InputMessageContent> MessagesManager::process_input_message_content(
return std::move(content);
}
Result<MessagesManager::SendMessageOptions> MessagesManager::process_send_message_options(
DialogId dialog_id, tl_object_ptr<td_api::sendMessageOptions> &&options) {
SendMessageOptions result;
if (options != nullptr) {
result.disable_notification = options->disable_notification_;
result.from_background = options->from_background_;
}
bool is_secret = dialog_id.get_type() == DialogType::SecretChat;
if (result.disable_notification && is_secret) {
return Status::Error(400, "Can't send messages with silent notifications to secret chats");
}
return result;
}
int64 MessagesManager::generate_new_media_album_id() {
int64 media_album_id = 0;
do {
@ -17967,7 +17984,7 @@ int64 MessagesManager::generate_new_media_album_id() {
}
Result<vector<MessageId>> MessagesManager::send_message_group(
DialogId dialog_id, MessageId reply_to_message_id, bool disable_notification, bool from_background,
DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr<td_api::sendMessageOptions> &&options,
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents) {
if (input_message_contents.size() > MAX_GROUPED_MESSAGES) {
return Status::Error(4, "Too much messages to send as an album");
@ -17982,6 +17999,7 @@ Result<vector<MessageId>> MessagesManager::send_message_group(
}
TRY_STATUS(can_send_message(dialog_id));
TRY_RESULT(send_message_options, process_send_message_options(dialog_id, std::move(options)));
vector<std::pair<unique_ptr<MessageContent>, int32>> message_contents;
for (auto &input_message_content : input_message_contents) {
@ -18005,7 +18023,7 @@ Result<vector<MessageId>> MessagesManager::send_message_group(
vector<MessageId> result;
bool need_update_dialog_pos = false;
for (auto &message_content : message_contents) {
Message *m = get_message_to_send(d, reply_to_message_id, disable_notification, from_background,
Message *m = get_message_to_send(d, reply_to_message_id, send_message_options,
dup_message_content(td_, dialog_id, message_content.first.get(), false),
&need_update_dialog_pos);
result.push_back(m->message_id);
@ -18618,7 +18636,7 @@ Result<MessageId> MessagesManager::send_bot_start_message(UserId bot_user_id, Di
vector<MessageEntity> text_entities;
text_entities.emplace_back(MessageEntity::Type::BotCommand, 0, narrow_cast<int32>(text.size()));
bool need_update_dialog_pos = false;
Message *m = get_message_to_send(d, MessageId(), false, false,
Message *m = get_message_to_send(d, MessageId(), SendMessageOptions(),
create_text_message_content(text, std::move(text_entities), WebPageId()),
&need_update_dialog_pos);
m->is_bot_start_message = true;
@ -18698,7 +18716,7 @@ void MessagesManager::do_send_bot_start_message(UserId bot_user_id, DialogId dia
}
Result<MessageId> MessagesManager::send_inline_query_result_message(DialogId dialog_id, MessageId reply_to_message_id,
bool disable_notification, bool from_background,
tl_object_ptr<td_api::sendMessageOptions> &&options,
int64 query_id, const string &result_id,
bool hide_via_bot) {
LOG(INFO) << "Begin to send inline query result message to " << dialog_id << " in reply to " << reply_to_message_id;
@ -18709,6 +18727,7 @@ Result<MessageId> MessagesManager::send_inline_query_result_message(DialogId dia
}
TRY_STATUS(can_send_message(dialog_id));
TRY_RESULT(send_message_options, process_send_message_options(dialog_id, std::move(options)));
bool to_secret = false;
switch (dialog_id.get_type()) {
case DialogType::User:
@ -18739,9 +18758,9 @@ Result<MessageId> MessagesManager::send_inline_query_result_message(DialogId dia
TRY_STATUS(can_send_message_content(dialog_id, content->message_content.get(), false, true));
bool need_update_dialog_pos = false;
Message *m = get_message_to_send(
d, get_reply_to_message_id(d, reply_to_message_id), disable_notification, from_background,
dup_message_content(td_, dialog_id, content->message_content.get(), false), &need_update_dialog_pos);
Message *m = get_message_to_send(d, get_reply_to_message_id(d, reply_to_message_id), send_message_options,
dup_message_content(td_, dialog_id, content->message_content.get(), false),
&need_update_dialog_pos);
m->hide_via_bot = hide_via_bot;
if (!hide_via_bot) {
m->via_bot_user_id = td_->inline_queries_manager_->get_inline_bot_user_id(query_id);
@ -20147,10 +20166,10 @@ void MessagesManager::do_forward_messages(DialogId to_dialog_id, DialogId from_d
}
Result<MessageId> MessagesManager::forward_message(DialogId to_dialog_id, DialogId from_dialog_id, MessageId message_id,
bool disable_notification, bool from_background, bool in_game_share,
bool send_copy, bool remove_caption) {
TRY_RESULT(result, forward_messages(to_dialog_id, from_dialog_id, {message_id}, disable_notification, from_background,
in_game_share, false, send_copy, remove_caption));
tl_object_ptr<td_api::sendMessageOptions> &&options,
bool in_game_share, bool send_copy, bool remove_caption) {
TRY_RESULT(result, forward_messages(to_dialog_id, from_dialog_id, {message_id}, std::move(options), in_game_share,
false, send_copy, remove_caption));
CHECK(result.size() == 1);
auto sent_message_id = result[0];
if (sent_message_id == MessageId()) {
@ -20160,9 +20179,10 @@ Result<MessageId> MessagesManager::forward_message(DialogId to_dialog_id, Dialog
}
Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_id, DialogId from_dialog_id,
vector<MessageId> message_ids, bool disable_notification,
bool from_background, bool in_game_share, bool as_album,
bool send_copy, bool remove_caption) {
vector<MessageId> message_ids,
tl_object_ptr<td_api::sendMessageOptions> &&options,
bool in_game_share, bool as_album, bool send_copy,
bool remove_caption) {
if (message_ids.size() > 100) { // TODO replace with const from config or implement mass-forward
return Status::Error(4, "Too much messages to forward");
}
@ -20187,6 +20207,7 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
}
TRY_STATUS(can_send_message(to_dialog_id));
TRY_RESULT(send_message_options, process_send_message_options(to_dialog_id, std::move(options)));
for (auto message_id : message_ids) {
if (message_id.is_valid_scheduled()) {
@ -20290,7 +20311,7 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
}
}
Message *m = get_message_to_send(to_dialog, MessageId(), disable_notification, from_background, std::move(content),
Message *m = get_message_to_send(to_dialog, MessageId(), send_message_options, std::move(content),
&need_update_dialog_pos, std::move(forward_info));
m->real_forward_from_dialog_id = from_dialog_id;
m->real_forward_from_message_id = message_id;
@ -20388,8 +20409,8 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
}
for (auto &copied_message : copied_messages) {
Message *m = get_message_to_send(to_dialog, MessageId(), disable_notification, from_background,
std::move(copied_message.content), &need_update_dialog_pos);
Message *m = get_message_to_send(to_dialog, MessageId(), send_message_options, std::move(copied_message.content),
&need_update_dialog_pos);
m->disable_web_page_preview = copied_message.disable_web_page_preview;
m->media_album_id = media_album_id;
@ -20500,9 +20521,9 @@ Result<vector<MessageId>> MessagesManager::resend_messages(DialogId dialog_id, v
CHECK(message != nullptr);
send_update_delete_messages(dialog_id, {message->message_id.get()}, true, false);
Message *m =
get_message_to_send(d, get_reply_to_message_id(d, message->reply_to_message_id), message->disable_notification,
message->from_background, std::move(new_contents[i]), &need_update_dialog_pos);
SendMessageOptions options(message->disable_notification, message->from_background);
Message *m = get_message_to_send(d, get_reply_to_message_id(d, message->reply_to_message_id), options,
std::move(new_contents[i]), &need_update_dialog_pos);
m->reply_markup = std::move(message->reply_markup);
m->via_bot_user_id = message->via_bot_user_id;
m->disable_web_page_preview = message->disable_web_page_preview;
@ -20544,7 +20565,7 @@ Result<MessageId> MessagesManager::send_dialog_set_ttl_message(DialogId dialog_i
TRY_STATUS(can_send_message(dialog_id));
bool need_update_dialog_pos = false;
Message *m = get_message_to_send(d, MessageId(), false, false, create_chat_set_ttl_message_content(ttl),
Message *m = get_message_to_send(d, MessageId(), SendMessageOptions(), create_chat_set_ttl_message_content(ttl),
&need_update_dialog_pos);
send_update_new_message(d, m);
@ -20577,8 +20598,8 @@ Status MessagesManager::send_screenshot_taken_notification_message(DialogId dial
if (dialog_type == DialogType::User) {
bool need_update_dialog_pos = false;
const Message *m = get_message_to_send(d, MessageId(), false, false, create_screenshot_taken_message_content(),
&need_update_dialog_pos);
const Message *m = get_message_to_send(d, MessageId(), SendMessageOptions(),
create_screenshot_taken_message_content(), &need_update_dialog_pos);
do_send_screenshot_taken_notification_message(dialog_id, m, 0);

View File

@ -351,26 +351,27 @@ class MessagesManager : public Actor {
DialogId search_public_dialog(const string &username_to_search, bool force, Promise<Unit> &&promise);
Result<MessageId> send_message(DialogId dialog_id, MessageId reply_to_message_id, bool disable_notification,
bool from_background, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content)
TD_WARN_UNUSED_RESULT;
Result<MessageId> send_message(
DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr<td_api::sendMessageOptions> &&options,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) TD_WARN_UNUSED_RESULT;
Result<vector<MessageId>> send_message_group(
DialogId dialog_id, MessageId reply_to_message_id, bool disable_notification, bool from_background,
DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr<td_api::sendMessageOptions> &&options,
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents) TD_WARN_UNUSED_RESULT;
Result<MessageId> send_bot_start_message(UserId bot_user_id, DialogId dialog_id,
const string &parameter) TD_WARN_UNUSED_RESULT;
Result<MessageId> send_inline_query_result_message(DialogId dialog_id, MessageId reply_to_message_id,
bool disable_notification, bool from_background, int64 query_id,
const string &result_id, bool hide_via_bot) TD_WARN_UNUSED_RESULT;
tl_object_ptr<td_api::sendMessageOptions> &&options,
int64 query_id, const string &result_id,
bool hide_via_bot) TD_WARN_UNUSED_RESULT;
Result<vector<MessageId>> forward_messages(DialogId to_dialog_id, DialogId from_dialog_id,
vector<MessageId> message_ids, bool disable_notification,
bool from_background, bool in_game_share, bool as_album, bool send_copy,
bool remove_caption) TD_WARN_UNUSED_RESULT;
vector<MessageId> message_ids,
tl_object_ptr<td_api::sendMessageOptions> &&options, bool in_game_share,
bool as_album, bool send_copy, bool remove_caption) TD_WARN_UNUSED_RESULT;
Result<vector<MessageId>> resend_messages(DialogId dialog_id, vector<MessageId> message_ids) TD_WARN_UNUSED_RESULT;
@ -1366,6 +1367,16 @@ class MessagesManager : public Actor {
Promise<> success_promise;
};
struct SendMessageOptions {
bool disable_notification = false;
bool from_background = false;
SendMessageOptions() = default;
SendMessageOptions(bool disable_notification, bool from_background)
: disable_notification(disable_notification), from_background(from_background) {
}
};
class ChangeDialogReportSpamStateOnServerLogEvent;
class DeleteAllChannelMessagesFromUserOnServerLogEvent;
class DeleteDialogHistoryFromServerLogEvent;
@ -1486,8 +1497,11 @@ class MessagesManager : public Actor {
Result<InputMessageContent> process_input_message_content(
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content);
Message *get_message_to_send(Dialog *d, MessageId reply_to_message_id, bool disable_notification,
bool from_background, unique_ptr<MessageContent> &&content, bool *need_update_dialog_pos,
Result<SendMessageOptions> process_send_message_options(DialogId dialog_id,
tl_object_ptr<td_api::sendMessageOptions> &&options);
Message *get_message_to_send(Dialog *d, MessageId reply_to_message_id, const SendMessageOptions &options,
unique_ptr<MessageContent> &&content, bool *need_update_dialog_pos,
unique_ptr<MessageForwardInfo> forward_info = nullptr);
int64 begin_send_message(DialogId dialog_id, const Message *m);
@ -1533,8 +1547,8 @@ class MessagesManager : public Actor {
const vector<MessageId> &message_ids, uint64 logevent_id);
Result<MessageId> forward_message(DialogId to_dialog_id, DialogId from_dialog_id, MessageId message_id,
bool disable_notification, bool from_background, bool in_game_share, bool send_copy,
bool remove_caption) TD_WARN_UNUSED_RESULT;
tl_object_ptr<td_api::sendMessageOptions> &&options, bool in_game_share,
bool send_copy, bool remove_caption) TD_WARN_UNUSED_RESULT;
void do_send_media(DialogId dialog_id, Message *m, FileId file_id, FileId thumbnail_file_id,
tl_object_ptr<telegram_api::InputFile> input_file,

View File

@ -5704,9 +5704,9 @@ void Td::on_request(uint64 id, const td_api::readAllChatMentions &request) {
void Td::on_request(uint64 id, td_api::sendMessage &request) {
DialogId dialog_id(request.chat_id_);
auto r_new_message_id = messages_manager_->send_message(
dialog_id, MessageId(request.reply_to_message_id_), request.disable_notification_, request.from_background_,
std::move(request.reply_markup_), std::move(request.input_message_content_));
auto r_new_message_id =
messages_manager_->send_message(dialog_id, MessageId(request.reply_to_message_id_), std::move(request.options_),
std::move(request.reply_markup_), std::move(request.input_message_content_));
if (r_new_message_id.is_error()) {
return send_closure(actor_id(this), &Td::send_error, id, r_new_message_id.move_as_error());
}
@ -5718,9 +5718,9 @@ void Td::on_request(uint64 id, td_api::sendMessage &request) {
void Td::on_request(uint64 id, td_api::sendMessageAlbum &request) {
DialogId dialog_id(request.chat_id_);
auto r_message_ids = messages_manager_->send_message_group(dialog_id, MessageId(request.reply_to_message_id_),
request.disable_notification_, request.from_background_,
std::move(request.input_message_contents_));
auto r_message_ids =
messages_manager_->send_message_group(dialog_id, MessageId(request.reply_to_message_id_),
std::move(request.options_), std::move(request.input_message_contents_));
if (r_message_ids.is_error()) {
return send_closure(actor_id(this), &Td::send_error, id, r_message_ids.move_as_error());
}
@ -5751,8 +5751,8 @@ void Td::on_request(uint64 id, td_api::sendInlineQueryResultMessage &request) {
DialogId dialog_id(request.chat_id_);
auto r_new_message_id = messages_manager_->send_inline_query_result_message(
dialog_id, MessageId(request.reply_to_message_id_), request.disable_notification_, request.from_background_,
request.query_id_, request.result_id_, request.hide_via_bot_);
dialog_id, MessageId(request.reply_to_message_id_), std::move(request.options_), request.query_id_,
request.result_id_, request.hide_via_bot_);
if (r_new_message_id.is_error()) {
return send_closure(actor_id(this), &Td::send_error, id, r_new_message_id.move_as_error());
}
@ -5906,12 +5906,11 @@ void Td::on_request(uint64 id, td_api::sendChatScreenshotTakenNotification &requ
answer_ok_query(id, messages_manager_->send_screenshot_taken_notification_message(DialogId(request.chat_id_)));
}
void Td::on_request(uint64 id, const td_api::forwardMessages &request) {
void Td::on_request(uint64 id, td_api::forwardMessages &request) {
DialogId dialog_id(request.chat_id_);
auto r_message_ids = messages_manager_->forward_messages(
dialog_id, DialogId(request.from_chat_id_), MessagesManager::get_message_ids(request.message_ids_),
request.disable_notification_, request.from_background_, false, request.as_album_, request.send_copy_,
request.remove_caption_);
std::move(request.options_), false, request.as_album_, request.send_copy_, request.remove_caption_);
if (r_message_ids.is_error()) {
return send_closure(actor_id(this), &Td::send_error, id, r_message_ids.move_as_error());
}

View File

@ -620,7 +620,7 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::sendChatScreenshotTakenNotification &request);
void on_request(uint64 id, const td_api::forwardMessages &request);
void on_request(uint64 id, td_api::forwardMessages &request);
void on_request(uint64 id, const td_api::resendMessages &request);

View File

@ -1276,7 +1276,9 @@ class CliClient final : public Actor {
bool disable_notification = false, bool from_background = false, int64 reply_to_message_id = 0) {
auto chat = as_chat_id(chat_id);
auto id = send_request(td_api::make_object<td_api::sendMessage>(
chat, reply_to_message_id, disable_notification, from_background, nullptr, std::move(input_message_content)));
chat, reply_to_message_id,
td_api::make_object<td_api::sendMessageOptions>(disable_notification, from_background), nullptr,
std::move(input_message_content)));
query_id_to_send_message_info_[id].start_time = Time::now();
}
@ -2539,7 +2541,7 @@ class CliClient final : public Actor {
auto chat = as_chat_id(chat_id);
send_request(td_api::make_object<td_api::forwardMessages>(chat, as_chat_id(from_chat_id),
as_message_ids(message_ids), false, false, op[2] == 'g',
as_message_ids(message_ids), nullptr, op[2] == 'g',
op[0] == 'c', Random::fast(0, 1) == 1));
} else if (op == "resend") {
string chat_id;
@ -2791,7 +2793,7 @@ class CliClient final : public Actor {
photos = full_split(args);
send_request(td_api::make_object<td_api::sendMessageAlbum>(
as_chat_id(chat_id), as_message_id(reply_to_message_id), false, false,
as_chat_id(chat_id), as_message_id(reply_to_message_id), nullptr,
transform(photos, [](const string &photo_path) {
td_api::object_ptr<td_api::InputMessageContent> content = td_api::make_object<td_api::inputMessagePhoto>(
as_input_file(photo_path), nullptr, Auto(), 0, 0, as_caption(""), 0);
@ -2920,7 +2922,7 @@ class CliClient final : public Actor {
auto chat = as_chat_id(chat_id);
send_request(td_api::make_object<td_api::sendInlineQueryResultMessage>(
chat, 0, false, false, to_integer<int64>(query_id), result_id, op == "siqrh"));
chat, 0, nullptr, to_integer<int64>(query_id), result_id, op == "siqrh"));
} else if (op == "gcqr") {
string chat_id;
string message_id;

View File

@ -309,7 +309,7 @@ class SetUsername : public Task {
auto chat = move_tl_object_as<td_api::chat>(res);
this->send_query(
make_tl_object<td_api::sendMessage>(
chat->id_, 0, false, false, nullptr,
chat->id_, 0, nullptr, nullptr,
make_tl_object<td_api::inputMessageText>(
make_tl_object<td_api::formattedText>(PSTRING() << tag_ << " INIT", Auto()), false, false)),
[](auto res) {});
@ -376,7 +376,7 @@ class TestA : public Task {
auto chat = move_tl_object_as<td_api::chat>(res);
for (int i = 0; i < 20; i++) {
this->send_query(make_tl_object<td_api::sendMessage>(
chat->id_, 0, false, false, nullptr,
chat->id_, 0, nullptr, nullptr,
make_tl_object<td_api::inputMessageText>(
make_tl_object<td_api::formattedText>(PSTRING() << tag_ << " " << (1000 + i), Auto()),
false, false)),
@ -424,7 +424,7 @@ class TestSecretChat : public Task {
LOG(INFO) << "SEND ENCRYPTED MESSAGES";
for (int i = 0; i < 20; i++) {
send_query(make_tl_object<td_api::sendMessage>(
chat_id_, 0, false, false, nullptr,
chat_id_, 0, nullptr, nullptr,
make_tl_object<td_api::inputMessageText>(
make_tl_object<td_api::formattedText>(PSTRING() << tag_ << " " << (1000 + i), Auto()), false,
false)),
@ -486,7 +486,7 @@ class TestFileGenerated : public Task {
file.flush_write().ensure(); // important
file.close();
this->send_query(make_tl_object<td_api::sendMessage>(
chat_id_, 0, false, false, nullptr,
chat_id_, 0, nullptr, nullptr,
make_tl_object<td_api::inputMessageDocument>(
make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0),
make_tl_object<td_api::inputThumbnail>(
@ -495,7 +495,7 @@ class TestFileGenerated : public Task {
[](auto res) { check_td_error(res); });
this->send_query(
make_tl_object<td_api::sendMessage>(chat_id_, 0, false, false, nullptr,
make_tl_object<td_api::sendMessage>(chat_id_, 0, nullptr, nullptr,
make_tl_object<td_api::inputMessageDocument>(
make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0),
nullptr, make_tl_object<td_api::formattedText>(tag_, Auto()))),
@ -601,7 +601,7 @@ class CheckTestC : public Task {
void one_file() {
this->send_query(
make_tl_object<td_api::sendMessage>(
chat_id_, 0, false, false, nullptr,
chat_id_, 0, nullptr, nullptr,
make_tl_object<td_api::inputMessageText>(
make_tl_object<td_api::formattedText>(PSTRING() << tag_ << " ONE_FILE", Auto()), false, false)),
[](auto res) { check_td_error(res); });