diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 562ef6f76..998546ef0 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6292,8 +6292,15 @@ getLoginUrl chat_id:int53 message_id:int53 button_id:int53 allow_write_access:Bo //@chat_id Identifier of the chat with the bot //@message_id Identifier of the message with the button //@button_id Identifier of the button -//@user_id Identifier of the chosen user -sendChosenUser chat_id:int53 message_id:int53 button_id:int32 user_id:int53 = Ok; +//@chosen_user_id Identifier of the chosen user +sendChosenUser chat_id:int53 message_id:int53 button_id:int32 chosen_user_id:int53 = Ok; + +//@description Sends a chat chosen after pressing a keyboardButtonTypeRequestChat button to the bot +//@chat_id Identifier of the chat with the bot +//@message_id Identifier of the message with the button +//@button_id Identifier of the button +//@chosen_chat_id Identifier of the chosen chat +sendChosenChat chat_id:int53 message_id:int53 button_id:int32 chosen_chat_id:int53 = Ok; //@description Sends an inline query to a bot and returns its results. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 9313e8b04..f321296ab 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -29747,8 +29747,8 @@ void MessagesManager::do_send_screenshot_taken_notification_message(DialogId dia ->send(dialog_id, random_id); } -void MessagesManager::send_chosen_user(FullMessageId full_message_id, int32 button_id, UserId user_id, - Promise &&promise) { +void MessagesManager::send_chosen_dialog(FullMessageId full_message_id, int32 button_id, DialogId chosen_dialog_id, + Promise &&promise) { const Message *m = get_message_force(full_message_id, "send_chosen_user"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); @@ -29757,9 +29757,9 @@ void MessagesManager::send_chosen_user(FullMessageId full_message_id, int32 butt return promise.set_error(Status::Error(400, "Message has no buttons")); } CHECK(m->message_id.is_valid() && m->message_id.is_server()); - TRY_STATUS_PROMISE(promise, m->reply_markup->check_chosen_user(td_, button_id, user_id)); + TRY_STATUS_PROMISE(promise, m->reply_markup->check_chosen_dialog(td_, button_id, chosen_dialog_id)); - td_->create_handler(std::move(promise))->send(full_message_id, button_id, DialogId(user_id)); + td_->create_handler(std::move(promise))->send(full_message_id, button_id, chosen_dialog_id); } Result MessagesManager::add_local_message( diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 1bfe6bfa1..031ca8f5b 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -462,7 +462,8 @@ class MessagesManager final : public Actor { Status send_screenshot_taken_notification_message(DialogId dialog_id); - void send_chosen_user(FullMessageId full_message_id, int32 button_id, UserId user_id, Promise &&promise); + void send_chosen_dialog(FullMessageId full_message_id, int32 button_id, DialogId chosen_dialog_id, + Promise &&promise); Result add_local_message(DialogId dialog_id, td_api::object_ptr &&sender, MessageId reply_to_message_id, bool disable_notification, diff --git a/td/telegram/ReplyMarkup.cpp b/td/telegram/ReplyMarkup.cpp index 4be5036f8..bc10cff00 100644 --- a/td/telegram/ReplyMarkup.cpp +++ b/td/telegram/ReplyMarkup.cpp @@ -1047,7 +1047,7 @@ tl_object_ptr ReplyMarkup::get_reply_markup_object(Contacts } } -Status ReplyMarkup::check_chosen_user(Td *td, int32 button_id, UserId user_id) const { +Status ReplyMarkup::check_chosen_dialog(Td *td, int32 button_id, DialogId dialog_id) const { // TODO return Status::OK(); } diff --git a/td/telegram/ReplyMarkup.h b/td/telegram/ReplyMarkup.h index 761ce6447..615765820 100644 --- a/td/telegram/ReplyMarkup.h +++ b/td/telegram/ReplyMarkup.h @@ -6,6 +6,7 @@ // #pragma once +#include "td/telegram/DialogId.h" #include "td/telegram/RequestedDialogType.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" @@ -81,7 +82,7 @@ struct ReplyMarkup { tl_object_ptr get_reply_markup_object(ContactsManager *contacts_manager) const; - Status check_chosen_user(Td *td, int32 button_id, UserId user_id) const; + Status check_chosen_dialog(Td *td, int32 button_id, DialogId dialog_id) const; }; bool operator==(const ReplyMarkup &lhs, const ReplyMarkup &rhs); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 05400934f..f2f400099 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7634,8 +7634,16 @@ void Td::on_request(uint64 id, const td_api::getLoginUrl &request) { void Td::on_request(uint64 id, const td_api::sendChosenUser &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); - messages_manager_->send_chosen_user({DialogId(request.chat_id_), MessageId(request.message_id_)}, request.button_id_, - UserId(request.user_id_), std::move(promise)); + messages_manager_->send_chosen_dialog({DialogId(request.chat_id_), MessageId(request.message_id_)}, + request.button_id_, DialogId(UserId(request.chosen_user_id_)), + std::move(promise)); +} + +void Td::on_request(uint64 id, const td_api::sendChosenChat &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + messages_manager_->send_chosen_dialog({DialogId(request.chat_id_), MessageId(request.message_id_)}, + request.button_id_, DialogId(request.chosen_chat_id_), std::move(promise)); } void Td::on_request(uint64 id, td_api::getInlineQueryResults &request) { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index e6a08563a..69f2ad0bc 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1292,6 +1292,8 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::sendChosenUser &request); + void on_request(uint64 id, const td_api::sendChosenChat &request); + void on_request(uint64 id, td_api::getInlineQueryResults &request); void on_request(uint64 id, td_api::answerInlineQuery &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index b2e6e815c..273753554 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -5106,9 +5106,16 @@ class CliClient final : public Actor { ChatId chat_id; MessageId message_id; int32 button_id; - UserId user_id; - get_args(args, chat_id, message_id, button_id, user_id); - send_request(td_api::make_object(chat_id, message_id, button_id, user_id)); + UserId chosen_user_id; + get_args(args, chat_id, message_id, button_id, chosen_user_id); + send_request(td_api::make_object(chat_id, message_id, button_id, chosen_user_id)); + } else if (op == "scc") { + ChatId chat_id; + MessageId message_id; + int32 button_id; + ChatId chosen_chat_id; + get_args(args, chat_id, message_id, button_id, chosen_chat_id); + send_request(td_api::make_object(chat_id, message_id, button_id, chosen_chat_id)); } else if (op == "rsgs") { string supergroup_id; string message_ids;