diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 9734db81b..67dc12cd1 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1683,11 +1683,11 @@ messageSchedulingStateSendAtDate send_date:int32 = MessageSchedulingState; messageSchedulingStateSendWhenOnline = MessageSchedulingState; -//@description Options to be used when a message is send +//@description Options to be used when a message is sent //@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 //@scheduling_state Message scheduling state. Messages sent to a secret chat, live location messages and self-destructing messages can't be scheduled -sendMessageOptions disable_notification:Bool from_background:Bool scheduling_state:MessageSchedulingState = SendMessageOptions; +messageSendOptions disable_notification:Bool from_background:Bool scheduling_state:MessageSchedulingState = MessageSendOptions; //@description Options to be used when a message content is copied without a link to the original message //@send_copy True, if content of the message needs to be copied without a link to the original message. Always true if the message is forwarded to a secret chat @@ -3617,13 +3617,13 @@ getMessageLinkInfo url:string = MessageLinkInfo; //@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 options:sendMessageOptions reply_markup:ReplyMarkup input_message_content:InputMessageContent = Message; +sendMessage chat_id:int53 reply_to_message_id:int53 options:messageSendOptions 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 //@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 options:sendMessageOptions input_message_contents:vector = Messages; +sendMessageAlbum chat_id:int53 reply_to_message_id:int53 options:messageSendOptions input_message_contents:vector = 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) @@ -3634,7 +3634,7 @@ sendBotStartMessage bot_user_id:int32 chat_id:int53 parameter:string = Message; //@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 options:sendMessageOptions query_id:int64 result_id:string hide_via_bot:Bool = Message; +sendInlineQueryResultMessage chat_id:int53 reply_to_message_id:int53 options:messageSendOptions 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 @@ -3642,7 +3642,7 @@ sendInlineQueryResultMessage chat_id:int53 reply_to_message_id:int53 options:sen //@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 options:sendMessageOptions as_album:Bool send_copy:Bool remove_caption:Bool = Messages; +forwardMessages chat_id:int53 from_chat_id:int53 message_ids:vector options:messageSendOptions 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 diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 34c03096a..9dd8c6d95 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 420bc0dee..d1fb264c6 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -19998,7 +19998,7 @@ tl_object_ptr MessagesManager::get_messages_object( } MessagesManager::Message *MessagesManager::get_message_to_send( - Dialog *d, MessageId reply_to_message_id, const SendMessageOptions &options, unique_ptr &&content, + Dialog *d, MessageId reply_to_message_id, const MessageSendOptions &options, unique_ptr &&content, bool *need_update_dialog_pos, unique_ptr forward_info, bool is_copy) { CHECK(d != nullptr); CHECK(!reply_to_message_id.is_scheduled()); @@ -20527,7 +20527,7 @@ class MessagesManager::SendMessageLogEvent { }; Result MessagesManager::send_message(DialogId dialog_id, MessageId reply_to_message_id, - tl_object_ptr &&options, + tl_object_ptr &&options, tl_object_ptr &&reply_markup, tl_object_ptr &&input_message_content) { if (input_message_content == nullptr) { @@ -20550,13 +20550,13 @@ Result 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))); - TRY_STATUS(can_use_send_message_options(send_message_options, message_content)); + TRY_RESULT(message_send_options, process_message_send_options(dialog_id, std::move(options))); + TRY_STATUS(can_use_message_send_options(message_send_options, message_content)); // 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), send_message_options, + Message *m = get_message_to_send(d, get_reply_to_message_id(d, reply_to_message_id), message_send_options, dup_message_content(td_, dialog_id, message_content.content.get(), MessageContentDupType::Send, MessageCopyOptions()), &need_update_dialog_pos, nullptr, message_content.via_bot_user_id.is_valid()); @@ -20655,9 +20655,9 @@ Result MessagesManager::process_message_copy_options( return std::move(result); } -Result MessagesManager::process_send_message_options( - DialogId dialog_id, tl_object_ptr &&options) const { - SendMessageOptions result; +Result MessagesManager::process_message_send_options( + DialogId dialog_id, tl_object_ptr &&options) const { + MessageSendOptions result; if (options != nullptr) { result.disable_notification = options->disable_notification_; result.from_background = options->from_background_; @@ -20689,7 +20689,7 @@ Result MessagesManager::process_send_messag return result; } -Status MessagesManager::can_use_send_message_options(const SendMessageOptions &options, +Status MessagesManager::can_use_message_send_options(const MessageSendOptions &options, const unique_ptr &content, int32 ttl) { if (options.schedule_date != 0) { if (ttl > 0) { @@ -20703,9 +20703,9 @@ Status MessagesManager::can_use_send_message_options(const SendMessageOptions &o return Status::OK(); } -Status MessagesManager::can_use_send_message_options(const SendMessageOptions &options, +Status MessagesManager::can_use_message_send_options(const MessageSendOptions &options, const InputMessageContent &content) { - return can_use_send_message_options(options, content.content, content.ttl); + return can_use_message_send_options(options, content.content, content.ttl); } int64 MessagesManager::generate_new_media_album_id() { @@ -20717,7 +20717,7 @@ int64 MessagesManager::generate_new_media_album_id() { } Result> MessagesManager::send_message_group( - DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr &&options, + DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr &&options, vector> &&input_message_contents) { if (input_message_contents.size() > MAX_GROUPED_MESSAGES) { return Status::Error(4, "Too much messages to send as an album"); @@ -20732,12 +20732,12 @@ Result> 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))); + TRY_RESULT(message_send_options, process_message_send_options(dialog_id, std::move(options))); vector, int32>> message_contents; for (auto &input_message_content : input_message_contents) { TRY_RESULT(message_content, process_input_message_content(dialog_id, std::move(input_message_content))); - TRY_STATUS(can_use_send_message_options(send_message_options, message_content)); + TRY_STATUS(can_use_message_send_options(message_send_options, message_content)); if (!is_allowed_media_group_content(message_content.content->get_type())) { return Status::Error(5, "Wrong message content type"); } @@ -20757,7 +20757,7 @@ Result> MessagesManager::send_message_group( vector result; bool need_update_dialog_pos = false; for (auto &message_content : message_contents) { - Message *m = get_message_to_send(d, reply_to_message_id, send_message_options, + Message *m = get_message_to_send(d, reply_to_message_id, message_send_options, dup_message_content(td_, dialog_id, message_content.first.get(), MessageContentDupType::Send, MessageCopyOptions()), &need_update_dialog_pos); @@ -21387,7 +21387,7 @@ Result MessagesManager::send_bot_start_message(UserId bot_user_id, Di vector text_entities; text_entities.emplace_back(MessageEntity::Type::BotCommand, 0, narrow_cast(text.size())); bool need_update_dialog_pos = false; - Message *m = get_message_to_send(d, MessageId(), SendMessageOptions(), + Message *m = get_message_to_send(d, MessageId(), MessageSendOptions(), create_text_message_content(text, std::move(text_entities), WebPageId()), &need_update_dialog_pos); m->is_bot_start_message = true; @@ -21472,7 +21472,7 @@ void MessagesManager::do_send_bot_start_message(UserId bot_user_id, DialogId dia } Result MessagesManager::send_inline_query_result_message(DialogId dialog_id, MessageId reply_to_message_id, - tl_object_ptr &&options, + tl_object_ptr &&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; @@ -21483,7 +21483,7 @@ Result 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))); + TRY_RESULT(message_send_options, process_message_send_options(dialog_id, std::move(options))); bool to_secret = false; switch (dialog_id.get_type()) { case DialogType::User: @@ -21511,11 +21511,11 @@ Result MessagesManager::send_inline_query_result_message(DialogId dia return Status::Error(5, "Inline query result not found"); } - TRY_STATUS(can_use_send_message_options(send_message_options, content->message_content, 0)); + TRY_STATUS(can_use_message_send_options(message_send_options, content->message_content, 0)); TRY_STATUS(can_send_message_content(dialog_id, content->message_content.get(), false)); bool need_update_dialog_pos = false; - Message *m = get_message_to_send(d, get_reply_to_message_id(d, reply_to_message_id), send_message_options, + Message *m = get_message_to_send(d, get_reply_to_message_id(d, reply_to_message_id), message_send_options, dup_message_content(td_, dialog_id, content->message_content.get(), MessageContentDupType::SendViaBot, MessageCopyOptions()), &need_update_dialog_pos, nullptr, true); @@ -22925,7 +22925,7 @@ void MessagesManager::do_forward_messages(DialogId to_dialog_id, DialogId from_d } Result MessagesManager::forward_message(DialogId to_dialog_id, DialogId from_dialog_id, MessageId message_id, - tl_object_ptr &&options, + tl_object_ptr &&options, bool in_game_share, MessageCopyOptions &©_options) { vector all_copy_options; all_copy_options.push_back(std::move(copy_options)); @@ -22941,7 +22941,7 @@ Result MessagesManager::forward_message(DialogId to_dialog_id, Dialog Result> MessagesManager::forward_messages(DialogId to_dialog_id, DialogId from_dialog_id, vector message_ids, - tl_object_ptr &&options, + tl_object_ptr &&options, bool in_game_share, bool as_album, vector &©_options) { CHECK(copy_options.size() == message_ids.size()); @@ -22969,7 +22969,7 @@ Result> 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))); + TRY_RESULT(message_send_options, process_message_send_options(to_dialog_id, std::move(options))); for (auto message_id : message_ids) { if (message_id.is_valid_scheduled()) { @@ -23027,7 +23027,7 @@ Result> MessagesManager::forward_messages(DialogId to_dialog_i continue; } - auto can_use_options_status = can_use_send_message_options(send_message_options, content, 0); + auto can_use_options_status = can_use_message_send_options(message_send_options, content, 0); if (can_use_options_status.is_error()) { LOG(INFO) << "Can't forward " << message_id << ": " << can_send_status.message(); continue; @@ -23077,7 +23077,7 @@ Result> MessagesManager::forward_messages(DialogId to_dialog_i } } - Message *m = get_message_to_send(to_dialog, MessageId(), send_message_options, std::move(content), + Message *m = get_message_to_send(to_dialog, MessageId(), message_send_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; @@ -23175,7 +23175,7 @@ Result> MessagesManager::forward_messages(DialogId to_dialog_i } for (auto &copied_message : copied_messages) { - Message *m = get_message_to_send(to_dialog, MessageId(), send_message_options, std::move(copied_message.content), + Message *m = get_message_to_send(to_dialog, MessageId(), message_send_options, std::move(copied_message.content), &need_update_dialog_pos, nullptr, true); m->disable_web_page_preview = copied_message.disable_web_page_preview; m->media_album_id = media_album_id; @@ -23282,7 +23282,7 @@ Result> MessagesManager::resend_messages(DialogId dialog_id, v CHECK(message != nullptr); send_update_delete_messages(dialog_id, {message->message_id.get()}, true, false); - SendMessageOptions options(message->disable_notification, message->from_background, + MessageSendOptions options(message->disable_notification, message->from_background, get_message_schedule_date(message.get())); 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, nullptr, message->is_copy); @@ -23328,7 +23328,7 @@ Result 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(), SendMessageOptions(), create_chat_set_ttl_message_content(ttl), + Message *m = get_message_to_send(d, MessageId(), MessageSendOptions(), create_chat_set_ttl_message_content(ttl), &need_update_dialog_pos); send_update_new_message(d, m); @@ -23361,7 +23361,7 @@ 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(), SendMessageOptions(), + const Message *m = get_message_to_send(d, MessageId(), MessageSendOptions(), create_screenshot_taken_message_content(), &need_update_dialog_pos); do_send_screenshot_taken_notification_message(dialog_id, m, 0); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 8ac1169eb..2c70ae94a 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -368,25 +368,25 @@ class MessagesManager : public Actor { DialogId search_public_dialog(const string &username_to_search, bool force, Promise &&promise); Result send_message( - DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr &&options, + DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr &&options, tl_object_ptr &&reply_markup, tl_object_ptr &&input_message_content) TD_WARN_UNUSED_RESULT; Result> send_message_group( - DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr &&options, + DialogId dialog_id, MessageId reply_to_message_id, tl_object_ptr &&options, vector> &&input_message_contents) TD_WARN_UNUSED_RESULT; Result send_bot_start_message(UserId bot_user_id, DialogId dialog_id, const string ¶meter) TD_WARN_UNUSED_RESULT; Result send_inline_query_result_message(DialogId dialog_id, MessageId reply_to_message_id, - tl_object_ptr &&options, + tl_object_ptr &&options, int64 query_id, const string &result_id, bool hide_via_bot) TD_WARN_UNUSED_RESULT; Result> forward_messages(DialogId to_dialog_id, DialogId from_dialog_id, vector message_ids, - tl_object_ptr &&options, bool in_game_share, + tl_object_ptr &&options, bool in_game_share, bool as_album, vector &©_options) TD_WARN_UNUSED_RESULT; @@ -1507,13 +1507,13 @@ class MessagesManager : public Actor { Promise<> success_promise; }; - struct SendMessageOptions { + struct MessageSendOptions { bool disable_notification = false; bool from_background = false; int32 schedule_date = 0; - SendMessageOptions() = default; - SendMessageOptions(bool disable_notification, bool from_background, int32 schedule_date) + MessageSendOptions() = default; + MessageSendOptions(bool disable_notification, bool from_background, int32 schedule_date) : disable_notification(disable_notification), from_background(from_background), schedule_date(schedule_date) { } }; @@ -1654,14 +1654,14 @@ class MessagesManager : public Actor { Result process_message_copy_options(DialogId dialog_id, tl_object_ptr &&options) const; - Result process_send_message_options(DialogId dialog_id, - tl_object_ptr &&options) const; + Result process_message_send_options(DialogId dialog_id, + tl_object_ptr &&options) const; - static Status can_use_send_message_options(const SendMessageOptions &options, + static Status can_use_message_send_options(const MessageSendOptions &options, const unique_ptr &content, int32 ttl); - static Status can_use_send_message_options(const SendMessageOptions &options, const InputMessageContent &content); + static Status can_use_message_send_options(const MessageSendOptions &options, const InputMessageContent &content); - Message *get_message_to_send(Dialog *d, MessageId reply_to_message_id, const SendMessageOptions &options, + Message *get_message_to_send(Dialog *d, MessageId reply_to_message_id, const MessageSendOptions &options, unique_ptr &&content, bool *need_update_dialog_pos, unique_ptr forward_info = nullptr, bool is_copy = false); @@ -1708,7 +1708,7 @@ class MessagesManager : public Actor { const vector &message_ids, uint64 logevent_id); Result forward_message(DialogId to_dialog_id, DialogId from_dialog_id, MessageId message_id, - tl_object_ptr &&options, bool in_game_share, + tl_object_ptr &&options, bool in_game_share, MessageCopyOptions &©_options) TD_WARN_UNUSED_RESULT; void do_send_media(DialogId dialog_id, Message *m, FileId file_id, FileId thumbnail_file_id, diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 366046111..419ad7724 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1391,14 +1391,14 @@ class CliClient final : public Actor { auto chat = as_chat_id(chat_id); auto id = send_request(td_api::make_object( chat, reply_to_message_id, - td_api::make_object(disable_notification, from_background, + td_api::make_object(disable_notification, from_background, as_message_scheduling_state(schedule_date_)), nullptr, std::move(input_message_content))); query_id_to_send_message_info_[id].start_time = Time::now(); } - td_api::object_ptr default_send_message_options() const { - return td_api::make_object(false, false, as_message_scheduling_state(schedule_date_)); + td_api::object_ptr default_message_send_options() const { + return td_api::make_object(false, false, as_message_scheduling_state(schedule_date_)); } void send_get_background_url(td_api::object_ptr &&background_type) { @@ -2706,7 +2706,7 @@ class CliClient final : public Actor { auto chat = as_chat_id(chat_id); send_request(td_api::make_object( - chat, as_chat_id(from_chat_id), as_message_ids(message_ids), default_send_message_options(), op[2] == 'g', + chat, as_chat_id(from_chat_id), as_message_ids(message_ids), default_message_send_options(), op[2] == 'g', op[0] == 'c', Random::fast(0, 1) == 1)); } else if (op == "resend") { string chat_id; @@ -2967,7 +2967,7 @@ class CliClient final : public Actor { photos = full_split(args); send_request(td_api::make_object( - as_chat_id(chat_id), as_message_id(reply_to_message_id), default_send_message_options(), + as_chat_id(chat_id), as_message_id(reply_to_message_id), default_message_send_options(), transform(photos, [](const string &photo_path) { td_api::object_ptr content = td_api::make_object( as_input_file(photo_path), nullptr, Auto(), 0, 0, as_caption(""), 0); @@ -3096,7 +3096,7 @@ class CliClient final : public Actor { auto chat = as_chat_id(chat_id); send_request(td_api::make_object( - chat, 0, default_send_message_options(), to_integer(query_id), result_id, op == "siqrh")); + chat, 0, default_message_send_options(), to_integer(query_id), result_id, op == "siqrh")); } else if (op == "gcqr") { string chat_id; string message_id;