Improve names of methods and message contents related to sharing user/chat with a bot.

This commit is contained in:
levlam 2023-01-23 18:19:35 +03:00
parent c4568db488
commit 0feb0f15ce
9 changed files with 47 additions and 47 deletions

View File

@ -1407,17 +1407,17 @@ keyboardButtonTypeRequestLocation = KeyboardButtonType;
//@description A button that allows the user to create and send a poll when pressed; available only in private chats @force_regular If true, only regular polls must be allowed to create @force_quiz If true, only polls in quiz mode must be allowed to create
keyboardButtonTypeRequestPoll force_regular:Bool force_quiz:Bool = KeyboardButtonType;
//@description A button that requests a user to be chosen by the current user; available only in private chats
//@description A button that requests a user to be shared by the current user; available only in private chats. Use the method shareUserWithBot to complete the request
//@id Unique button identifier
//@restrict_user_is_bot True, if the chosen user must or must not be a bot
//@user_is_bot True, if the chosen user must be a bot; otherwise, the chosen user must no be a bot. Ignored if restrict_user_is_bot is false
//@restrict_user_is_premium True, if the chosen user must or must not be a Telegram Premium user
//@user_is_premium True, if the chosen user must be a Telegram Premium user; otherwise, the chosen user must no be a Telegram Premium user. Ignored if restrict_user_is_premium is false
//@restrict_user_is_bot True, if the shared user must or must not be a bot
//@user_is_bot True, if the shared user must be a bot; otherwise, the shared user must no be a bot. Ignored if restrict_user_is_bot is false
//@restrict_user_is_premium True, if the shared user must or must not be a Telegram Premium user
//@user_is_premium True, if the shared user must be a Telegram Premium user; otherwise, the shared user must no be a Telegram Premium user. Ignored if restrict_user_is_premium is false
keyboardButtonTypeRequestUser id:int32 restrict_user_is_bot:Bool user_is_bot:Bool restrict_user_is_premium:Bool user_is_premium:Bool = KeyboardButtonType;
//@description A button that requests a chat to be chosen by the current user; available only in private chats
//@description A button that requests a chat to be shared by the current user; available only in private chats. Use the method shareChatWithBot to complete the request
//@id Unique button identifier
//@chat_is_channel True, if the chat must be a channel; otherwise, a basic group or a supergroup chat is chosen
//@chat_is_channel True, if the chat must be a channel; otherwise, a basic group or a supergroup chat is shared
//@restrict_chat_is_forum True, if the chat must or must not be a forum supergroup
//@chat_is_forum True, if the chat must be a forum supergroup; otherwise, the chat must not be a forum supergroup. Ignored if restrict_chat_is_forum is false
//@restrict_chat_has_username True, if the chat must or must not have a username
@ -2514,11 +2514,11 @@ messageGiftedPremium currency:string amount:int53 month_count:int32 sticker:stic
//@description A contact has registered with Telegram
messageContactRegistered = MessageContent;
//@description The current user chosen a user, which was requested by the bot @user_id Identifier of the chosen user @button_id Identifier of the keyboard button with the request
messageUserChosen user_id:int53 button_id:int32 = MessageContent;
//@description The current user shared a user, which was requested by the bot @user_id Identifier of the shared user @button_id Identifier of the keyboard button with the request
messageUserShared user_id:int53 button_id:int32 = MessageContent;
//@description The current user chosen a chat, which was requested by the bot @chat_id Identifier of the chosen chat @button_id Identifier of the keyboard button with the request
messageChatChosen chat_id:int53 button_id:int32 = MessageContent;
//@description The current user shared a chat, which was requested by the bot @chat_id Identifier of the shared chat @button_id Identifier of the keyboard button with the request
messageChatShared chat_id:int53 button_id:int32 = MessageContent;
//@description The current user has connected a website by logging in using Telegram Login Widget on it @domain_name Domain name of the connected website
messageWebsiteConnected domain_name:string = MessageContent;
@ -6355,19 +6355,19 @@ getLoginUrlInfo chat_id:int53 message_id:int53 button_id:int53 = LoginUrlInfo;
getLoginUrl chat_id:int53 message_id:int53 button_id:int53 allow_write_access:Bool = HttpUrl;
//@description Sends a user chosen after pressing a keyboardButtonTypeRequestUser button to the bot
//@description Shares a user after pressing a keyboardButtonTypeRequestUser button with 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_user_id Identifier of the chosen user
sendChosenUser chat_id:int53 message_id:int53 button_id:int32 chosen_user_id:int53 = Ok;
//@shared_user_id Identifier of the shared user
shareUserWithBot chat_id:int53 message_id:int53 button_id:int32 shared_user_id:int53 = Ok;
//@description Sends a chat chosen after pressing a keyboardButtonTypeRequestChat button to the bot
//@description Shares a chat after pressing a keyboardButtonTypeRequestChat button with 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;
//@shared_chat_id Identifier of the shared chat
shareChatWithBot chat_id:int53 message_id:int53 button_id:int32 shared_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

