执行机器人命令

时间:2019-06-26 07:12:29

标签: php laravel telegram-bot

我想创建一个电报机器人。我正在使用"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命令

谢谢

0 个答案:

没有答案
相关问题