/var/www/myprog.com.ua/telegram/webhooks
NameSizeModeActions
vendor/-0755rm
bot.txt556540666editdlrm
composer.json620644editdlrm
composer.lock23940644editdlrm
composer.phar18756110755editdlrm
dialog.php2770644editdlrm
webhook.php41770644editdlrm
webhook2.php27380644editdlrm
Edit: /var/www/myprog.com.ua/telegram/webhooks/webhook.php (4177B)
command('ping', function ($message) use ($bot) { $bot->sendMessage($message->getChat()->getId(), 'pong!'); }); $bot->command('start', function ($message) use ($bot) { $answer = 'Добро пожаловать! Я бот MyProg который облегчит Вам жизнь :)'."\n"; $answer .= 'Для начала выберите Вашу систему'."\n"; $bot->sendMessage($message->getChat()->getId(), $answer); }); // команда для помощи $bot->command('help', function ($message) use ($bot) { $answer = 'Команды: /help - вывод справки /menu - главное меню'; $bot->sendMessage($message->getChat()->getId(), $answer); }); $bot->command('menu', function ($message) use ($bot) { $keyboard = new \TelegramBot\Api\Types\ReplyKeyboardMarkup(array(array("/menu2", "Курсы валют", "Погода")), true); // true for one-time keyboard $messageText = 'Главное меню'; $bot->sendMessage($message->getChat()->getId(), $messageText, null, false, null, $keyboard); }); $bot->command('menu2', function ($message) use ($bot) { $keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup( [ [ ['text' => 'DEMO', 'url' => 'https://demo.myprog.com.ua'], ['text' => 'Кнопка', 'callback_data' => 'test01'] ] ] ); $messageText = 'Не главное меню'; $bot->sendMessage($message->getChat()->getId(), $messageText, null, false, null, $keyboard); }); //Callbacks $bot->callbackQuery(function($message) use ($bot){ //$callback = $cback->getCallbackQuery(); $mess = $message->getMessage(); $chatId = $mess->getChat()->getId(); $data = $message->getData(); file_put_contents("bot.txt","RX CALLBACK: ".$data." chatId=".$chatId."\n\n",FILE_APPEND); if($data == 'test01') { $bot->sendMessage($chatId, 'test1'); $bot->answerCallbackQuery($message->getId()); } if($data == '/test2') { $bot->sendMessage($chatId, 'test2'); $bot->answerCallbackQuery($message->getId()); } }, function($message) use ($bot) { $message = $message->getMessage(); if (is_null($message)) return false; return true; }); $bot->on(function($update) use ($bot){ $message = $update->getMessage(); $mtext = $message->getText(); $cid = $message->getChat()->getId(); $user = $message->getChat()->getUsername(); //$answer = "RX: ".$message; if($mtext == "me"){ $answer = "Hi"; $keyboard = new \TelegramBot\Api\Types\ReplyKeyboardMarkup([[["text" => "\xF0\x9F\x93\xB2 Добавить телефон"]]], false, true, false); } if(class_exists($message->getContact()) !== false){ $tlf = $message->getContact()->getPhoneNumber(); $answer = "Ваш телефон добавлен к списку контактов!"; } $bot->sendMessage($message->getChat()->getId(), $answer, 'HTML', false, null, $keyboard); }, function($update){ $message = $update->getMessage(); if (is_null($message)) return false; return true; }); if(!empty($bot->getRawBody())){ file_put_contents("bot.txt","RX RAW: ".$bot->getRawBody()."\n\n",FILE_APPEND); // $bot->sendMessage($message->getChat()->getId(), "\n\nLOG: "); $bot->run(); } } catch (\TelegramBot\Api\Exception $e) { $e->getMessage(); file_put_contents("bot.txt","ERROR: ".$e->getMessage()."\n",FILE_APPEND); } ?>