How to make a simple inline Bot using tgbot-cpp? #318
|
Hello! I want to make inline Feature for My own Bot, but I actually can't figure out how to do this... I've tried to search in there or somewhere else in the Internet... anything that can help Me, but for C++ I didn't find it... Thanks for the Answer in advance! |
Answered by
reo7sp
Sep 14, 2026
Replies: 1 comment
|
First enable inline mode for the bot in @Botfather. Then handle bot.getEvents().onInlineQuery([&bot](TgBot::InlineQuery::Ptr query) {
auto text = std::make_shared<TgBot::InputTextMessageContent>();
text->messageText = "You entered: " + query->query;
auto content = std::make_shared<TgBot::InputMessageContent>();
content->value = text;
auto article = std::make_shared<TgBot::InlineQueryResultArticle>();
article->id = "text-result";
article->title = "Send result";
article->inputMessageContent = content;
auto result = std::make_shared<TgBot::InlineQueryResult>();
result->value = article;
bot.getApi().answerInlineQuery(query->id, {result}, 0, true);
});The user invokes it as |
0 replies
Answer selected by
reo7sp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First enable inline mode for the bot in @Botfather. Then handle
InlineQuery, create an article result, and pass it toanswerInlineQuery:bot.getEvents().onInlineQuery([&bot](TgBot::InlineQuery::Ptr query) { auto text = std::make_shared<TgBot::InputTextMessageContent>(); text->messageText = "You entered: " + query->query; auto content = std::make_shared<TgBot::InputMessageContent>(); content->value = text; auto article = std::make_shared<TgBot::InlineQueryResultArticle>(); article->id = "text-result"; article->title = "Send result"; article->inputMessageContent = content; auto result = std::make_shared<TgBot::InlineQueryResult>(); result->value = …