From e077f1dd0986656dad8ca86d8141245830bc7a0f Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 22 Mar 2024 14:16:49 +0300 Subject: [PATCH] Add additional request users/chat flags. --- td/generate/scheme/td_api.tl | 10 ++++++++-- td/telegram/RequestedDialogType.cpp | 29 ++++++++++++++++++++++++----- td/telegram/RequestedDialogType.h | 6 +++++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 44eb78dd5..703efeb32 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1875,7 +1875,10 @@ keyboardButtonTypeRequestPoll force_regular:Bool force_quiz:Bool = KeyboardButto //@restrict_user_is_premium True, if the shared users must or must not be Telegram Premium users //@user_is_premium True, if the shared users must be Telegram Premium users; otherwise, the shared users must not be Telegram Premium users. Ignored if restrict_user_is_premium is false //@max_quantity The maximum number of users to share -keyboardButtonTypeRequestUsers id:int32 restrict_user_is_bot:Bool user_is_bot:Bool restrict_user_is_premium:Bool user_is_premium:Bool max_quantity:int32 = KeyboardButtonType; +//@request_name Pass true to request name of the users; bots only +//@request_username Pass true to request username of the users; bots only +//@request_photo Pass true to request photo of the users; bots only +keyboardButtonTypeRequestUsers id:int32 restrict_user_is_bot:Bool user_is_bot:Bool restrict_user_is_premium:Bool user_is_premium:Bool max_quantity:int32 request_name:Bool request_username:Bool request_photo:Bool = KeyboardButtonType; //@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 @@ -1888,7 +1891,10 @@ keyboardButtonTypeRequestUsers id:int32 restrict_user_is_bot:Bool user_is_bot:Bo //@user_administrator_rights Expected user administrator rights in the chat; may be null if they aren't restricted //@bot_administrator_rights Expected bot administrator rights in the chat; may be null if they aren't restricted //@bot_is_member True, if the bot must be a member of the chat; for basic group and supergroup chats only -keyboardButtonTypeRequestChat id:int32 chat_is_channel:Bool restrict_chat_is_forum:Bool chat_is_forum:Bool restrict_chat_has_username:Bool chat_has_username:Bool chat_is_created:Bool user_administrator_rights:chatAdministratorRights bot_administrator_rights:chatAdministratorRights bot_is_member:Bool = KeyboardButtonType; +//@request_title Pass true to request title of the chat; bots only +//@request_username Pass true to request username of the chat; bots only +//@request_photo Pass true to request photo of the chat; bots only +keyboardButtonTypeRequestChat id:int32 chat_is_channel:Bool restrict_chat_is_forum:Bool chat_is_forum:Bool restrict_chat_has_username:Bool chat_has_username:Bool chat_is_created:Bool user_administrator_rights:chatAdministratorRights bot_administrator_rights:chatAdministratorRights bot_is_member:Bool request_title:Bool request_username:Bool request_photo:Bool = KeyboardButtonType; //@description A button that opens a Web App by calling getWebAppUrl @url An HTTP URL to pass to getWebAppUrl keyboardButtonTypeWebApp url:string = KeyboardButtonType; diff --git a/td/telegram/RequestedDialogType.cpp b/td/telegram/RequestedDialogType.cpp index c8d029f91..e512ce784 100644 --- a/td/telegram/RequestedDialogType.cpp +++ b/td/telegram/RequestedDialogType.cpp @@ -21,6 +21,9 @@ RequestedDialogType::RequestedDialogType(td_api::object_ptruser_is_bot_; restrict_is_premium_ = request_users->restrict_user_is_premium_; is_premium_ = request_users->user_is_premium_; + request_name_ = request_users->request_name_; + request_username_ = request_users->request_username_; + request_photo_ = request_users->request_photo_; } RequestedDialogType::RequestedDialogType(td_api::object_ptr &&request_dialog) { @@ -38,6 +41,9 @@ RequestedDialogType::RequestedDialogType(td_api::object_ptrchat_is_channel_ ? ChannelType::Broadcast : ChannelType::Megagroup; user_administrator_rights_ = AdministratorRights(request_dialog->user_administrator_rights_, channel_type); bot_administrator_rights_ = AdministratorRights(request_dialog->bot_administrator_rights_, channel_type); + request_name_ = request_dialog->request_title_; + request_username_ = request_dialog->request_username_; + request_photo_ = request_dialog->request_photo_; } RequestedDialogType::RequestedDialogType(telegram_api::object_ptr &&peer_type, @@ -90,7 +96,8 @@ RequestedDialogType::RequestedDialogType(telegram_api::object_ptr RequestedDialogType::get_keyboard_button_type_object() const { if (type_ == Type::User) { return td_api::make_object( - button_id_, restrict_is_bot_, is_bot_, restrict_is_premium_, is_premium_, max_quantity_); + button_id_, restrict_is_bot_, is_bot_, restrict_is_premium_, is_premium_, max_quantity_, request_name_, + request_username_, request_photo_); } else { auto user_administrator_rights = restrict_user_administrator_rights_ ? user_administrator_rights_.get_chat_administrator_rights_object() @@ -99,7 +106,8 @@ td_api::object_ptr RequestedDialogType::get_keyboard restrict_bot_administrator_rights_ ? bot_administrator_rights_.get_chat_administrator_rights_object() : nullptr; return td_api::make_object( button_id_, type_ == Type::Channel, restrict_is_forum_, is_forum_, restrict_has_username_, has_username_, - is_created_, std::move(user_administrator_rights), std::move(bot_administrator_rights), bot_is_participant_); + is_created_, std::move(user_administrator_rights), std::move(bot_administrator_rights), bot_is_participant_, + request_name_, request_username_, request_photo_); } } @@ -171,10 +179,21 @@ telegram_api::object_ptr RequestedDialogType::get } } -telegram_api::object_ptr +telegram_api::object_ptr RequestedDialogType::get_input_keyboard_button_request_peer(const string &text) const { - return telegram_api::make_object( - text, button_id_, get_input_request_peer_type_object(), max_quantity_); + int32 flags = 0; + if (request_name_) { + flags |= telegram_api::inputKeyboardButtonRequestPeer::NAME_REQUESTED_MASK; + } + if (request_username_) { + flags |= telegram_api::inputKeyboardButtonRequestPeer::USERNAME_REQUESTED_MASK; + } + if (request_photo_) { + flags |= telegram_api::inputKeyboardButtonRequestPeer::PHOTO_REQUESTED_MASK; + } + return telegram_api::make_object( + flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, text, button_id_, + get_input_request_peer_type_object(), max_quantity_); } int32 RequestedDialogType::get_button_id() const { diff --git a/td/telegram/RequestedDialogType.h b/td/telegram/RequestedDialogType.h index 67a8180b5..aba0e3b77 100644 --- a/td/telegram/RequestedDialogType.h +++ b/td/telegram/RequestedDialogType.h @@ -28,6 +28,10 @@ class RequestedDialogType { bool restrict_is_premium_ = false; // User only bool is_premium_ = false; // User only + bool request_name_ = false; + bool request_username_ = false; + bool request_photo_ = false; + bool restrict_is_forum_ = false; // Group only bool is_forum_ = false; // Group only bool bot_is_participant_ = false; // Group only @@ -53,7 +57,7 @@ class RequestedDialogType { td_api::object_ptr get_keyboard_button_type_object() const; - telegram_api::object_ptr get_input_keyboard_button_request_peer( + telegram_api::object_ptr get_input_keyboard_button_request_peer( const string &text) const; int32 get_button_id() const;