Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

answerInlineQuery not working? #363

Open
maksutovnurda opened this issue Jan 13, 2022 · 1 comment
Open

answerInlineQuery not working? #363

maksutovnurda opened this issue Jan 13, 2022 · 1 comment

Comments

@maksutovnurda
Copy link

maksutovnurda commented Jan 13, 2022

$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
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants