Core: Webhook does not return messages

Created on 24 Jul 2017  路  4Comments  路  Source: php-telegram-bot/core

Required Information

  • Operating system: Ubuntu 16.04 / nginx
  • PHP version: 7.1
  • PHP Telegram Bot version: ^0.46.0
  • Using MySQL database: yes
  • MySQL version: 5.7
  • Update Method: Webhook
  • Self-signed certificate: no
  • RAW update (if available):
  • Uses laravel 5.4

Expected behaviour

command: /help should return data to the message

Actual behaviour

The messages is stored in the database but does not send a message to the chat.
Table: telegram_message (i have telegram_ as prefix)
text column: /help
entities column: [{"type":"bot_command","offset":0,"length":5}]

Steps to reproduce

$token = env('TELEGRAM_API_KEY');
$botName = env('TELEGRAM_BOT_NAME');

$mysql_credentials = [
    'host'     => env('DB_HOST'),
    'user'     => env('DB_USERNAME'),
    'password' => env('DB_PASSWORD'),
    'database' => env('DB_DATABASE'),
];

try {
    $telegram new Telegram($token, $botName);
    $telegram->enableMySQL($mysql_credentials, 'telegram_');
    $telegram->enableAdmin('12345678');


    // $telegram->addCommandsPath(app_path('Telegram\Commands'));
    //$telegram->setCommandConfig();

    // get the updates
    $telegram->handle();

} catch (TelegramException $exception) {
    Log::error('Could not handle telegram updates | ' . $exception->getMessage() . "\r\n"  . $exception->getTraceAsString());
}

Log::info('Message: ' . Request::getInput());

Extra details

I use laravel. I do not get any logs for nginx or laravel it self.
I do get the access log and there it gives a status code 200.

I can send messages with Request:sendMessage()

What can be the problem?

Most helpful comment

As @jacklul noted, there are no built-in public commands that create output. For some example commands, like /help, have a look at the separate example-bot repository.

Also, as a side-note, the user ID you pass to enableAdmin must be an integer, not string.

All 4 comments

By default bot comes with public commands that do not reply.

Try executing /debug command, it should work out of the box. Make sure your custom commands path is included in the output, if it doesn't then there is path error in $telegram->addCommandsPath(app_path('Telegram\Commands'));!

As @jacklul noted, there are no built-in public commands that create output. For some example commands, like /help, have a look at the separate example-bot repository.

Also, as a side-note, the user ID you pass to enableAdmin must be an integer, not string.

@jacklul @noplanman

Thank you! i've solved it.
When i changed: enableAdmin to an integer the default commands worked. However i did not get any error message or whatsoever.

By the debug command i did not find my own command path. Eventually i found out my directory separator was facing the wrong way \ instead of / And i didn't have a trailing separator. I also did not receive an error message any where.

And now it works like a charm 馃憤

Did you have the logging enabled? If so, you should have seen error entries there 馃槙

Anyway, good to see you've got it running!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bl0ck154 picture Bl0ck154  路  3Comments

dorcu picture dorcu  路  3Comments

vansanblch picture vansanblch  路  3Comments

noplanman picture noplanman  路  3Comments

esomkin picture esomkin  路  3Comments