Answer the question
In order to leave comments, you need to log in
Telegram Bot: How to get not only a callback from inlinekeyboard, but also a manually entered message?
Bot using telegram-bot/api. There is a code (abbreviated):
<?php
include('vendor/autoload.php');
include('admin/include/database.php');
function startMess($bot, $message, $db)
{
...
foreach ($arDBStreets as $arDBStreet) {
$arStreets[] = [
['callback_data' => 'street__' . $arDBStreet['id'], 'text' => ' ' . $arDBStreet['name']]
];
}
$arStreets[] = [
['callback_data' => 'message__1', 'text' => 'Перейти к разделам']
];
$keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup($arStreets);
$sendedStartMessage = $bot->sendMessage($message->getChat()->getId(), $mess, false, null, null, $keyboard);
...
}
...
try {
$bot = new \TelegramBot\Api\Client($settings['telegram']['token']);
$bot->command('start', function ($message) use ($bot) {
global $db;
...
startMess($bot, $message, $db);
});
$bot->on(function ($update) use ($bot) {
global $db;
$callback = $update->getCallbackQuery();
$message = $callback->getMessage();
$data = $callback->getData();
$bot->answerCallbackQuery($callback->getId());
$arData = explode('__', $data);
if ($arData[0] == 'street') {
houseMess($bot, $message, $db, $arData[1]);
}
...
}, function ($update) {
$callback = $update->getCallbackQuery();
if (is_null($callback) || !strlen($callback->getData()))
return false;
return true;
});
$bot->run();
} catch (\TelegramBot\Api\Exception $e) {
$e->getMessage();
}
Answer the question
In order to leave comments, you need to log in
Yes, I found the answer. I rummaged through the Client class, there is a getRawBody () method. So it contains everything that comes from the client - both messages and callback
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question