php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.9k stars 953 forks source link

Can't add custom command path #225

Closed iamraccoon closed 8 years ago

iamraccoon commented 8 years ago

Sorry for my English...

I can call addCommandsPath() in the Controller, but there is bug in Longman\TelegramBot\Telegram.php method getCommandObject() at line 243:

$command_namespace = __NAMESPACE__ . '\\Commands\\' . $auth . 'Commands\\' . $this->ucfirstUnicode($command) . 'Command';

NAMESPACE return only "Longman\TelegramBot". NAMESPACE never return my commands path.

So new Commands can be executions only they are located in a system folder like Longman\TelegramBot\Commands\SystemCommands.

noplanman commented 8 years ago

All commands need to belong to the correct namespace. Your custom commands classes need to extend the type of command they are.

Look at the examples/commands folder for examples. e.g. MarkdownCommand.php

iamraccoon commented 8 years ago

Thanks a lot, it's work!

But it is not logical. MarkdownCommand.php should have namespace examples\commands, not Longman\TelegramBot\Commands\UserCommands.

I thought we adhere to the standard PSR-0

noplanman commented 8 years ago

The example commands are intended for copy-pasting, so that the namespaces are already set correctly 👍