|
|
|
@ -9059,21 +9059,16 @@ td::Result<Client::InputReplyParameters> Client::get_reply_parameters(td::JsonVa
|
|
|
|
return std::move(result);
|
|
|
|
return std::move(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
td::Result<td_api::object_ptr<td_api::keyboardButton>> Client::get_keyboard_button(td::JsonValue &button) {
|
|
|
|
td::Result<td_api::object_ptr<td_api::KeyboardButtonType>> Client::get_keyboard_button_type(td::JsonObject &object) {
|
|
|
|
if (button.type() == td::JsonValue::Type::Object) {
|
|
|
|
|
|
|
|
auto &object = button.get_object();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TRY_RESULT(text, object.get_required_string_field("text"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TRY_RESULT(request_phone_number, object.get_optional_bool_field("request_phone_number"));
|
|
|
|
TRY_RESULT(request_phone_number, object.get_optional_bool_field("request_phone_number"));
|
|
|
|
TRY_RESULT(request_contact, object.get_optional_bool_field("request_contact"));
|
|
|
|
TRY_RESULT(request_contact, object.get_optional_bool_field("request_contact"));
|
|
|
|
if (request_phone_number || request_contact) {
|
|
|
|
if (request_phone_number || request_contact) {
|
|
|
|
return make_object<td_api::keyboardButton>(text, make_object<td_api::keyboardButtonTypeRequestPhoneNumber>());
|
|
|
|
return make_object<td_api::keyboardButtonTypeRequestPhoneNumber>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TRY_RESULT(request_location, object.get_optional_bool_field("request_location"));
|
|
|
|
TRY_RESULT(request_location, object.get_optional_bool_field("request_location"));
|
|
|
|
if (request_location) {
|
|
|
|
if (request_location) {
|
|
|
|
return make_object<td_api::keyboardButton>(text, make_object<td_api::keyboardButtonTypeRequestLocation>());
|
|
|
|
return make_object<td_api::keyboardButtonTypeRequestLocation>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (object.has_field("request_poll")) {
|
|
|
|
if (object.has_field("request_poll")) {
|
|
|
|
@ -9089,15 +9084,14 @@ td::Result<td_api::object_ptr<td_api::keyboardButton>> Client::get_keyboard_butt
|
|
|
|
force_regular = true;
|
|
|
|
force_regular = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return make_object<td_api::keyboardButton>(
|
|
|
|
return make_object<td_api::keyboardButtonTypeRequestPoll>(force_regular, force_quiz);
|
|
|
|
text, make_object<td_api::keyboardButtonTypeRequestPoll>(force_regular, force_quiz));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (object.has_field("web_app")) {
|
|
|
|
if (object.has_field("web_app")) {
|
|
|
|
TRY_RESULT(web_app, object.extract_required_field("web_app", td::JsonValue::Type::Object));
|
|
|
|
TRY_RESULT(web_app, object.extract_required_field("web_app", td::JsonValue::Type::Object));
|
|
|
|
auto &web_app_object = web_app.get_object();
|
|
|
|
auto &web_app_object = web_app.get_object();
|
|
|
|
TRY_RESULT(url, web_app_object.get_required_string_field("url"));
|
|
|
|
TRY_RESULT(url, web_app_object.get_required_string_field("url"));
|
|
|
|
return make_object<td_api::keyboardButton>(text, make_object<td_api::keyboardButtonTypeWebApp>(url));
|
|
|
|
return make_object<td_api::keyboardButtonTypeWebApp>(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (object.has_field("request_user") || object.has_field("request_users")) {
|
|
|
|
if (object.has_field("request_user") || object.has_field("request_users")) {
|
|
|
|
@ -9117,10 +9111,9 @@ td::Result<td_api::object_ptr<td_api::keyboardButton>> Client::get_keyboard_butt
|
|
|
|
TRY_RESULT(request_name, request_user_object.get_optional_bool_field("request_name"));
|
|
|
|
TRY_RESULT(request_name, request_user_object.get_optional_bool_field("request_name"));
|
|
|
|
TRY_RESULT(request_username, request_user_object.get_optional_bool_field("request_username"));
|
|
|
|
TRY_RESULT(request_username, request_user_object.get_optional_bool_field("request_username"));
|
|
|
|
TRY_RESULT(request_photo, request_user_object.get_optional_bool_field("request_photo"));
|
|
|
|
TRY_RESULT(request_photo, request_user_object.get_optional_bool_field("request_photo"));
|
|
|
|
return make_object<td_api::keyboardButton>(
|
|
|
|
return make_object<td_api::keyboardButtonTypeRequestUsers>(id, restrict_user_is_bot, user_is_bot,
|
|
|
|
text, make_object<td_api::keyboardButtonTypeRequestUsers>(
|
|
|
|
restrict_user_is_premium, user_is_premium, max_quantity,
|
|
|
|
id, restrict_user_is_bot, user_is_bot, restrict_user_is_premium, user_is_premium, max_quantity,
|
|
|
|
request_name, request_username, request_photo);
|
|
|
|
request_name, request_username, request_photo));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (object.has_field("request_chat")) {
|
|
|
|
if (object.has_field("request_chat")) {
|
|
|
|
@ -9135,8 +9128,7 @@ td::Result<td_api::object_ptr<td_api::keyboardButton>> Client::get_keyboard_butt
|
|
|
|
TRY_RESULT(chat_is_created, request_chat_object.get_optional_bool_field("chat_is_created"));
|
|
|
|
TRY_RESULT(chat_is_created, request_chat_object.get_optional_bool_field("chat_is_created"));
|
|
|
|
object_ptr<td_api::chatAdministratorRights> user_administrator_rights;
|
|
|
|
object_ptr<td_api::chatAdministratorRights> user_administrator_rights;
|
|
|
|
if (request_chat_object.has_field("user_administrator_rights")) {
|
|
|
|
if (request_chat_object.has_field("user_administrator_rights")) {
|
|
|
|
TRY_RESULT_ASSIGN(
|
|
|
|
TRY_RESULT_ASSIGN(user_administrator_rights,
|
|
|
|
user_administrator_rights,
|
|
|
|
|
|
|
|
get_chat_administrator_rights(request_chat_object.extract_field("user_administrator_rights")));
|
|
|
|
get_chat_administrator_rights(request_chat_object.extract_field("user_administrator_rights")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
object_ptr<td_api::chatAdministratorRights> bot_administrator_rights;
|
|
|
|
object_ptr<td_api::chatAdministratorRights> bot_administrator_rights;
|
|
|
|
@ -9148,15 +9140,22 @@ td::Result<td_api::object_ptr<td_api::keyboardButton>> Client::get_keyboard_butt
|
|
|
|
TRY_RESULT(request_title, request_chat_object.get_optional_bool_field("request_title"));
|
|
|
|
TRY_RESULT(request_title, request_chat_object.get_optional_bool_field("request_title"));
|
|
|
|
TRY_RESULT(request_username, request_chat_object.get_optional_bool_field("request_username"));
|
|
|
|
TRY_RESULT(request_username, request_chat_object.get_optional_bool_field("request_username"));
|
|
|
|
TRY_RESULT(request_photo, request_chat_object.get_optional_bool_field("request_photo"));
|
|
|
|
TRY_RESULT(request_photo, request_chat_object.get_optional_bool_field("request_photo"));
|
|
|
|
return make_object<td_api::keyboardButton>(
|
|
|
|
return make_object<td_api::keyboardButtonTypeRequestChat>(
|
|
|
|
text,
|
|
|
|
|
|
|
|
make_object<td_api::keyboardButtonTypeRequestChat>(
|
|
|
|
|
|
|
|
id, chat_is_channel, restrict_chat_is_forum, chat_is_forum, restrict_chat_has_username, chat_has_username,
|
|
|
|
id, chat_is_channel, restrict_chat_is_forum, chat_is_forum, restrict_chat_has_username, chat_has_username,
|
|
|
|
chat_is_created, std::move(user_administrator_rights), std::move(bot_administrator_rights), bot_is_member,
|
|
|
|
chat_is_created, std::move(user_administrator_rights), std::move(bot_administrator_rights), bot_is_member,
|
|
|
|
request_title, request_username, request_photo));
|
|
|
|
request_title, request_username, request_photo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return make_object<td_api::keyboardButton>(text, nullptr);
|
|
|
|
td::Result<td_api::object_ptr<td_api::keyboardButton>> Client::get_keyboard_button(td::JsonValue &button) {
|
|
|
|
|
|
|
|
if (button.type() == td::JsonValue::Type::Object) {
|
|
|
|
|
|
|
|
auto &object = button.get_object();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TRY_RESULT(text, object.get_required_string_field("text"));
|
|
|
|
|
|
|
|
TRY_RESULT(type, get_keyboard_button_type(object));
|
|
|
|
|
|
|
|
return make_object<td_api::keyboardButton>(text, std::move(type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (button.type() == td::JsonValue::Type::String) {
|
|
|
|
if (button.type() == td::JsonValue::Type::String) {
|
|
|
|
return make_object<td_api::keyboardButton>(button.get_string().str(), nullptr);
|
|
|
|
return make_object<td_api::keyboardButton>(button.get_string().str(), nullptr);
|
|
|
|
|