command: /help should return data to the message
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}]
$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());
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?
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!
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
enableAdminmust be an integer, not string.