Update layer 109. Add keyboardButtonTypeRequestPoll.
GitOrigin-RevId: eae6bb600cef6eb4d9386c4dc2a762d065b1fa09
This commit is contained in:
parent
f3130ea7fb
commit
fa31f168b5
@ -735,6 +735,9 @@ keyboardButtonTypeRequestPhoneNumber = KeyboardButtonType;
|
|||||||
//@description A button that sends the user's location when pressed; available only in private chats
|
//@description A button that sends the user's location when pressed; available only in private chats
|
||||||
keyboardButtonTypeRequestLocation = KeyboardButtonType;
|
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 should be allowed to create @force_quiz If true, only quiz mode polls should be allowed to create
|
||||||
|
keyboardButtonTypeRequestPoll force_regular:Bool force_quiz:Bool = KeyboardButtonType;
|
||||||
|
|
||||||
|
|
||||||
//@description Represents a single button in a bot keyboard @text Text of the button @type Type of the button
|
//@description Represents a single button in a bot keyboard @text Text of the button @type Type of the button
|
||||||
keyboardButton text:string type:KeyboardButtonType = KeyboardButton;
|
keyboardButton text:string type:KeyboardButtonType = KeyboardButton;
|
||||||
@ -1562,7 +1565,7 @@ inputMessageGame bot_user_id:int32 game_short_name:string = InputMessageContent;
|
|||||||
//@payload The invoice payload @provider_token Payment provider token @provider_data JSON-encoded data about the invoice, which will be shared with the payment provider @start_parameter Unique invoice bot start_parameter for the generation of this invoice
|
//@payload The invoice payload @provider_token Payment provider token @provider_data JSON-encoded data about the invoice, which will be shared with the payment provider @start_parameter Unique invoice bot start_parameter for the generation of this invoice
|
||||||
inputMessageInvoice invoice:invoice title:string description:string photo_url:string photo_size:int32 photo_width:int32 photo_height:int32 payload:bytes provider_token:string provider_data:string start_parameter:string = InputMessageContent;
|
inputMessageInvoice invoice:invoice title:string description:string photo_url:string photo_size:int32 photo_width:int32 photo_height:int32 payload:bytes provider_token:string provider_data:string start_parameter:string = InputMessageContent;
|
||||||
|
|
||||||
//@description A message with a poll. Polls can't be sent to secret chats. Polls can be sent to private chats only by bots @question Poll question, 1-255 characters @options List of poll answer options, 2-10 strings 1-100 characters each
|
//@description A message with a poll. Polls can't be sent to secret chats. Polls can be sent to private chats if this is a private chat with self or with a bot only @question Poll question, 1-255 characters @options List of poll answer options, 2-10 strings 1-100 characters each
|
||||||
//@is_anonymous True, if the poll voters are anonymous. Non-anonymous polls can't be sent or forwarded to channels @type Type of the poll
|
//@is_anonymous True, if the poll voters are anonymous. Non-anonymous polls can't be sent or forwarded to channels @type Type of the poll
|
||||||
inputMessagePoll question:string options:vector<string> is_anonymous:Bool type:PollType = InputMessageContent;
|
inputMessagePoll question:string options:vector<string> is_anonymous:Bool type:PollType = InputMessageContent;
|
||||||
|
|
||||||
|
Binary file not shown.
@ -534,6 +534,7 @@ keyboardButtonGame#50f41ccf text:string = KeyboardButton;
|
|||||||
keyboardButtonBuy#afd93fbb text:string = KeyboardButton;
|
keyboardButtonBuy#afd93fbb text:string = KeyboardButton;
|
||||||
keyboardButtonUrlAuth#10b78d29 flags:# text:string fwd_text:flags.0?string url:string button_id:int = KeyboardButton;
|
keyboardButtonUrlAuth#10b78d29 flags:# text:string fwd_text:flags.0?string url:string button_id:int = KeyboardButton;
|
||||||
inputKeyboardButtonUrlAuth#d02e7fd4 flags:# request_write_access:flags.0?true text:string fwd_text:flags.1?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;
|
||||||
|
keyboardButtonRequestPoll#bbc7515d flags:# quiz:flags.0?Bool text:string = KeyboardButton;
|
||||||
|
|
||||||
keyboardButtonRow#77608b83 buttons:Vector<KeyboardButton> = KeyboardButtonRow;
|
keyboardButtonRow#77608b83 buttons:Vector<KeyboardButton> = KeyboardButtonRow;
|
||||||
|
|
||||||
|
Binary file not shown.
@ -17785,8 +17785,9 @@ Status MessagesManager::can_send_message_content(DialogId dialog_id, const Messa
|
|||||||
auto content_type = content->get_type();
|
auto content_type = content->get_type();
|
||||||
switch (dialog_type) {
|
switch (dialog_type) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
if (content_type == MessageContentType::Poll && !is_forward && !td_->auth_manager_->is_bot() && !is_via_bot) {
|
if (content_type == MessageContentType::Poll && !is_forward && !td_->auth_manager_->is_bot() && !is_via_bot &&
|
||||||
return Status::Error(400, "Polls can't be sent to private chats");
|
!td_->contacts_manager_->is_user_bot(dialog_id.get_user_id()) && dialog_id != get_my_dialog_id()) {
|
||||||
|
return Status::Error(400, "Polls can't be sent to the private chat");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
|
@ -41,6 +41,15 @@ static StringBuilder &operator<<(StringBuilder &string_builder, const KeyboardBu
|
|||||||
case KeyboardButton::Type::RequestLocation:
|
case KeyboardButton::Type::RequestLocation:
|
||||||
string_builder << "RequestLocation";
|
string_builder << "RequestLocation";
|
||||||
break;
|
break;
|
||||||
|
case KeyboardButton::Type::RequestPoll:
|
||||||
|
string_builder << "RequestPoll";
|
||||||
|
break;
|
||||||
|
case KeyboardButton::Type::RequestPollQuiz:
|
||||||
|
string_builder << "RequestPollQuiz";
|
||||||
|
break;
|
||||||
|
case KeyboardButton::Type::RequestPollRegular:
|
||||||
|
string_builder << "RequestPollRegular";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -175,6 +184,20 @@ static KeyboardButton get_keyboard_button(tl_object_ptr<telegram_api::KeyboardBu
|
|||||||
button.text = std::move(keyboard_button->text_);
|
button.text = std::move(keyboard_button->text_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case telegram_api::keyboardButtonRequestPoll::ID: {
|
||||||
|
auto keyboard_button = move_tl_object_as<telegram_api::keyboardButtonRequestPoll>(keyboard_button_ptr);
|
||||||
|
if (keyboard_button->flags_ & telegram_api::keyboardButtonRequestPoll::QUIZ_MASK) {
|
||||||
|
if (keyboard_button->quiz_) {
|
||||||
|
button.type = KeyboardButton::Type::RequestPollQuiz;
|
||||||
|
} else {
|
||||||
|
button.type = KeyboardButton::Type::RequestPollRegular;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
button.type = KeyboardButton::Type::RequestPoll;
|
||||||
|
}
|
||||||
|
button.text = std::move(keyboard_button->text_);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
LOG(ERROR) << "Unsupported keyboard button: " << to_string(keyboard_button_ptr);
|
LOG(ERROR) << "Unsupported keyboard button: " << to_string(keyboard_button_ptr);
|
||||||
}
|
}
|
||||||
@ -346,16 +369,33 @@ static Result<KeyboardButton> get_keyboard_button(tl_object_ptr<td_api::keyboard
|
|||||||
break;
|
break;
|
||||||
case td_api::keyboardButtonTypeRequestPhoneNumber::ID:
|
case td_api::keyboardButtonTypeRequestPhoneNumber::ID:
|
||||||
if (!request_buttons_allowed) {
|
if (!request_buttons_allowed) {
|
||||||
return Status::Error(400, "Phone number can be requested in a private chats only");
|
return Status::Error(400, "Phone number can be requested in private chats only");
|
||||||
}
|
}
|
||||||
current_button.type = KeyboardButton::Type::RequestPhoneNumber;
|
current_button.type = KeyboardButton::Type::RequestPhoneNumber;
|
||||||
break;
|
break;
|
||||||
case td_api::keyboardButtonTypeRequestLocation::ID:
|
case td_api::keyboardButtonTypeRequestLocation::ID:
|
||||||
if (!request_buttons_allowed) {
|
if (!request_buttons_allowed) {
|
||||||
return Status::Error(400, "Location can be requested in a private chats only");
|
return Status::Error(400, "Location can be requested in private chats only");
|
||||||
}
|
}
|
||||||
current_button.type = KeyboardButton::Type::RequestLocation;
|
current_button.type = KeyboardButton::Type::RequestLocation;
|
||||||
break;
|
break;
|
||||||
|
case td_api::keyboardButtonTypeRequestPoll::ID: {
|
||||||
|
if (!request_buttons_allowed) {
|
||||||
|
return Status::Error(400, "Poll can be requested in private chats only");
|
||||||
|
}
|
||||||
|
auto *request_poll = static_cast<const td_api::keyboardButtonTypeRequestPoll *>(button->type_.get());
|
||||||
|
if (request_poll->force_quiz_ && request_poll->force_regular_) {
|
||||||
|
return Status::Error(400, "Can't force quiz mode and regular poll simultaneously");
|
||||||
|
}
|
||||||
|
if (request_poll->force_quiz_) {
|
||||||
|
current_button.type = KeyboardButton::Type::RequestPollQuiz;
|
||||||
|
} else if (request_poll->force_regular_) {
|
||||||
|
current_button.type = KeyboardButton::Type::RequestPollRegular;
|
||||||
|
} else {
|
||||||
|
current_button.type = KeyboardButton::Type::RequestPoll;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -560,6 +600,12 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_keyboard_button(const Key
|
|||||||
return make_tl_object<telegram_api::keyboardButtonRequestPhone>(keyboard_button.text);
|
return make_tl_object<telegram_api::keyboardButtonRequestPhone>(keyboard_button.text);
|
||||||
case KeyboardButton::Type::RequestLocation:
|
case KeyboardButton::Type::RequestLocation:
|
||||||
return make_tl_object<telegram_api::keyboardButtonRequestGeoLocation>(keyboard_button.text);
|
return make_tl_object<telegram_api::keyboardButtonRequestGeoLocation>(keyboard_button.text);
|
||||||
|
case KeyboardButton::Type::RequestPoll:
|
||||||
|
return make_tl_object<telegram_api::keyboardButtonRequestPoll>(0, false, keyboard_button.text);
|
||||||
|
case KeyboardButton::Type::RequestPollQuiz:
|
||||||
|
return make_tl_object<telegram_api::keyboardButtonRequestPoll>(1, true, keyboard_button.text);
|
||||||
|
case KeyboardButton::Type::RequestPollRegular:
|
||||||
|
return make_tl_object<telegram_api::keyboardButtonRequestPoll>(1, false, keyboard_button.text);
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -674,6 +720,15 @@ static tl_object_ptr<td_api::keyboardButton> get_keyboard_button_object(const Ke
|
|||||||
case KeyboardButton::Type::RequestLocation:
|
case KeyboardButton::Type::RequestLocation:
|
||||||
type = make_tl_object<td_api::keyboardButtonTypeRequestLocation>();
|
type = make_tl_object<td_api::keyboardButtonTypeRequestLocation>();
|
||||||
break;
|
break;
|
||||||
|
case KeyboardButton::Type::RequestPoll:
|
||||||
|
type = make_tl_object<td_api::keyboardButtonTypeRequestPoll>(false, false);
|
||||||
|
break;
|
||||||
|
case KeyboardButton::Type::RequestPollQuiz:
|
||||||
|
type = make_tl_object<td_api::keyboardButtonTypeRequestPoll>(false, true);
|
||||||
|
break;
|
||||||
|
case KeyboardButton::Type::RequestPollRegular:
|
||||||
|
type = make_tl_object<td_api::keyboardButtonTypeRequestPoll>(true, false);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -17,7 +17,14 @@ namespace td {
|
|||||||
|
|
||||||
struct KeyboardButton {
|
struct KeyboardButton {
|
||||||
// append only
|
// append only
|
||||||
enum class Type : int32 { Text, RequestPhoneNumber, RequestLocation };
|
enum class Type : int32 {
|
||||||
|
Text,
|
||||||
|
RequestPhoneNumber,
|
||||||
|
RequestLocation,
|
||||||
|
RequestPoll,
|
||||||
|
RequestPollQuiz,
|
||||||
|
RequestPollRegular
|
||||||
|
};
|
||||||
Type type;
|
Type type;
|
||||||
string text;
|
string text;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user