Add separate keyboardButtonTypeRequestUser.
This commit is contained in:
parent
83403d9836
commit
1afcc3bcfd
@ -1355,35 +1355,6 @@ chatActionBarSharePhoneNumber = ChatActionBar;
|
||||
chatActionBarJoinRequest title:string is_channel:Bool request_date:int32 = ChatActionBar;
|
||||
|
||||
|
||||
//@class RequestedChatType @description Describes type of a chat, which is requested in keyboardButtonTypeRequestChat
|
||||
|
||||
//@description A chat with a user was requested
|
||||
//@restrict_is_bot True, if the user must or must not be a bot
|
||||
//@is_bot True, if the user must be a bot; otherwise, the user must no be a bot. Ignored if restrict_is_bot is false
|
||||
//@restrict_is_premium True, if the user must or must not be a Telegram Premium user
|
||||
//@is_premium True, if the user must be a Telegram Premium user; otherwise, the user must no be a Telegram Premium user. Ignored if restrict_is_premium is false
|
||||
requestedChatTypePrivate restrict_is_bot:Bool is_bot:Bool restrict_is_premium:Bool is_premium:Bool = RequestedChatType;
|
||||
|
||||
//@description A basic group or a supergroup chat was requested
|
||||
//@restrict_is_forum True, if the chat must or must not be a forum
|
||||
//@is_forum True, if the chat must be a forum; otherwise, the chat must not be a forum. Ignored if restrict_is_forum is false
|
||||
//@restrict_has_username True, if the chat must or must not have a username
|
||||
//@has_username True, if the chat must have a username; otherwise, the chat must not have a username. Ignored if restrict_has_username is false
|
||||
//@is_created True, if the chat must be created by the user
|
||||
//@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
|
||||
requestedChatTypeGroup restrict_is_forum:Bool is_forum:Bool restrict_has_username:Bool has_username:Bool is_created:Bool user_administrator_rights:chatAdministratorRights bot_administrator_rights:chatAdministratorRights bot_is_member:Bool = RequestedChatType;
|
||||
|
||||
//@description A channel chat was requested
|
||||
//@restrict_has_username True, if the chat must or must not have a username
|
||||
//@has_username True, if the chat must have a username; otherwise, the chat must not have a username. Ignored if restrict_has_username is false
|
||||
//@is_created True, if the chat must be created by the user
|
||||
//@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
|
||||
requestedChatTypeChannel restrict_has_username:Bool has_username:Bool is_created:Bool user_administrator_rights:chatAdministratorRights bot_administrator_rights:chatAdministratorRights = RequestedChatType;
|
||||
|
||||
|
||||
//@class KeyboardButtonType @description Describes a keyboard button type
|
||||
|
||||
//@description A simple button, with text that must be sent when the button is pressed
|
||||
@ -1398,8 +1369,26 @@ 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 chat to be chosen by the user; available only in private chats @chat_type Type of the requested chat @id Unique button identifier
|
||||
keyboardButtonTypeRequestChat chat_type:RequestedChatType id:int32 = KeyboardButtonType;
|
||||
//@description A button that requests a user to be chosen by the current user; available only in private chats
|
||||
//@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
|
||||
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
|
||||
//@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
|
||||
//@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
|
||||
//@chat_has_username True, if the chat must have a username; otherwise, the chat must not have a username. Ignored if restrict_chat_has_username is false
|
||||
//@chat_is_created True, if the chat must be created by the current user
|
||||
//@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
|
||||
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;
|
||||
|
||||
//@description A button that opens a Web App by calling getWebAppUrl @url An HTTP URL to pass to getWebAppUrl
|
||||
keyboardButtonTypeWebApp url:string = KeyboardButtonType;
|
||||
|
@ -31,7 +31,7 @@ static constexpr int32 REPLY_MARKUP_FLAG_HAS_PLACEHOLDER = 1 << 3;
|
||||
static constexpr int32 REPLY_MARKUP_FLAG_IS_PERSISTENT = 1 << 4;
|
||||
|
||||
static bool operator==(const KeyboardButton &lhs, const KeyboardButton &rhs) {
|
||||
return lhs.type == rhs.type && lhs.text == rhs.text && lhs.url == rhs.url && lhs.button_id == rhs.button_id;
|
||||
return lhs.type == rhs.type && lhs.text == rhs.text && lhs.url == rhs.url;
|
||||
}
|
||||
|
||||
static StringBuilder &operator<<(StringBuilder &string_builder, const KeyboardButton &keyboard_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);
|
||||
button.type = KeyboardButton::Type::RequestDialog;
|
||||
button.text = std::move(keyboard_button->text_);
|
||||
button.requested_dialog_type = td::make_unique<RequestedDialogType>(std::move(keyboard_button->peer_type_));
|
||||
button.button_id = std::move(keyboard_button->button_id_);
|
||||
button.requested_dialog_type =
|
||||
td::make_unique<RequestedDialogType>(std::move(keyboard_button->peer_type_), keyboard_button->button_id_);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -499,17 +499,22 @@ static Result<KeyboardButton> get_keyboard_button(tl_object_ptr<td_api::keyboard
|
||||
current_button.url = std::move(button_type->url_);
|
||||
break;
|
||||
}
|
||||
case td_api::keyboardButtonTypeRequestUser::ID: {
|
||||
if (!request_buttons_allowed) {
|
||||
return Status::Error(400, "Users can be requested in private chats only");
|
||||
}
|
||||
auto button_type = move_tl_object_as<td_api::keyboardButtonTypeRequestUser>(button->type_);
|
||||
current_button.type = KeyboardButton::Type::RequestDialog;
|
||||
current_button.requested_dialog_type = td::make_unique<RequestedDialogType>(std::move(button_type));
|
||||
break;
|
||||
}
|
||||
case td_api::keyboardButtonTypeRequestChat::ID: {
|
||||
if (!request_buttons_allowed) {
|
||||
return Status::Error(400, "Chat can be requested in private chats only");
|
||||
return Status::Error(400, "Chats can be requested in private chats only");
|
||||
}
|
||||
auto button_type = move_tl_object_as<td_api::keyboardButtonTypeRequestChat>(button->type_);
|
||||
if (button_type->chat_type_ == nullptr) {
|
||||
return Status::Error(400, "Requested chat type must be non-null");
|
||||
}
|
||||
current_button.type = KeyboardButton::Type::RequestDialog;
|
||||
current_button.requested_dialog_type = td::make_unique<RequestedDialogType>(std::move(button_type->chat_type_));
|
||||
current_button.button_id = button_type->id_;
|
||||
current_button.requested_dialog_type = td::make_unique<RequestedDialogType>(std::move(button_type));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -774,7 +779,6 @@ unique_ptr<ReplyMarkup> dup_reply_markup(const unique_ptr<ReplyMarkup> &reply_ma
|
||||
result.text = button.text;
|
||||
result.url = button.url;
|
||||
result.requested_dialog_type = td::make_unique<RequestedDialogType>(*button.requested_dialog_type);
|
||||
result.button_id = button.button_id;
|
||||
return result;
|
||||
});
|
||||
});
|
||||
@ -801,7 +805,7 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(con
|
||||
return make_tl_object<telegram_api::keyboardButtonSimpleWebView>(keyboard_button.text, keyboard_button.url);
|
||||
case KeyboardButton::Type::RequestDialog:
|
||||
return make_tl_object<telegram_api::keyboardButtonRequestPeer>(
|
||||
keyboard_button.text, keyboard_button.button_id,
|
||||
keyboard_button.text, keyboard_button.requested_dialog_type->get_button_id(),
|
||||
keyboard_button.requested_dialog_type->get_input_request_peer_type_object());
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -946,8 +950,7 @@ static tl_object_ptr<td_api::keyboardButton> get_keyboard_button_object(const Ke
|
||||
type = make_tl_object<td_api::keyboardButtonTypeWebApp>(keyboard_button.url);
|
||||
break;
|
||||
case KeyboardButton::Type::RequestDialog:
|
||||
type = make_tl_object<td_api::keyboardButtonTypeRequestChat>(
|
||||
keyboard_button.requested_dialog_type->get_requested_chat_type_object(), keyboard_button.button_id);
|
||||
type = keyboard_button.requested_dialog_type->get_keyboard_button_type_object();
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -36,7 +36,6 @@ struct KeyboardButton {
|
||||
string text;
|
||||
string url; // WebView only
|
||||
unique_ptr<RequestedDialogType> requested_dialog_type; // RequestDialog only
|
||||
int32 button_id = 0; // RequestDialog only
|
||||
};
|
||||
|
||||
struct InlineKeyboardButton {
|
||||
|
@ -18,11 +18,9 @@ template <class StorerT>
|
||||
void store(const KeyboardButton &button, StorerT &storer) {
|
||||
bool has_url = !button.url.empty();
|
||||
bool has_requested_dialog_type = button.requested_dialog_type != nullptr;
|
||||
bool has_button_id = button.button_id != 0;
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_url);
|
||||
STORE_FLAG(has_requested_dialog_type);
|
||||
STORE_FLAG(has_button_id);
|
||||
END_STORE_FLAGS();
|
||||
store(button.type, storer);
|
||||
store(button.text, storer);
|
||||
@ -32,26 +30,20 @@ void store(const KeyboardButton &button, StorerT &storer) {
|
||||
if (has_requested_dialog_type) {
|
||||
store(button.requested_dialog_type, storer);
|
||||
}
|
||||
if (has_button_id) {
|
||||
store(button.button_id, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(KeyboardButton &button, ParserT &parser) {
|
||||
bool has_url;
|
||||
bool has_requested_dialog_type;
|
||||
bool has_button_id;
|
||||
if (parser.version() >= static_cast<int32>(Version::AddKeyboardButtonFlags)) {
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_url);
|
||||
PARSE_FLAG(has_requested_dialog_type);
|
||||
PARSE_FLAG(has_button_id);
|
||||
END_PARSE_FLAGS();
|
||||
} else {
|
||||
has_url = false;
|
||||
has_requested_dialog_type = false;
|
||||
has_button_id = false;
|
||||
}
|
||||
parse(button.type, parser);
|
||||
parse(button.text, parser);
|
||||
@ -61,9 +53,6 @@ void parse(KeyboardButton &button, ParserT &parser) {
|
||||
if (has_requested_dialog_type) {
|
||||
parse(button.requested_dialog_type, parser);
|
||||
}
|
||||
if (has_button_id) {
|
||||
parse(button.button_id, parser);
|
||||
}
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
|
@ -8,14 +8,17 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::RequestedChatType> &&chat_type) {
|
||||
RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestUser> &&request_user) {
|
||||
}
|
||||
|
||||
RequestedDialogType::RequestedDialogType(telegram_api::object_ptr<telegram_api::RequestPeerType> &&chat_type) {
|
||||
RequestedDialogType::RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestChat> &&request_dialog) {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::RequestedChatType> RequestedDialogType::get_requested_chat_type_object() const {
|
||||
return td_api::make_object<td_api::requestedChatTypePrivate>();
|
||||
RequestedDialogType::RequestedDialogType(telegram_api::object_ptr<telegram_api::RequestPeerType> &&chat_type, int32 button_id) {
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::KeyboardButtonType> RequestedDialogType::get_keyboard_button_type_object() const {
|
||||
return td_api::make_object<td_api::keyboardButtonTypeRequestUser>(0, false, false, false, false);
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::RequestPeerType> RequestedDialogType::get_input_request_peer_type_object()
|
||||
@ -23,4 +26,8 @@ telegram_api::object_ptr<telegram_api::RequestPeerType> RequestedDialogType::get
|
||||
return telegram_api::make_object<telegram_api::requestPeerTypeUser>(0, false, false);
|
||||
}
|
||||
|
||||
int32 RequestedDialogType::get_button_id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -17,14 +17,18 @@ class RequestedDialogType {
|
||||
public:
|
||||
RequestedDialogType() = default;
|
||||
|
||||
explicit RequestedDialogType(td_api::object_ptr<td_api::RequestedChatType> &&chat_type);
|
||||
explicit RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestUser> &&request_user);
|
||||
|
||||
explicit RequestedDialogType(telegram_api::object_ptr<telegram_api::RequestPeerType> &&peer_type);
|
||||
explicit RequestedDialogType(td_api::object_ptr<td_api::keyboardButtonTypeRequestChat> &&request_dialog);
|
||||
|
||||
td_api::object_ptr<td_api::RequestedChatType> get_requested_chat_type_object() const;
|
||||
explicit RequestedDialogType(telegram_api::object_ptr<telegram_api::RequestPeerType> &&peer_type, int32 button_id);
|
||||
|
||||
td_api::object_ptr<td_api::KeyboardButtonType> get_keyboard_button_type_object() const;
|
||||
|
||||
telegram_api::object_ptr<telegram_api::RequestPeerType> get_input_request_peer_type_object() const;
|
||||
|
||||
int32 get_button_id() const;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user