<?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();
}