diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index a44a894..ec988f5 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -11052,6 +11052,48 @@ td::Result> Client::get_text_entity_t if (type == "expandable_blockquote") { return make_object(); } + 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 { + if (format.empty()) { + return nullptr; + } + if (format == "r" || format == "R") { + return make_object(); + } + auto result = make_object(); + for (auto c : format) { + switch (c) { + case 't': + result->time_precision_ = make_object(); + break; + case 'T': + result->time_precision_ = make_object(); + break; + case 'd': + result->date_precision_ = make_object(); + break; + case 'D': + result->date_precision_ = make_object(); + 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(unix_time, std::move(formatting_type)); + } if (type == "mention" || type == "hashtag" || type == "cashtag" || type == "bot_command" || type == "url" || type == "email" || type == "phone_number" || type == "bank_card_number") { return nullptr;