From 14c15fca85216b04c5c8bc5867218624d7322eaa Mon Sep 17 00:00:00 2001 From: Slavasil Date: Fri, 18 Oct 2024 22:31:05 +0300 Subject: [PATCH] add support for updateChosenInlineResult --- commands.cpp | 18 ++++++++++++++++++ commands.h | 1 + main.cpp | 3 +++ 3 files changed, 22 insertions(+) diff --git a/commands.cpp b/commands.cpp index c1caffb..896a514 100644 --- a/commands.cpp +++ b/commands.cpp @@ -164,6 +164,24 @@ void cmd::handle_callback_query(context *ctx, td_api::updateNewInlineCallbackQue } } +void cmd::handle_chosen_inline_result(context *ctx, td_api::updateNewChosenInlineResult &result) { + shorten_link(result.query_, ctx, [ctx, inlineMessageId = result.inline_message_id_](std::string url){ + ctx->tg->send_query(td_api::make_object( + inlineMessageId, + nullptr, // reply_markup + static_cast>(td_api::make_object( + td_api::make_object( + url, + std::move(std::vector>()) + ), + td_api::make_object(true, "", false, false, false), + //nullptr, + false + )) + ), {}); + }); +} + bool cmd::shorten_link(std::string link, context *ctx, std::function cb) { spdlog::debug("creating CURL request"); CURL *req = curl_easy_init(); diff --git a/commands.h b/commands.h index 9fa2c5f..4900926 100644 --- a/commands.h +++ b/commands.h @@ -8,6 +8,7 @@ namespace cmd { void handle_regular_message(context *ctx, td_api::message &msg); void handle_inline_query(context *ctx, td_api::updateNewInlineQuery &query); void handle_callback_query(context *ctx, td_api::updateNewInlineCallbackQuery &query); + void handle_chosen_inline_result(context *ctx, td_api::updateNewChosenInlineResult &result); bool shorten_link(std::string link, context *ctx, std::function cb); uint64_t new_pending_query_id(); diff --git a/main.cpp b/main.cpp index 6d3e6ba..ff01974 100644 --- a/main.cpp +++ b/main.cpp @@ -142,6 +142,9 @@ void async_startup(uv_idle_t *h) { [ctx](td_api::updateNewInlineCallbackQuery &upd) { cmd::handle_callback_query(ctx, upd); }, + [ctx](td_api::updateNewChosenInlineResult &upd) { + cmd::handle_chosen_inline_result(ctx, upd); + }, [](td_api::Object &obj){} )); }, nullptr);