-
-
Couldn't load subscription status.
- Fork 963
Description
I try to set up hook.php but with little success so far.
- The minimum example:
try {
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
$telegram->enableMySQL($credentials);
// later commands are handled here
$telegram->handle();
}
works so far.
- However, if I add commands (is it correct to do this before the method
$telegram->handle()?), MySQL logging stops working and the web server error_log logs 500 Internal Server Error (see MySQL logging works only with no other commands active, but then HTTP/500 #39). - Exceptions are logged but not when (1) happened. I can have an exception logged by calling
php hook.phpfrom command line, then the exception saysexception 'Longman\TelegramBot\Exception\TelegramException' with message 'Input is empty!'so exception logging should work. - My basic question is: What is the exact way to add any functionality to above minimum example such as
echoorwhoami?
Is this correct?
$echo = new Longman\TelegramBot\Commands\EchoCommand;
$echo->execute();
Or this way?
$telegram->executeCommand('echo', $update);
Or both? I cannot figure this out without diving into the classes but it should be clear in the documentation already.
The point is, I believe that Telegram API stops sending me requests if I produce to many server errors. Because after trying this out, even the basic example above stops working (MySQL no longer logs anything) and I have to wait a day or so and suddenly it works again.
Please provide a minimum working example in README.md with which users can instantly get at least the /echo Telegram bot command working.
I don't know if this would be a minimum working example, but please add something like the following to README.md to make it clear and instantly get a working bot:
try {
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
$telegram->enableMySQL($credentials);
$echo = new Longman\TelegramBot\Commands\EchoCommand; // or whatever is correct to activate "/echo"
$echo->execute();
$telegram->handle();
}
If this would be easy to get started with, I think it will be a great success! Thank you.