Add parameter only_preview to sendMessageAlbum.
This commit is contained in:
parent
679b70efa5
commit
83d26f3335
@ -4555,7 +4555,8 @@ sendMessage chat_id:int53 message_thread_id:int53 reply_to_message_id:int53 opti
|
||||
//@reply_to_message_id Identifier of a message to reply to or 0
|
||||
//@options Options to be used to send the messages; pass null to use default options
|
||||
//@input_message_contents Contents of messages to be sent. At most 10 messages can be added to an album
|
||||
sendMessageAlbum chat_id:int53 message_thread_id:int53 reply_to_message_id:int53 options:messageSendOptions input_message_contents:vector<InputMessageContent> = Messages;
|
||||
//@only_preview If true, messages will not be sent and instead fake messages will be returned
|
||||
sendMessageAlbum chat_id:int53 message_thread_id:int53 reply_to_message_id:int53 options:messageSendOptions input_message_contents:vector<InputMessageContent> only_preview:Bool = 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)
|
||||
|
@ -25777,7 +25777,7 @@ int64 MessagesManager::generate_new_media_album_id() {
|
||||
Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_message_group(
|
||||
DialogId dialog_id, MessageId top_thread_message_id, MessageId reply_to_message_id,
|
||||
tl_object_ptr<td_api::messageSendOptions> &&options,
|
||||
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents) {
|
||||
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents, bool only_preview) {
|
||||
if (input_message_contents.size() > MAX_GROUPED_MESSAGES) {
|
||||
return Status::Error(400, "Too many messages to send as an album");
|
||||
}
|
||||
@ -25828,11 +25828,23 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_message_group
|
||||
bool need_update_dialog_pos = false;
|
||||
for (size_t i = 0; i < message_contents.size(); i++) {
|
||||
auto &message_content = message_contents[i];
|
||||
Message *m = get_message_to_send(d, top_thread_message_id, reply_to_message_id, message_send_options,
|
||||
dup_message_content(td_, dialog_id, message_content.first.get(),
|
||||
MessageContentDupType::Send, MessageCopyOptions()),
|
||||
&need_update_dialog_pos, i != 0);
|
||||
result.push_back(get_message_object(dialog_id, m, "send_message_group"));
|
||||
unique_ptr<Message> message;
|
||||
Message *m;
|
||||
if (only_preview) {
|
||||
message = create_message_to_send(d, top_thread_message_id, reply_to_message_id, message_send_options,
|
||||
std::move(message_content.first), i != 0, nullptr, false, DialogId());
|
||||
MessageId new_message_id = message_send_options.schedule_date != 0
|
||||
? get_next_yet_unsent_scheduled_message_id(d, message_send_options.schedule_date)
|
||||
: get_next_yet_unsent_message_id(d);
|
||||
set_message_id(message, new_message_id);
|
||||
m = message.get();
|
||||
} else {
|
||||
m = get_message_to_send(d, top_thread_message_id, reply_to_message_id, message_send_options,
|
||||
dup_message_content(td_, dialog_id, message_content.first.get(),
|
||||
MessageContentDupType::Send, MessageCopyOptions()),
|
||||
&need_update_dialog_pos, i != 0);
|
||||
}
|
||||
|
||||
auto ttl = message_content.second;
|
||||
if (ttl > 0) {
|
||||
m->ttl = ttl;
|
||||
@ -25840,13 +25852,18 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_message_group
|
||||
}
|
||||
m->media_album_id = media_album_id;
|
||||
|
||||
save_send_message_log_event(dialog_id, m);
|
||||
do_send_message(dialog_id, m);
|
||||
result.push_back(get_message_object(dialog_id, m, "send_message_group"));
|
||||
|
||||
send_update_new_message(d, m);
|
||||
if (!only_preview) {
|
||||
save_send_message_log_event(dialog_id, m);
|
||||
do_send_message(dialog_id, m);
|
||||
|
||||
send_update_new_message(d, m);
|
||||
}
|
||||
}
|
||||
|
||||
if (need_update_dialog_pos) {
|
||||
CHECK(!only_preview);
|
||||
send_update_chat_last_message(d, "send_message_group");
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,8 @@ class MessagesManager final : public Actor {
|
||||
Result<td_api::object_ptr<td_api::messages>> send_message_group(
|
||||
DialogId dialog_id, MessageId top_thread_message_id, MessageId reply_to_message_id,
|
||||
tl_object_ptr<td_api::messageSendOptions> &&options,
|
||||
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents) TD_WARN_UNUSED_RESULT;
|
||||
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents,
|
||||
bool only_preview) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
Result<MessageId> send_bot_start_message(UserId bot_user_id, DialogId dialog_id,
|
||||
const string ¶meter) TD_WARN_UNUSED_RESULT;
|
||||
|
@ -5396,7 +5396,7 @@ void Td::on_request(uint64 id, td_api::sendMessage &request) {
|
||||
void Td::on_request(uint64 id, td_api::sendMessageAlbum &request) {
|
||||
auto r_messages = messages_manager_->send_message_group(
|
||||
DialogId(request.chat_id_), MessageId(request.message_thread_id_), MessageId(request.reply_to_message_id_),
|
||||
std::move(request.options_), std::move(request.input_message_contents_));
|
||||
std::move(request.options_), std::move(request.input_message_contents_), request.only_preview_);
|
||||
if (r_messages.is_error()) {
|
||||
send_closure(actor_id(this), &Td::send_error, id, r_messages.move_as_error());
|
||||
} else {
|
||||
|
@ -3465,34 +3465,32 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::addLocalMessage>(
|
||||
chat_id, as_message_sender(sender_id), reply_to_message_id, false,
|
||||
td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true)));
|
||||
} else if (op == "smap" || op == "smapr") {
|
||||
} else if (op == "smap" || op == "smapr" || op == "smapp" || op == "smaprp") {
|
||||
ChatId chat_id;
|
||||
MessageId reply_to_message_id;
|
||||
vector<string> photos;
|
||||
get_args(args, chat_id, args);
|
||||
if (op == "smapr") {
|
||||
if (op == "smapr" || op == "smaprp") {
|
||||
get_args(args, reply_to_message_id, args);
|
||||
}
|
||||
photos = full_split(args);
|
||||
auto input_message_contents = transform(full_split(args), [](const string &photo) {
|
||||
td_api::object_ptr<td_api::InputMessageContent> content = td_api::make_object<td_api::inputMessagePhoto>(
|
||||
as_input_file(photo), nullptr, Auto(), 0, 0, as_caption(""), 0);
|
||||
return content;
|
||||
});
|
||||
send_request(td_api::make_object<td_api::sendMessageAlbum>(
|
||||
chat_id, as_message_thread_id(message_thread_id_), reply_to_message_id, default_message_send_options(),
|
||||
transform(photos, [](const string &photo) {
|
||||
td_api::object_ptr<td_api::InputMessageContent> content = td_api::make_object<td_api::inputMessagePhoto>(
|
||||
as_input_file(photo), nullptr, Auto(), 0, 0, as_caption(""), 0);
|
||||
return content;
|
||||
})));
|
||||
} else if (op == "smad") {
|
||||
std::move(input_message_contents), op == "smapp" || op == "smaprp"));
|
||||
} else if (op == "smad" || op == "smadp") {
|
||||
ChatId chat_id;
|
||||
vector<string> documents;
|
||||
get_args(args, chat_id, args);
|
||||
documents = full_split(args);
|
||||
send_request(td_api::make_object<td_api::sendMessageAlbum>(
|
||||
chat_id, as_message_thread_id(message_thread_id_), 0, default_message_send_options(),
|
||||
transform(documents, [](const string &document) {
|
||||
td_api::object_ptr<td_api::InputMessageContent> content = td_api::make_object<td_api::inputMessageDocument>(
|
||||
as_input_file(document), nullptr, true, as_caption(""));
|
||||
return content;
|
||||
})));
|
||||
auto input_message_contents = transform(full_split(args), [](const string &document) {
|
||||
td_api::object_ptr<td_api::InputMessageContent> content =
|
||||
td_api::make_object<td_api::inputMessageDocument>(as_input_file(document), nullptr, true, as_caption(""));
|
||||
return content;
|
||||
});
|
||||
send_request(td_api::make_object<td_api::sendMessageAlbum>(chat_id, as_message_thread_id(message_thread_id_), 0,
|
||||
default_message_send_options(),
|
||||
std::move(input_message_contents), op.back() == 'p'));
|
||||
} else if (op == "gmft") {
|
||||
auto r_message_file_head = read_file_str(args, 2 << 10);
|
||||
if (r_message_file_head.is_error()) {
|
||||
|
Loading…
Reference in New Issue
Block a user