Add additional request users/chat flags.

This commit is contained in:
levlam 2024-03-22 14:16:49 +03:00
parent 4e51567a8c
commit e077f1dd09
3 changed files with 37 additions and 8 deletions

View File

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

View File

@ -21,6 +21,9 @@ RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButt
is_bot_ = request_users->user_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<td_api::keyboardButtonTypeRequestChat> &&request_dialog) {
@ -38,6 +41,9 @@ RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButt
auto channel_type = request_dialog->chat_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<telegram_api::RequestPeerType> &&peer_type,
@ -90,7 +96,8 @@ RequestedDialogType::RequestedDialogType(telegram_api::object_ptr<telegram_api::
td_api::object_ptr<td_api::KeyboardButtonType> RequestedDialogType::get_keyboard_button_type_object() const {
if (type_ == Type::User) {
return td_api::make_object<td_api::keyboardButtonTypeRequestUsers>(
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<td_api::KeyboardButtonType> RequestedDialogType::get_keyboard
restrict_bot_administrator_rights_ ? bot_administrator_rights_.get_chat_administrator_rights_object() : nullptr;
return td_api::make_object<td_api::keyboardButtonTypeRequestChat>(
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<telegram_api::RequestPeerType> RequestedDialogType::get
}
}
telegram_api::object_ptr<telegram_api::keyboardButtonRequestPeer>
telegram_api::object_ptr<telegram_api::inputKeyboardButtonRequestPeer>
RequestedDialogType::get_input_keyboard_button_request_peer(const string &text) const {
return telegram_api::make_object<telegram_api::keyboardButtonRequestPeer>(
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<telegram_api::inputKeyboardButtonRequestPeer>(
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, text, button_id_,
get_input_request_peer_type_object(), max_quantity_);
}
int32 RequestedDialogType::get_button_id() const {

View File

@ -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<td_api::KeyboardButtonType> get_keyboard_button_type_object() const;
telegram_api::object_ptr<telegram_api::keyboardButtonRequestPeer> get_input_keyboard_button_request_peer(
telegram_api::object_ptr<telegram_api::inputKeyboardButtonRequestPeer> get_input_keyboard_button_request_peer(
const string &text) const;
int32 get_button_id() const;