我想创建一个电报机器人。我正在使用"telegram-bot/api": "^2.3"
,laravel 5.7
try {
$bot = new \TelegramBot\Api\Client('XXXXXXXX:XXXXXXXXXXXX');
$bot->command('start', function ($message) use ($bot) {
$answer = 'Добро пожаловать!';
$bot->sendMessage($message->getChat()->getId(), $answer);
});
$bot->command('stop', function ($message) use ($bot) {
$keyboard = new \TelegramBot\Api\Types\ReplyKeyboardMarkup(
array
(
array("to start command")
), true);
$bot->sendMessage($message->getChat()->getId(), 'test', null, false, null, $keyboard);
});
$bot->run();
} catch (\TelegramBot\Api\Exception $e) {
$e->getMessage();
}
当我按下“开始命令”按钮时,我需要执行/ start命令
谢谢