|
|
|
@ -11052,6 +11052,48 @@ td::Result<td_api::object_ptr<td_api::TextEntityType>> Client::get_text_entity_t
|
|
|
|
if (type == "expandable_blockquote") {
|
|
|
|
if (type == "expandable_blockquote") {
|
|
|
|
return make_object<td_api::textEntityTypeExpandableBlockQuote>();
|
|
|
|
return make_object<td_api::textEntityTypeExpandableBlockQuote>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == "date_time") {
|
|
|
|
|
|
|
|
TRY_RESULT(unix_time, object.get_required_int_field("unix_time"));
|
|
|
|
|
|
|
|
TRY_RESULT(format, object.get_optional_string_field("date_time_format"));
|
|
|
|
|
|
|
|
bool is_invalid = false;
|
|
|
|
|
|
|
|
auto formatting_type = [&format, &is_invalid]() -> object_ptr<td_api::DateTimeFormattingType> {
|
|
|
|
|
|
|
|
if (format.empty()) {
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format == "r" || format == "R") {
|
|
|
|
|
|
|
|
return make_object<td_api::dateTimeFormattingTypeRelative>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
auto result = make_object<td_api::dateTimeFormattingTypeAbsolute>();
|
|
|
|
|
|
|
|
for (auto c : format) {
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
|
|
|
|
case 't':
|
|
|
|
|
|
|
|
result->time_precision_ = make_object<td_api::dateTimePartPrecisionShort>();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T':
|
|
|
|
|
|
|
|
result->time_precision_ = make_object<td_api::dateTimePartPrecisionLong>();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
|
|
|
|
result->date_precision_ = make_object<td_api::dateTimePartPrecisionShort>();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'D':
|
|
|
|
|
|
|
|
result->date_precision_ = make_object<td_api::dateTimePartPrecisionLong>();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'w':
|
|
|
|
|
|
|
|
case 'W':
|
|
|
|
|
|
|
|
result->show_day_of_week_ = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
is_invalid = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::move(result);
|
|
|
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
if (is_invalid) {
|
|
|
|
|
|
|
|
return td::Status::Error(400, "Invalid date-time format specified");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return make_object<td_api::textEntityTypeDateTime>(unix_time, std::move(formatting_type));
|
|
|
|
|
|
|
|
}
|
|
|
|
if (type == "mention" || type == "hashtag" || type == "cashtag" || type == "bot_command" || type == "url" ||
|
|
|
|
if (type == "mention" || type == "hashtag" || type == "cashtag" || type == "bot_command" || type == "url" ||
|
|
|
|
type == "email" || type == "phone_number" || type == "bank_card_number") {
|
|
|
|
type == "email" || type == "phone_number" || type == "bank_card_number") {
|
|
|
|
return nullptr;
|
|
|
|
return nullptr;
|
|
|
|
|