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

How to use answercallbackquery? #403

Open
bilibvivo opened this issue Apr 2, 2023 · 1 comment
Open

How to use answercallbackquery? #403

bilibvivo opened this issue Apr 2, 2023 · 1 comment

Comments

@bilibvivo
Copy link

//Handle text messages
$bot->on(function (\TelegramBot\Api\Types\Update $update) use ($bot, $log) {
  $message = $update->getMessage();
  $id = $message->getChat()->getId();
  $callback_query = $update->getCallbackQuery();

  $log->info('web hook', ['message'=>$message->getText(), 'callback'=>$callback_query]);
  if ($callback_query) {
      $callback_query_data = $callback_query->getData();
      $bot->sendDocument($id, $document, $callback_query_data);
      return;
  } elseif (!stristr($message->getText(), '/s')) {
      return;
  }
  
  //handle text
   ....
}

When I click the inline button, it doesn't work.
I think CallbackQuery is not in this event listener, how should I listen to it and respond to it?

@Gramotun
Copy link

Gramotun commented Oct 12, 2023

Use this event:

$bot->callbackQuery(function (\TelegramBot\Api\Types\CallbackQuery $callback) use ($bot) {
      $message = $callback->getMessage();
      $chat_id = $message->getChat()->getId();
      $text = $message->getText();
      $callback_data = $callback->getData();
      ...
});

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