Longman\TelegramBot\Telegram::setCommandConfig PHP Method

setCommandConfig() public method

Provide further variables to a particular commands. For example you can add the channel name at the command /sendtochannel Or you can add the api key for external service.
public setCommandConfig ( string $command, array $config ) : Telegram
$command string
$config array
return Telegram
    public function setCommandConfig($command, array $config)
    {
        $this->commands_config[$command] = $config;
        return $this;
    }

Usage Example

 public function setUp()
 {
     //Default command object
     $this->telegram = new Telegram('apikey', 'testbot');
     $this->command_stub = $this->getMockForAbstractClass($this->command_namespace, [$this->telegram]);
     //Create separate command object that contain a command config
     $this->telegram_with_config = new Telegram('apikey', 'testbot');
     $this->telegram_with_config->setCommandConfig('command_name', ['config_key' => 'config_value']);
     $this->command_stub_with_config = $this->getMockBuilder($this->command_namespace)->disableOriginalConstructor()->getMockForAbstractClass();
     //Set a name for the object property so that the constructor can set the config correctly
     TestHelpers::setObjectProperty($this->command_stub_with_config, 'name', 'command_name');
     $this->command_stub_with_config->__construct($this->telegram_with_config);
 }