php-telegram-bot / core

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

getCommandObject #784

Open kiwina opened 6 years ago

kiwina commented 6 years ago

Not sure if i'm missing something but if i give any command path of custom commands they dont get loaded because this function assumes that the namespace is below Longman\TelegramBot\Commands

sergey89d commented 6 years ago

first option

namespace should be Longman\TelegramBot\ UserCommands || Commands || AdminCommands, because namespace for commands static https://github.com/php-telegram-bot/core/blob/master/src/Telegram.php#L265

second option

If you want your custom namespace, you need to add to the constructor Telegram and then use your namespace

//Add default custom commands path
$this->addCommandsPath(BASE_COMMANDS_PATH . '/CustomCommands');

And in method getCommandObject added your commands name For example

$which[] = 'YourClass';
noplanman commented 6 years ago

This is being worked on in #689