diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index acbc8e2..761706d 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -9437,9 +9437,11 @@ td::Result> Client::get_input_me td_api::object_ptr Client::get_message_send_options(bool disable_notification, bool protect_content, bool allow_paid_broadcast, - int64 effect_id) { - return make_object(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(direct_messages_topic_id, nullptr, disable_notification, false, + protect_content, allow_paid_broadcast, 0, false, nullptr, effect_id, 0, + false); } td::Result> 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(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 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 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( 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(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(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 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(message_count); - send_request(make_object( - 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(this, chat_id, message_count, std::move(query))); + send_request( + make_object( + 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(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(query->arg("message_effect_id")); + auto direct_messages_topic_id = td::to_integer(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 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(message_count); - send_request( - make_object( - 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(this, chat_id, message_count, std::move(query))); + send_request(make_object( + 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(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 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(query->arg("message_effect_id")); + auto direct_messages_topic_id = td::to_integer(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 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 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 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 input_messa } count++; - send_request( - make_object( - 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(this, chat_id, std::move(query))); + send_request(make_object( + 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(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); diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index 6dcf183..7e0e6e1 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -642,7 +642,8 @@ class Client final : public WebhookActor::Callback { static object_ptr 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>> get_poll_options(const Query *query);