diff --git a/tests/manual_tests.cpp b/tests/manual_tests.cpp index b54228d9b..3b7aec04b 100644 --- a/tests/manual_tests.cpp +++ b/tests/manual_tests.cpp @@ -5,6 +5,7 @@ #include "tgbotxx/objects/WebhookInfo.hpp" #include #include +#include #include #include @@ -338,9 +339,28 @@ class MyBot : public Bot { void onEditedMessage(const Ptr& editedMessage) override { std::cout << __func__ << ": " << editedMessage->text << std::endl; } - /// Called when a new incoming inline query is received + /// Called when a new incoming inline query is received (when user writes in the chat text box: @botname QUERY) void onInlineQuery(const Ptr& inlineQuery) override { std::cout << __func__ << ": " << inlineQuery->query << std::endl; + std::string query = inlineQuery->query; + + if(query.starts_with("photo")) { + std::vector> inlineQueryResults; + for (const std::string_view photoURL: {"https://images.alphacoders.com/129/1299740.jpg", + "https://images2.alphacoders.com/112/1128233.jpg", + "https://images2.alphacoders.com/131/1311487.jpg"}) { + auto photoPtr = makePtr(); + photoPtr->id = StringUtils::random(16); + photoPtr->photoUrl = photoURL; + photoPtr->thumbnailUrl = photoURL; + inlineQueryResults.push_back(std::move(photoPtr)); + } + try { + api()->answerInlineQuery(inlineQuery->id, inlineQueryResults, 300, ""); + } catch(const std::exception& e) { + std::cerr << e.what() << std::endl; + } + } } /// Called when the result of an inline query that was chosen by a user and sent to their chat partner. void onChosenInlineResult(const Ptr& chosenInlineResult) override {