Replace td_api::keyboardButtonTypeRequestUser with td_api::keyboardButtonTypeRequestUsers.
This commit is contained in:
parent
9f9884f2f5
commit
590b3f3c25
@ -1725,13 +1725,14 @@ 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
|
//@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;
|
keyboardButtonTypeRequestPoll force_regular:Bool force_quiz:Bool = KeyboardButtonType;
|
||||||
|
|
||||||
//@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
|
//@description A button that requests users to be shared by the current user; available only in private chats. Use the method shareUsersWithBot to complete the request
|
||||||
//@id Unique button identifier
|
//@id Unique button identifier
|
||||||
//@restrict_user_is_bot True, if the shared user must or must not be a bot
|
//@restrict_user_is_bot True, if the shared users must or must not be bots
|
||||||
//@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
|
//@user_is_bot True, if the shared users must be bots; otherwise, the shared users must not be bots. 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
|
//@restrict_user_is_premium True, if the shared users must or must not be Telegram Premium users
|
||||||
//@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
|
//@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
|
||||||
keyboardButtonTypeRequestUser id:int32 restrict_user_is_bot:Bool user_is_bot:Bool restrict_user_is_premium:Bool user_is_premium:Bool = KeyboardButtonType;
|
//@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;
|
||||||
|
|
||||||
//@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
|
//@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
|
//@id Unique button identifier
|
||||||
@ -7573,7 +7574,7 @@ 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;
|
getLoginUrl chat_id:int53 message_id:int53 button_id:int53 allow_write_access:Bool = HttpUrl;
|
||||||
|
|
||||||
|
|
||||||
//@description Shares a user after pressing a keyboardButtonTypeRequestUser button with the bot
|
//@description Shares a user after pressing a keyboardButtonTypeRequestUsers button with the bot
|
||||||
//@chat_id Identifier of the chat with the bot
|
//@chat_id Identifier of the chat with the bot
|
||||||
//@message_id Identifier of the message with the button
|
//@message_id Identifier of the message with the button
|
||||||
//@button_id Identifier of the button
|
//@button_id Identifier of the button
|
||||||
|
@ -244,8 +244,8 @@ static KeyboardButton get_keyboard_button(tl_object_ptr<telegram_api::KeyboardBu
|
|||||||
auto keyboard_button = move_tl_object_as<telegram_api::keyboardButtonRequestPeer>(keyboard_button_ptr);
|
auto keyboard_button = move_tl_object_as<telegram_api::keyboardButtonRequestPeer>(keyboard_button_ptr);
|
||||||
button.type = KeyboardButton::Type::RequestDialog;
|
button.type = KeyboardButton::Type::RequestDialog;
|
||||||
button.text = std::move(keyboard_button->text_);
|
button.text = std::move(keyboard_button->text_);
|
||||||
button.requested_dialog_type =
|
button.requested_dialog_type = td::make_unique<RequestedDialogType>(
|
||||||
td::make_unique<RequestedDialogType>(std::move(keyboard_button->peer_type_), keyboard_button->button_id_);
|
std::move(keyboard_button->peer_type_), keyboard_button->button_id_, keyboard_button->max_quantity_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -525,11 +525,11 @@ static Result<KeyboardButton> get_keyboard_button(tl_object_ptr<td_api::keyboard
|
|||||||
current_button.url = std::move(button_type->url_);
|
current_button.url = std::move(button_type->url_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case td_api::keyboardButtonTypeRequestUser::ID: {
|
case td_api::keyboardButtonTypeRequestUsers::ID: {
|
||||||
if (!request_buttons_allowed) {
|
if (!request_buttons_allowed) {
|
||||||
return Status::Error(400, "Users can be requested in private chats only");
|
return Status::Error(400, "Users can be requested in private chats only");
|
||||||
}
|
}
|
||||||
auto button_type = move_tl_object_as<td_api::keyboardButtonTypeRequestUser>(button->type_);
|
auto button_type = move_tl_object_as<td_api::keyboardButtonTypeRequestUsers>(button->type_);
|
||||||
current_button.type = KeyboardButton::Type::RequestDialog;
|
current_button.type = KeyboardButton::Type::RequestDialog;
|
||||||
current_button.requested_dialog_type = td::make_unique<RequestedDialogType>(std::move(button_type));
|
current_button.requested_dialog_type = td::make_unique<RequestedDialogType>(std::move(button_type));
|
||||||
break;
|
break;
|
||||||
@ -865,9 +865,11 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(con
|
|||||||
case KeyboardButton::Type::WebView:
|
case KeyboardButton::Type::WebView:
|
||||||
return make_tl_object<telegram_api::keyboardButtonSimpleWebView>(keyboard_button.text, keyboard_button.url);
|
return make_tl_object<telegram_api::keyboardButtonSimpleWebView>(keyboard_button.text, keyboard_button.url);
|
||||||
case KeyboardButton::Type::RequestDialog:
|
case KeyboardButton::Type::RequestDialog:
|
||||||
|
CHECK(keyboard_button.requested_dialog_type != nullptr);
|
||||||
return make_tl_object<telegram_api::keyboardButtonRequestPeer>(
|
return make_tl_object<telegram_api::keyboardButtonRequestPeer>(
|
||||||
keyboard_button.text, keyboard_button.requested_dialog_type->get_button_id(),
|
keyboard_button.text, keyboard_button.requested_dialog_type->get_button_id(),
|
||||||
keyboard_button.requested_dialog_type->get_input_request_peer_type_object(), 1);
|
keyboard_button.requested_dialog_type->get_input_request_peer_type_object(),
|
||||||
|
keyboard_button.requested_dialog_type->get_max_quantity());
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -12,14 +12,15 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestUser> &&request_user) {
|
RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestUsers> &&request_users) {
|
||||||
CHECK(request_user != nullptr);
|
CHECK(request_users != nullptr);
|
||||||
type_ = Type::User;
|
type_ = Type::User;
|
||||||
button_id_ = request_user->id_;
|
button_id_ = request_users->id_;
|
||||||
restrict_is_bot_ = request_user->restrict_user_is_bot_;
|
max_quantity_ = request_users->max_quantity_;
|
||||||
is_bot_ = request_user->user_is_bot_;
|
restrict_is_bot_ = request_users->restrict_user_is_bot_;
|
||||||
restrict_is_premium_ = request_user->restrict_user_is_premium_;
|
is_bot_ = request_users->user_is_bot_;
|
||||||
is_premium_ = request_user->user_is_premium_;
|
restrict_is_premium_ = request_users->restrict_user_is_premium_;
|
||||||
|
is_premium_ = request_users->user_is_premium_;
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestChat> &&request_dialog) {
|
RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestChat> &&request_dialog) {
|
||||||
@ -40,9 +41,10 @@ RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButt
|
|||||||
}
|
}
|
||||||
|
|
||||||
RequestedDialogType::RequestedDialogType(telegram_api::object_ptr<telegram_api::RequestPeerType> &&peer_type,
|
RequestedDialogType::RequestedDialogType(telegram_api::object_ptr<telegram_api::RequestPeerType> &&peer_type,
|
||||||
int32 button_id) {
|
int32 button_id, int32 max_quantity) {
|
||||||
CHECK(peer_type != nullptr);
|
CHECK(peer_type != nullptr);
|
||||||
button_id_ = button_id;
|
button_id_ = button_id;
|
||||||
|
max_quantity_ = max_quantity;
|
||||||
switch (peer_type->get_id()) {
|
switch (peer_type->get_id()) {
|
||||||
case telegram_api::requestPeerTypeUser::ID: {
|
case telegram_api::requestPeerTypeUser::ID: {
|
||||||
auto type = telegram_api::move_object_as<telegram_api::requestPeerTypeUser>(peer_type);
|
auto type = telegram_api::move_object_as<telegram_api::requestPeerTypeUser>(peer_type);
|
||||||
@ -87,8 +89,8 @@ RequestedDialogType::RequestedDialogType(telegram_api::object_ptr<telegram_api::
|
|||||||
|
|
||||||
td_api::object_ptr<td_api::KeyboardButtonType> RequestedDialogType::get_keyboard_button_type_object() const {
|
td_api::object_ptr<td_api::KeyboardButtonType> RequestedDialogType::get_keyboard_button_type_object() const {
|
||||||
if (type_ == Type::User) {
|
if (type_ == Type::User) {
|
||||||
return td_api::make_object<td_api::keyboardButtonTypeRequestUser>(button_id_, restrict_is_bot_, is_bot_,
|
return td_api::make_object<td_api::keyboardButtonTypeRequestUsers>(
|
||||||
restrict_is_premium_, is_premium_);
|
button_id_, restrict_is_bot_, is_bot_, restrict_is_premium_, is_premium_, max_quantity_);
|
||||||
} else {
|
} else {
|
||||||
auto user_administrator_rights = restrict_user_administrator_rights_
|
auto user_administrator_rights = restrict_user_administrator_rights_
|
||||||
? user_administrator_rights_.get_chat_administrator_rights_object()
|
? user_administrator_rights_.get_chat_administrator_rights_object()
|
||||||
@ -173,6 +175,10 @@ int32 RequestedDialogType::get_button_id() const {
|
|||||||
return button_id_;
|
return button_id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 RequestedDialogType::get_max_quantity() const {
|
||||||
|
return max_quantity_;
|
||||||
|
}
|
||||||
|
|
||||||
Status RequestedDialogType::check_shared_dialog(Td *td, DialogId dialog_id) const {
|
Status RequestedDialogType::check_shared_dialog(Td *td, DialogId dialog_id) const {
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User: {
|
case DialogType::User: {
|
||||||
|
@ -22,6 +22,7 @@ class RequestedDialogType {
|
|||||||
enum class Type : int32 { User, Group, Channel };
|
enum class Type : int32 { User, Group, Channel };
|
||||||
Type type_ = Type::User;
|
Type type_ = Type::User;
|
||||||
int32 button_id_ = 0;
|
int32 button_id_ = 0;
|
||||||
|
int32 max_quantity_ = 1; // User only
|
||||||
bool restrict_is_bot_ = false; // User only
|
bool restrict_is_bot_ = false; // User only
|
||||||
bool is_bot_ = false; // User only
|
bool is_bot_ = false; // User only
|
||||||
bool restrict_is_premium_ = false; // User only
|
bool restrict_is_premium_ = false; // User only
|
||||||
@ -41,11 +42,12 @@ class RequestedDialogType {
|
|||||||
public:
|
public:
|
||||||
RequestedDialogType() = default;
|
RequestedDialogType() = default;
|
||||||
|
|
||||||
explicit RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestUser> &&request_user);
|
explicit RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestUsers> &&request_users);
|
||||||
|
|
||||||
explicit RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestChat> &&request_dialog);
|
explicit RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestChat> &&request_dialog);
|
||||||
|
|
||||||
explicit RequestedDialogType(telegram_api::object_ptr<telegram_api::RequestPeerType> &&peer_type, int32 button_id);
|
explicit RequestedDialogType(telegram_api::object_ptr<telegram_api::RequestPeerType> &&peer_type, int32 button_id,
|
||||||
|
int32 max_quantity);
|
||||||
|
|
||||||
td_api::object_ptr<td_api::KeyboardButtonType> get_keyboard_button_type_object() const;
|
td_api::object_ptr<td_api::KeyboardButtonType> get_keyboard_button_type_object() const;
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ class RequestedDialogType {
|
|||||||
|
|
||||||
int32 get_button_id() const;
|
int32 get_button_id() const;
|
||||||
|
|
||||||
|
int32 get_max_quantity() const;
|
||||||
|
|
||||||
Status check_shared_dialog(Td *td, DialogId dialog_id) const;
|
Status check_shared_dialog(Td *td, DialogId dialog_id) const;
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
|
@ -14,6 +14,7 @@ namespace td {
|
|||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void RequestedDialogType::store(StorerT &storer) const {
|
void RequestedDialogType::store(StorerT &storer) const {
|
||||||
|
bool has_max_quantity = max_quantity_ != 1;
|
||||||
BEGIN_STORE_FLAGS();
|
BEGIN_STORE_FLAGS();
|
||||||
STORE_FLAG(restrict_is_bot_);
|
STORE_FLAG(restrict_is_bot_);
|
||||||
STORE_FLAG(is_bot_);
|
STORE_FLAG(is_bot_);
|
||||||
@ -27,6 +28,7 @@ void RequestedDialogType::store(StorerT &storer) const {
|
|||||||
STORE_FLAG(is_created_);
|
STORE_FLAG(is_created_);
|
||||||
STORE_FLAG(restrict_user_administrator_rights_);
|
STORE_FLAG(restrict_user_administrator_rights_);
|
||||||
STORE_FLAG(restrict_bot_administrator_rights_);
|
STORE_FLAG(restrict_bot_administrator_rights_);
|
||||||
|
STORE_FLAG(has_max_quantity);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
td::store(type_, storer);
|
td::store(type_, storer);
|
||||||
td::store(button_id_, storer);
|
td::store(button_id_, storer);
|
||||||
@ -36,10 +38,14 @@ void RequestedDialogType::store(StorerT &storer) const {
|
|||||||
if (restrict_bot_administrator_rights_) {
|
if (restrict_bot_administrator_rights_) {
|
||||||
td::store(bot_administrator_rights_, storer);
|
td::store(bot_administrator_rights_, storer);
|
||||||
}
|
}
|
||||||
|
if (has_max_quantity) {
|
||||||
|
td::store(max_quantity_, storer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
void RequestedDialogType::parse(ParserT &parser) {
|
void RequestedDialogType::parse(ParserT &parser) {
|
||||||
|
bool has_max_quantity;
|
||||||
BEGIN_PARSE_FLAGS();
|
BEGIN_PARSE_FLAGS();
|
||||||
PARSE_FLAG(restrict_is_bot_);
|
PARSE_FLAG(restrict_is_bot_);
|
||||||
PARSE_FLAG(is_bot_);
|
PARSE_FLAG(is_bot_);
|
||||||
@ -53,6 +59,7 @@ void RequestedDialogType::parse(ParserT &parser) {
|
|||||||
PARSE_FLAG(is_created_);
|
PARSE_FLAG(is_created_);
|
||||||
PARSE_FLAG(restrict_user_administrator_rights_);
|
PARSE_FLAG(restrict_user_administrator_rights_);
|
||||||
PARSE_FLAG(restrict_bot_administrator_rights_);
|
PARSE_FLAG(restrict_bot_administrator_rights_);
|
||||||
|
PARSE_FLAG(has_max_quantity);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
td::parse(type_, parser);
|
td::parse(type_, parser);
|
||||||
td::parse(button_id_, parser);
|
td::parse(button_id_, parser);
|
||||||
@ -62,6 +69,11 @@ void RequestedDialogType::parse(ParserT &parser) {
|
|||||||
if (restrict_bot_administrator_rights_) {
|
if (restrict_bot_administrator_rights_) {
|
||||||
td::parse(bot_administrator_rights_, parser);
|
td::parse(bot_administrator_rights_, parser);
|
||||||
}
|
}
|
||||||
|
if (has_max_quantity) {
|
||||||
|
td::parse(max_quantity_, parser);
|
||||||
|
} else {
|
||||||
|
max_quantity_ = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
Loading…
x
Reference in New Issue
Block a user