php-telegram-bot / core

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

Custom namespace for commands #164

Closed Doncode closed 8 years ago

Doncode commented 8 years ago

Can i create command with custom namespace

MBoretto commented 8 years ago

The command have to follow the namespace of the library but if you need you can create you own father command with your namespace and inherit from it. Why you need a custom namespace?

UnsupportedCallbackException commented 8 years ago

HelpCommand is part of the package (and part of namespace Longman\TelegramBot\Commands\UserCommands)

MyCustomCommand even if it inherited from abstract Longman\TelegramBot\Commands\UserCommands\UserCommand is not part of your package and requires its own (my own) namespace. The logical separation is reasonable because it avoid misunderstanding: If I have problems and bugs in MyCustomCommand I will go to my MyCustomCommands folder instead of trying to find that class in vendor directory.

Note that namespace Longman\TelegramBot\Commands\UserCommands is similar to folder structure. So I guess using of this namespace even for examples would be wrong.