irazasyed / telegram-bot-sdk

🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
https://telegram-bot-sdk.com
BSD 3-Clause "New" or "Revised" License
3.05k stars 673 forks source link

The bot does not reply to command #331

Closed rtfmfm closed 7 years ago

rtfmfm commented 7 years ago

Hi! I'm trying to make the bot to reply to commands. I think everything I did is right, but the bot do not respond.

Laravel 5.3 My codes:

web.php

Route::get('/set', function () {
    $res = Telegram::setWebhook(['url' => 'https://mydomain.com/'. env('TELEGRAM_BOT_TOKEN') .'/webhook']);
});

Route::post(env('TELEGRAM_BOT_TOKEN') .'/webhook', function () {
    $update = Telegram::commandsHandler(true);
    return 'ok';
});

VerifyCsrfToken.php

protected $except = [
      '*:*/webhook',
 ];

telegram.php

'commands' => [
      Telegram\Bot\Commands\HelpCommand::class,
      App\Bot\StartCommand::class,
],

In folder app/Bot I have file StartCommand.php

<?php
namespace App\Bot;
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;

class StartCommand extends Command
{
    protected $name = "start";
    protected $description = "Start Command to get you started";
    public function handle($arguments)
    {
        $this->replyWithMessage(['text' => 'Hello!']);
    }
}

The bot did not reply on /start and /help commands. When I try to send it POST message with Postman http://mydomain.com/<bot-token>/webhook

I'm getting "ok" as reply.

Can you tell me where I'm wrong?

Thank you in advance!

rtfmfm commented 7 years ago

Found out that I need https ;-)