@ -5681,11 +5681,11 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
case MessageContentType::RequestedDialog: {
const auto *m = static_cast<const MessageRequestedDialog *>(content);
if (m->dialog_id.get_type() == DialogType::User) {
return make_tl_object<td_api::messageUserChosen>(
return make_tl_object<td_api::messageUserShared>(
td->contacts_manager_->get_user_id_object(m->dialog_id.get_user_id(), "MessageRequestedDialog"),
m->button_id);
}
return make_tl_object<td_api::messageChatChosen>(m->dialog_id.get(), m->button_id);
return make_tl_object<td_api::messageChatShared>(m->dialog_id.get(), m->button_id);
}
default:
UNREACHABLE();

View File

@ -29882,9 +29882,9 @@ void MessagesManager::do_send_screenshot_taken_notification_message(DialogId dia
->send(dialog_id, random_id);
}
void MessagesManager::send_chosen_dialog(FullMessageId full_message_id, int32 button_id, DialogId chosen_dialog_id,
void MessagesManager::share_dialog_with_bot(FullMessageId full_message_id, int32 button_id, DialogId shared_dialog_id,
Promise<Unit> &&promise) {
const Message *m = get_message_force(full_message_id, "send_chosen_dialog");
const Message *m = get_message_force(full_message_id, "share_dialog_with_bot");
if (m == nullptr) {
return promise.set_error(Status::Error(400, "Message not found"));
}
@ -29892,12 +29892,12 @@ void MessagesManager::send_chosen_dialog(FullMessageId full_message_id, int32 bu
return promise.set_error(Status::Error(400, "Message has no buttons"));
}
CHECK(m->message_id.is_valid() && m->message_id.is_server());
if (chosen_dialog_id.get_type() != DialogType::User) {
get_dialog_force(chosen_dialog_id, "send_chosen_dialog");
if (shared_dialog_id.get_type() != DialogType::User) {
get_dialog_force(shared_dialog_id, "share_dialog_with_bot");
}
TRY_STATUS_PROMISE(promise, m->reply_markup->check_chosen_dialog(td_, button_id, chosen_dialog_id));
TRY_STATUS_PROMISE(promise, m->reply_markup->check_shared_dialog(td_, button_id, shared_dialog_id));
td_->create_handler<SendBotRequestedPeer>(std::move(promise))->send(full_message_id, button_id, chosen_dialog_id);
td_->create_handler<SendBotRequestedPeer>(std::move(promise))->send(full_message_id, button_id, shared_dialog_id);
}
Result<MessageId> MessagesManager::add_local_message(

View File

@ -467,7 +467,7 @@ class MessagesManager final : public Actor {
Status send_screenshot_taken_notification_message(DialogId dialog_id);
void send_chosen_dialog(FullMessageId full_message_id, int32 button_id, DialogId chosen_dialog_id,
void share_dialog_with_bot(FullMessageId full_message_id, int32 button_id, DialogId shared_dialog_id,
Promise<Unit> &&promise);
Result<MessageId> add_local_message(DialogId dialog_id, td_api::object_ptr<td_api::MessageSender> &&sender,

View File

@ -1047,7 +1047,7 @@ tl_object_ptr<td_api::ReplyMarkup> ReplyMarkup::get_reply_markup_object(Contacts
}
}
Status ReplyMarkup::check_chosen_dialog(Td *td, int32 button_id, DialogId dialog_id) const {
Status ReplyMarkup::check_shared_dialog(Td *td, int32 button_id, DialogId dialog_id) const {
// TODO
return Status::OK();
}

View File

@ -82,7 +82,7 @@ struct ReplyMarkup {
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(ContactsManager *contacts_manager) const;
Status check_chosen_dialog(Td *td, int32 button_id, DialogId dialog_id) const;
Status check_shared_dialog(Td *td, int32 button_id, DialogId dialog_id) const;
};
bool operator==(const ReplyMarkup &lhs, const ReplyMarkup &rhs);

View File

@ -7655,19 +7655,19 @@ void Td::on_request(uint64 id, const td_api::getLoginUrl &request) {
request.allow_write_access_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::sendChosenUser &request) {
void Td::on_request(uint64 id, const td_api::shareUserWithBot &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(UserId(request.chosen_user_id_)),
messages_manager_->share_dialog_with_bot({DialogId(request.chat_id_), MessageId(request.message_id_)},
request.button_id_, DialogId(UserId(request.shared_user_id_)),
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::sendChosenChat &request) {
void Td::on_request(uint64 id, const td_api::shareChatWithBot &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));
messages_manager_->share_dialog_with_bot({DialogId(request.chat_id_), MessageId(request.message_id_)},
request.button_id_, DialogId(request.shared_chat_id_), std::move(promise));
}
void Td::on_request(uint64 id, td_api::getInlineQueryResults &request) {

View File

@ -1299,9 +1299,9 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::getLoginUrl &request);
void on_request(uint64 id, const td_api::sendChosenUser &request);
void on_request(uint64 id, const td_api::shareUserWithBot &request);
void on_request(uint64 id, const td_api::sendChosenChat &request);
void on_request(uint64 id, const td_api::shareChatWithBot &request);
void on_request(uint64 id, td_api::getInlineQueryResults &request);

View File

@ -5172,20 +5172,20 @@ class CliClient final : public Actor {
send_request(
td_api::make_object<td_api::getLoginUrl>(chat_id, message_id, as_button_id(button_id), op == "glua"));
}
} else if (op == "scu") {
} else if (op == "suwb") {
ChatId chat_id;
MessageId message_id;
int32 button_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") {
UserId shared_user_id;
get_args(args, chat_id, message_id, button_id, shared_user_id);
send_request(td_api::make_object<td_api::shareUserWithBot>(chat_id, message_id, button_id, shared_user_id));
} else if (op == "scwb") {
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));
ChatId shared_chat_id;
get_args(args, chat_id, message_id, button_id, shared_chat_id);
send_request(td_api::make_object<td_api::shareChatWithBot>(chat_id, message_id, button_id, shared_chat_id));
} else if (op == "rsgs") {
string supergroup_id;
string message_ids;