From e636a6db45a9c86c7ccdd710effd9feb971f283a Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 11 Jan 2023 20:39:34 +0300 Subject: [PATCH] Support "request_user" keyboard buttons. --- telegram-bot-api/Client.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index cec3a52..130e36c 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -5349,6 +5349,19 @@ td::Result> Client::get_keyboard_butt return make_object(text, make_object(url)); } + if (has_json_object_field(object, "request_user")) { + TRY_RESULT(request_user, get_json_object_field(object, "request_user", JsonValue::Type::Object, false)); + auto &request_user_object = request_user.get_object(); + TRY_RESULT(id, get_json_object_int_field(request_user_object, "request_id", false)); + auto restrict_user_is_bot = has_json_object_field(request_user_object, "user_is_bot"); + TRY_RESULT(user_is_bot, get_json_object_bool_field(request_user_object, "user_is_bot")); + auto restrict_user_is_premium = has_json_object_field(request_user_object, "user_is_premium"); + TRY_RESULT(user_is_premium, get_json_object_bool_field(request_user_object, "user_is_premium")); + return make_object( + text, make_object(id, restrict_user_is_bot, user_is_bot, + restrict_user_is_premium, user_is_premium)); + } + return make_object(text, nullptr); } if (button.type() == JsonValue::Type::String) {