Add td_api::sendChosenChat.

This commit is contained in:
levlam 2023-01-13 17:16:16 +03:00
parent 0b54e28467
commit 97cc57a25c
8 changed files with 40 additions and 14 deletions

View File

@ -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

View File

@ -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<Unit> &&promise) {
void MessagesManager::send_chosen_dialog(FullMessageId full_message_id, int32 button_id, DialogId chosen_dialog_id,
Promise<Unit> &&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<SendBotRequestedPeer>(std::move(promise))->send(full_message_id, button_id, DialogId(user_id));
td_->create_handler<SendBotRequestedPeer>(std::move(promise))->send(full_message_id, button_id, chosen_dialog_id);
}
Result<MessageId> MessagesManager::add_local_message(

View File

@ -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<Unit> &&promise);
void send_chosen_dialog(FullMessageId full_message_id, int32 button_id, DialogId chosen_dialog_id,
Promise<Unit> &&promise);
Result<MessageId> add_local_message(DialogId dialog_id, td_api::object_ptr<td_api::MessageSender> &&sender,
MessageId reply_to_message_id, bool disable_notification,

View File

@ -1047,7 +1047,7 @@ tl_object_ptr<td_api::ReplyMarkup> 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();
}

View File

@ -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<td_api::ReplyMarkup> 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);

View File

@ -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) {

View File

@ -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);

View File

@ -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<td_api::sendChosenUser>(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<td_api::sendChosenUser>(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<td_api::sendChosenUser>(chat_id, message_id, button_id, chosen_chat_id));
} else if (op == "rsgs") {
string supergroup_id;
string message_ids;