From c3c8f112ee91ba6eeca8cd654de07cc253b15c2c Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 11 Jan 2023 20:50:43 +0300 Subject: [PATCH] Support "request_chat" keyboard buttons. --- telegram-bot-api/Client.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 130e36c..09c645c 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -5362,6 +5362,34 @@ td::Result> Client::get_keyboard_butt restrict_user_is_premium, user_is_premium)); } + if (has_json_object_field(object, "request_chat")) { + TRY_RESULT(request_chat, get_json_object_field(object, "request_chat", JsonValue::Type::Object, false)); + auto &request_chat_object = request_chat.get_object(); + TRY_RESULT(id, get_json_object_int_field(request_chat_object, "request_id", false)); + TRY_RESULT(chat_is_channel, get_json_object_bool_field(request_chat_object, "chat_is_channel")); + auto restrict_chat_is_forum = has_json_object_field(request_chat_object, "chat_is_forum"); + TRY_RESULT(chat_is_forum, get_json_object_bool_field(request_chat_object, "chat_is_forum")); + auto restrict_chat_has_username = has_json_object_field(request_chat_object, "chat_has_username"); + TRY_RESULT(chat_has_username, get_json_object_bool_field(request_chat_object, "chat_has_username")); + TRY_RESULT(chat_is_created, get_json_object_bool_field(request_chat_object, "chat_is_created")); + td_api::object_ptr user_administrator_rights; + if (has_json_object_field(request_chat_object, "user_administrator_rights")) { + TRY_RESULT_ASSIGN(user_administrator_rights, get_chat_administrator_rights(get_json_object_field_force( + request_chat_object, "user_administrator_rights"))); + } + td_api::object_ptr bot_administrator_rights; + if (has_json_object_field(request_chat_object, "bot_administrator_rights")) { + TRY_RESULT_ASSIGN(bot_administrator_rights, get_chat_administrator_rights(get_json_object_field_force( + request_chat_object, "bot_administrator_rights"))); + } + TRY_RESULT(bot_is_member, get_json_object_bool_field(request_chat_object, "bot_is_member")); + return make_object( + text, make_object( + 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)); + } + return make_object(text, nullptr); } if (button.type() == JsonValue::Type::String) {