php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.87k stars 951 forks source link

Dealing with undefined commands #26

Closed manolab closed 9 years ago

manolab commented 9 years ago

Hi!

If the bot receives an undefined command something like that is thrown in the apache logs:

[Mon Aug 31 10:55:02.370494 2015] [:error] [pid 17414] [client 149.154.167.198:47253] PHP Fatal error:  Class 'Longman\\TelegramBot\\Commands\\GeloCommand' not found in /var/www/html/bot/vendor/longman/telegram-bot/src/Telegram.php

How can I deal with that? Which class do I need to tamper with to catch that error and, for example, reply some text to suggest the use of /help??

Thanks!

MBoretto commented 9 years ago

Thank for reporting! you can try to modify this line: https://github.com/akalongman/php-telegram-bot/blob/master/src/Telegram.php#L375 with: if ($class) { anyway i will fix it in the next relase

manolab commented 9 years ago

Thanks! I extended the Telegram class with my version of executeCommand function and all works as I wanted!