TelegramBot / Api

Native PHP Wrapper for Telegram BOT API
MIT License
1.09k stars 323 forks source link

answerInlineQuery not working? #363

Open maksutovnurda opened 2 years ago

maksutovnurda commented 2 years ago
$bot->inlineQuery(function($update) use ($bot){
    $content = new \TelegramBot\Api\Types\Inline\InputMessageContent\Text('*Test*', 'html');
    $result = new \TelegramBot\Api\Types\Inline\QueryResult\Article(time(),'Title', null,null,null,null, $content);
    $bot->answerInlineQuery($update->getId(), $result);

    $bot->sendMessage(808542421, $update->getid().$update->getQuery()); //FOR TESTING
});

No matter how much I test, no error, no result. sendMessage send inline query id, and query the itself. But $bot->answerInlineQuery don't do anything. Also code in bottom works good.

$inlineResult = [
  [
    "type" => "article",
    "id" => time(), 
    "title" => "Title",
    "input_message_content" => [
      "message_text" => "*Test*",
      "parse_mode" => "Markdown",
  ],
] ];
$uqid =  $update->getid();
file_get_contents("https://api.telegram.org/bottoken/answerInlineQuery?inline_query_id$uqid&results=".json_encode($inlineResult));
Cherry-Pie commented 2 years ago

@maksutovnurda You should pass an array of results, see https://core.telegram.org/bots/api#answerinlinequery This will work:

$bot->answerInlineQuery($update->getId(), [$result]);