Support forwsrd text for login URL buttons.
GitOrigin-RevId: c5682599198cacfd7b7945f6b43e6af4ded4aedf
This commit is contained in:
parent
55fd1c30af
commit
5e8be86d9f
@ -643,8 +643,8 @@ keyboardButton text:string type:KeyboardButtonType = KeyboardButton;
|
|||||||
//@description A button that opens a specified URL @url HTTP or tg:// URL to open
|
//@description A button that opens a specified URL @url HTTP or tg:// URL to open
|
||||||
inlineKeyboardButtonTypeUrl url:string = InlineKeyboardButtonType;
|
inlineKeyboardButtonTypeUrl url:string = InlineKeyboardButtonType;
|
||||||
|
|
||||||
//@description A button that opens a specified URL and automatically logs in in current user if they allowed to do that @url HTTP URL to open @id Unique button identifier
|
//@description A button that opens a specified URL and automatically logs in in current user if they allowed to do that @url HTTP URL to open @id Unique button identifier @forward_text If non-empty, new text of the button in forwarded messages
|
||||||
inlineKeyboardButtonTypeLoginUrl url:string id:int32 = InlineKeyboardButtonType;
|
inlineKeyboardButtonTypeLoginUrl url:string id:int32 forward_text:string = InlineKeyboardButtonType;
|
||||||
|
|
||||||
//@description A button that sends a special callback query to a bot @data Data to be sent to the bot via a callback query
|
//@description A button that sends a special callback query to a bot @data Data to be sent to the bot via a callback query
|
||||||
inlineKeyboardButtonTypeCallback data:bytes = InlineKeyboardButtonType;
|
inlineKeyboardButtonTypeCallback data:bytes = InlineKeyboardButtonType;
|
||||||
|
Binary file not shown.
@ -512,8 +512,8 @@ keyboardButtonRequestGeoLocation#fc796b3f text:string = KeyboardButton;
|
|||||||
keyboardButtonSwitchInline#568a748 flags:# same_peer:flags.0?true text:string query:string = KeyboardButton;
|
keyboardButtonSwitchInline#568a748 flags:# same_peer:flags.0?true text:string query:string = KeyboardButton;
|
||||||
keyboardButtonGame#50f41ccf text:string = KeyboardButton;
|
keyboardButtonGame#50f41ccf text:string = KeyboardButton;
|
||||||
keyboardButtonBuy#afd93fbb text:string = KeyboardButton;
|
keyboardButtonBuy#afd93fbb text:string = KeyboardButton;
|
||||||
keyboardButtonUrlAuth#77a34975 text:string url:string button_id:int = KeyboardButton;
|
keyboardButtonUrlAuth#10b78d29 flags:# text:string fwd_text:flags.0?string url:string button_id:int = KeyboardButton;
|
||||||
inputKeyboardButtonUrlAuth#af24bb74 flags:# request_write_access:flags.0?true text:string url:string bot:InputUser = KeyboardButton;
|
inputKeyboardButtonUrlAuth#d02e7fd4 flags:# request_write_access:flags.0?true text:string fwd_text:flags.1?string url:string bot:InputUser = KeyboardButton;
|
||||||
|
|
||||||
keyboardButtonRow#77608b83 buttons:Vector<KeyboardButton> = KeyboardButtonRow;
|
keyboardButtonRow#77608b83 buttons:Vector<KeyboardButton> = KeyboardButtonRow;
|
||||||
|
|
||||||
|
Binary file not shown.
@ -18129,6 +18129,10 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
|
|||||||
if (button.type == InlineKeyboardButton::Type::SwitchInlineCurrentDialog) {
|
if (button.type == InlineKeyboardButton::Type::SwitchInlineCurrentDialog) {
|
||||||
button.type = InlineKeyboardButton::Type::SwitchInline;
|
button.type = InlineKeyboardButton::Type::SwitchInline;
|
||||||
}
|
}
|
||||||
|
if (!button.forward_text.empty()) {
|
||||||
|
button.text = std::move(button.forward_text);
|
||||||
|
button.forward_text.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,9 @@ static InlineKeyboardButton get_inline_keyboard_button(
|
|||||||
button.id = keyboard_button->button_id_;
|
button.id = keyboard_button->button_id_;
|
||||||
button.text = std::move(keyboard_button->text_);
|
button.text = std::move(keyboard_button->text_);
|
||||||
button.data = std::move(keyboard_button->url_);
|
button.data = std::move(keyboard_button->url_);
|
||||||
|
if ((keyboard_button->flags_ & telegram_api::keyboardButtonUrlAuth::FWD_TEXT_MASK) != 0) {
|
||||||
|
button.forward_text = std::move(keyboard_button->fwd_text_);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -419,8 +422,12 @@ static Result<InlineKeyboardButton> get_inline_keyboard_button(tl_object_ptr<td_
|
|||||||
auto login_url = td_api::move_object_as<td_api::inlineKeyboardButtonTypeLoginUrl>(button->type_);
|
auto login_url = td_api::move_object_as<td_api::inlineKeyboardButtonTypeLoginUrl>(button->type_);
|
||||||
TRY_RESULT(url, check_url(login_url->url_));
|
TRY_RESULT(url, check_url(login_url->url_));
|
||||||
current_button.data = std::move(url);
|
current_button.data = std::move(url);
|
||||||
|
current_button.forward_text = std::move(login_url->forward_text_);
|
||||||
if (!clean_input_string(current_button.data)) {
|
if (!clean_input_string(current_button.data)) {
|
||||||
return Status::Error(400, "Inline keyboard button url must be encoded in UTF-8");
|
return Status::Error(400, "Inline keyboard button login url must be encoded in UTF-8");
|
||||||
|
}
|
||||||
|
if (!clean_input_string(current_button.forward_text)) {
|
||||||
|
return Status::Error(400, "Inline keyboard button forward text must be encoded in UTF-8");
|
||||||
}
|
}
|
||||||
current_button.id = login_url->id_;
|
current_button.id = login_url->id_;
|
||||||
if (current_button.id == 0 || current_button.id == std::numeric_limits<int32>::min()) {
|
if (current_button.id == 0 || current_button.id == std::numeric_limits<int32>::min()) {
|
||||||
@ -589,12 +596,16 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_inline_keyboard_button(
|
|||||||
} else {
|
} else {
|
||||||
bot_user_id = -bot_user_id;
|
bot_user_id = -bot_user_id;
|
||||||
}
|
}
|
||||||
|
if (!keyboard_button.forward_text.empty()) {
|
||||||
|
flags |= telegram_api::inputKeyboardButtonUrlAuth::FWD_TEXT_MASK;
|
||||||
|
}
|
||||||
auto input_user = G()->td().get_actor_unsafe()->contacts_manager_->get_input_user(UserId(bot_user_id));
|
auto input_user = G()->td().get_actor_unsafe()->contacts_manager_->get_input_user(UserId(bot_user_id));
|
||||||
if (input_user == nullptr) {
|
if (input_user == nullptr) {
|
||||||
LOG(ERROR) << "Failed to get InputUser for " << bot_user_id;
|
LOG(ERROR) << "Failed to get InputUser for " << bot_user_id;
|
||||||
return make_tl_object<telegram_api::keyboardButtonUrl>(keyboard_button.text, keyboard_button.data);
|
return make_tl_object<telegram_api::keyboardButtonUrl>(keyboard_button.text, keyboard_button.data);
|
||||||
}
|
}
|
||||||
return make_tl_object<telegram_api::inputKeyboardButtonUrlAuth>(flags, false /*ignored*/, keyboard_button.text,
|
return make_tl_object<telegram_api::inputKeyboardButtonUrlAuth>(flags, false /*ignored*/, keyboard_button.text,
|
||||||
|
keyboard_button.forward_text,
|
||||||
keyboard_button.data, std::move(input_user));
|
keyboard_button.data, std::move(input_user));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -694,7 +705,8 @@ static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_ob
|
|||||||
type = make_tl_object<td_api::inlineKeyboardButtonTypeBuy>();
|
type = make_tl_object<td_api::inlineKeyboardButtonTypeBuy>();
|
||||||
break;
|
break;
|
||||||
case InlineKeyboardButton::Type::UrlAuth:
|
case InlineKeyboardButton::Type::UrlAuth:
|
||||||
type = make_tl_object<td_api::inlineKeyboardButtonTypeLoginUrl>(keyboard_button.data, keyboard_button.id);
|
type = make_tl_object<td_api::inlineKeyboardButtonTypeLoginUrl>(keyboard_button.data, keyboard_button.id,
|
||||||
|
keyboard_button.forward_text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -28,6 +28,7 @@ struct InlineKeyboardButton {
|
|||||||
Type type;
|
Type type;
|
||||||
int32 id = 0; // UrlAuth only, button_id or (2 * request_write_access - 1) * bot_user_id
|
int32 id = 0; // UrlAuth only, button_id or (2 * request_write_access - 1) * bot_user_id
|
||||||
string text;
|
string text;
|
||||||
|
string forward_text; // UrlAuth only
|
||||||
string data;
|
string data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user