mirror of
https://github.com/tdlib/telegram-bot-api
synced 2025-08-22 01:49:24 +00:00
Support sending messages to direct messages topics.
This commit is contained in:
parent
b3ee23bf83
commit
9ff59948be
@ -9437,9 +9437,11 @@ td::Result<td_api::object_ptr<td_api::InputMessageContent>> Client::get_input_me
|
||||
td_api::object_ptr<td_api::messageSendOptions> Client::get_message_send_options(bool disable_notification,
|
||||
bool protect_content,
|
||||
bool allow_paid_broadcast,
|
||||
int64 effect_id) {
|
||||
return make_object<td_api::messageSendOptions>(0, nullptr, disable_notification, false, protect_content,
|
||||
allow_paid_broadcast, 0, false, nullptr, effect_id, 0, false);
|
||||
int64 effect_id,
|
||||
int64 direct_messages_topic_id) {
|
||||
return make_object<td_api::messageSendOptions>(direct_messages_topic_id, nullptr, disable_notification, false,
|
||||
protect_content, allow_paid_broadcast, 0, false, nullptr, effect_id, 0,
|
||||
false);
|
||||
}
|
||||
|
||||
td::Result<td_api::object_ptr<td_api::inlineQueryResultsButton>> Client::get_inline_query_results_button(
|
||||
@ -12219,10 +12221,11 @@ td::Status Client::process_copy_messages_query(PromisedQueryPtr &query) {
|
||||
}
|
||||
auto disable_notification = to_bool(query->arg("disable_notification"));
|
||||
auto protect_content = to_bool(query->arg("protect_content"));
|
||||
auto direct_messages_topic_id = td::to_integer<int64>(query->arg("direct_messages_topic_id"));
|
||||
auto remove_caption = to_bool(query->arg("remove_caption"));
|
||||
|
||||
auto on_success = [this, from_chat_id = from_chat_id.str(), message_ids = std::move(message_ids),
|
||||
disable_notification, protect_content,
|
||||
disable_notification, protect_content, direct_messages_topic_id,
|
||||
remove_caption](int64 chat_id, int64 message_thread_id, CheckedReplyParameters,
|
||||
PromisedQueryPtr query) mutable {
|
||||
auto it = yet_unsent_message_count_.find(chat_id);
|
||||
@ -12232,8 +12235,8 @@ td::Status Client::process_copy_messages_query(PromisedQueryPtr &query) {
|
||||
|
||||
check_messages(
|
||||
from_chat_id, std::move(message_ids), true, AccessRights::Read, "message to forward", std::move(query),
|
||||
[this, chat_id, message_thread_id, disable_notification, protect_content, remove_caption](
|
||||
int64 from_chat_id, td::vector<int64> message_ids, PromisedQueryPtr query) {
|
||||
[this, chat_id, message_thread_id, disable_notification, protect_content, direct_messages_topic_id,
|
||||
remove_caption](int64 from_chat_id, td::vector<int64> message_ids, PromisedQueryPtr query) {
|
||||
auto &count = yet_unsent_message_count_[chat_id];
|
||||
if (count >= MAX_CONCURRENTLY_SENT_CHAT_MESSAGES) {
|
||||
return fail_query_flood_limit_exceeded(std::move(query));
|
||||
@ -12245,7 +12248,8 @@ td::Status Client::process_copy_messages_query(PromisedQueryPtr &query) {
|
||||
send_request(
|
||||
make_object<td_api::forwardMessages>(
|
||||
chat_id, message_thread_id, from_chat_id, std::move(message_ids),
|
||||
get_message_send_options(disable_notification, protect_content, false, 0), true, remove_caption),
|
||||
get_message_send_options(disable_notification, protect_content, false, 0, direct_messages_topic_id),
|
||||
true, remove_caption),
|
||||
td::make_unique<TdOnForwardMessagesCallback>(this, chat_id, message_count, std::move(query)));
|
||||
});
|
||||
};
|
||||
@ -12281,10 +12285,12 @@ td::Status Client::process_forward_messages_query(PromisedQueryPtr &query) {
|
||||
}
|
||||
auto disable_notification = to_bool(query->arg("disable_notification"));
|
||||
auto protect_content = to_bool(query->arg("protect_content"));
|
||||
auto direct_messages_topic_id = td::to_integer<int64>(query->arg("direct_messages_topic_id"));
|
||||
|
||||
auto on_success = [this, from_chat_id = from_chat_id.str(), message_ids = std::move(message_ids),
|
||||
disable_notification, protect_content](int64 chat_id, int64 message_thread_id,
|
||||
CheckedReplyParameters, PromisedQueryPtr query) mutable {
|
||||
disable_notification, protect_content,
|
||||
direct_messages_topic_id](int64 chat_id, int64 message_thread_id, CheckedReplyParameters,
|
||||
PromisedQueryPtr query) mutable {
|
||||
auto it = yet_unsent_message_count_.find(chat_id);
|
||||
if (it != yet_unsent_message_count_.end() && it->second >= MAX_CONCURRENTLY_SENT_CHAT_MESSAGES) {
|
||||
return fail_query_flood_limit_exceeded(std::move(query));
|
||||
@ -12292,7 +12298,7 @@ td::Status Client::process_forward_messages_query(PromisedQueryPtr &query) {
|
||||
|
||||
check_messages(
|
||||
from_chat_id, std::move(message_ids), true, AccessRights::Read, "message to forward", std::move(query),
|
||||
[this, chat_id, message_thread_id, disable_notification, protect_content](
|
||||
[this, chat_id, message_thread_id, disable_notification, protect_content, direct_messages_topic_id](
|
||||
int64 from_chat_id, td::vector<int64> message_ids, PromisedQueryPtr query) {
|
||||
auto &count = yet_unsent_message_count_[chat_id];
|
||||
if (count >= MAX_CONCURRENTLY_SENT_CHAT_MESSAGES) {
|
||||
@ -12302,10 +12308,12 @@ td::Status Client::process_forward_messages_query(PromisedQueryPtr &query) {
|
||||
auto message_count = message_ids.size();
|
||||
count += static_cast<int32>(message_count);
|
||||
|
||||
send_request(make_object<td_api::forwardMessages>(
|
||||
chat_id, message_thread_id, from_chat_id, std::move(message_ids),
|
||||
get_message_send_options(disable_notification, protect_content, false, 0), false, false),
|
||||
td::make_unique<TdOnForwardMessagesCallback>(this, chat_id, message_count, std::move(query)));
|
||||
send_request(
|
||||
make_object<td_api::forwardMessages>(
|
||||
chat_id, message_thread_id, from_chat_id, std::move(message_ids),
|
||||
get_message_send_options(disable_notification, protect_content, false, 0, direct_messages_topic_id),
|
||||
false, false),
|
||||
td::make_unique<TdOnForwardMessagesCallback>(this, chat_id, message_count, std::move(query)));
|
||||
});
|
||||
};
|
||||
check_reply_parameters(chat_id, InputReplyParameters(), message_thread_id, std::move(query), std::move(on_success));
|
||||
@ -12322,6 +12330,7 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
||||
auto protect_content = to_bool(query->arg("protect_content"));
|
||||
auto allow_paid_broadcast = to_bool(query->arg("allow_paid_broadcast"));
|
||||
auto effect_id = td::to_integer<int64>(query->arg("message_effect_id"));
|
||||
auto direct_messages_topic_id = td::to_integer<int64>(query->arg("direct_messages_topic_id"));
|
||||
// TRY_RESULT(reply_markup, get_reply_markup(query.get(), bot_user_ids_));
|
||||
auto reply_markup = nullptr;
|
||||
TRY_RESULT(input_message_contents, get_input_message_contents(query.get(), "media"));
|
||||
@ -12330,7 +12339,7 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
||||
std::move(reply_markup), std::move(query),
|
||||
[this, chat_id_str = chat_id.str(), message_thread_id, business_connection_id = business_connection_id.str(),
|
||||
reply_parameters = std::move(reply_parameters), disable_notification, protect_content, allow_paid_broadcast,
|
||||
effect_id, input_message_contents = std::move(input_message_contents)](
|
||||
effect_id, direct_messages_topic_id, input_message_contents = std::move(input_message_contents)](
|
||||
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
||||
if (!business_connection_id.empty()) {
|
||||
return check_business_connection_chat_id(
|
||||
@ -12348,7 +12357,7 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
||||
}
|
||||
|
||||
auto on_success = [this, disable_notification, protect_content, allow_paid_broadcast, effect_id,
|
||||
input_message_contents = std::move(input_message_contents),
|
||||
direct_messages_topic_id, input_message_contents = std::move(input_message_contents),
|
||||
reply_markup = std::move(reply_markup)](int64 chat_id, int64 message_thread_id,
|
||||
CheckedReplyParameters reply_parameters,
|
||||
PromisedQueryPtr query) mutable {
|
||||
@ -12359,12 +12368,12 @@ td::Status Client::process_send_media_group_query(PromisedQueryPtr &query) {
|
||||
auto message_count = input_message_contents.size();
|
||||
count += static_cast<int32>(message_count);
|
||||
|
||||
send_request(
|
||||
make_object<td_api::sendMessageAlbum>(
|
||||
chat_id, message_thread_id, get_input_message_reply_to(std::move(reply_parameters)),
|
||||
get_message_send_options(disable_notification, protect_content, allow_paid_broadcast, effect_id),
|
||||
std::move(input_message_contents)),
|
||||
td::make_unique<TdOnSendMessageAlbumCallback>(this, chat_id, message_count, std::move(query)));
|
||||
send_request(make_object<td_api::sendMessageAlbum>(
|
||||
chat_id, message_thread_id, get_input_message_reply_to(std::move(reply_parameters)),
|
||||
get_message_send_options(disable_notification, protect_content, allow_paid_broadcast,
|
||||
effect_id, direct_messages_topic_id),
|
||||
std::move(input_message_contents)),
|
||||
td::make_unique<TdOnSendMessageAlbumCallback>(this, chat_id, message_count, std::move(query)));
|
||||
};
|
||||
check_reply_parameters(chat_id_str, std::move(reply_parameters), message_thread_id, std::move(query),
|
||||
std::move(on_success), allow_paid_broadcast);
|
||||
@ -14759,6 +14768,7 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
||||
auto protect_content = to_bool(query->arg("protect_content"));
|
||||
auto allow_paid_broadcast = to_bool(query->arg("allow_paid_broadcast"));
|
||||
auto effect_id = td::to_integer<int64>(query->arg("message_effect_id"));
|
||||
auto direct_messages_topic_id = td::to_integer<int64>(query->arg("direct_messages_topic_id"));
|
||||
auto r_reply_markup = get_reply_markup(query.get(), bot_user_ids_);
|
||||
if (r_reply_markup.is_error()) {
|
||||
return fail_query_with_error(std::move(query), 400, r_reply_markup.error().message());
|
||||
@ -14769,7 +14779,7 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
||||
std::move(reply_markup), std::move(query),
|
||||
[this, chat_id_str = chat_id.str(), message_thread_id, business_connection_id = business_connection_id.str(),
|
||||
reply_parameters = std::move(reply_parameters), disable_notification, protect_content, allow_paid_broadcast,
|
||||
effect_id, input_message_content = std::move(input_message_content)](
|
||||
effect_id, direct_messages_topic_id, input_message_content = std::move(input_message_content)](
|
||||
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
|
||||
if (!business_connection_id.empty()) {
|
||||
return check_business_connection_chat_id(
|
||||
@ -14787,7 +14797,7 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
||||
}
|
||||
|
||||
auto on_success = [this, disable_notification, protect_content, allow_paid_broadcast, effect_id,
|
||||
input_message_content = std::move(input_message_content),
|
||||
direct_messages_topic_id, input_message_content = std::move(input_message_content),
|
||||
reply_markup = std::move(reply_markup)](int64 chat_id, int64 message_thread_id,
|
||||
CheckedReplyParameters reply_parameters,
|
||||
PromisedQueryPtr query) mutable {
|
||||
@ -14797,12 +14807,12 @@ void Client::do_send_message(object_ptr<td_api::InputMessageContent> input_messa
|
||||
}
|
||||
count++;
|
||||
|
||||
send_request(
|
||||
make_object<td_api::sendMessage>(
|
||||
chat_id, message_thread_id, get_input_message_reply_to(std::move(reply_parameters)),
|
||||
get_message_send_options(disable_notification, protect_content, allow_paid_broadcast, effect_id),
|
||||
std::move(reply_markup), std::move(input_message_content)),
|
||||
td::make_unique<TdOnSendMessageCallback>(this, chat_id, std::move(query)));
|
||||
send_request(make_object<td_api::sendMessage>(
|
||||
chat_id, message_thread_id, get_input_message_reply_to(std::move(reply_parameters)),
|
||||
get_message_send_options(disable_notification, protect_content, allow_paid_broadcast,
|
||||
effect_id, direct_messages_topic_id),
|
||||
std::move(reply_markup), std::move(input_message_content)),
|
||||
td::make_unique<TdOnSendMessageCallback>(this, chat_id, std::move(query)));
|
||||
};
|
||||
check_reply_parameters(chat_id_str, std::move(reply_parameters), message_thread_id, std::move(query),
|
||||
std::move(on_success), allow_paid_broadcast);
|
||||
|
@ -642,7 +642,8 @@ class Client final : public WebhookActor::Callback {
|
||||
|
||||
static object_ptr<td_api::messageSendOptions> get_message_send_options(bool disable_notification,
|
||||
bool protect_content,
|
||||
bool allow_paid_broadcast, int64 effect_id);
|
||||
bool allow_paid_broadcast, int64 effect_id,
|
||||
int64 direct_messages_topic_id);
|
||||
|
||||
static td::Result<td::vector<object_ptr<td_api::formattedText>>> get_poll_options(const Query *query);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user