PHP Class Telegram\Bot\Commands\CommandBus

Mostra file Open project: irazasyed/telegram-bot-sdk

Protected Properties

Property Type Description
$commandAliases Holds all commands' aliases.
$commands Holds all commands.

Public Methods

Method Description
__construct ( Api $telegram ) Instantiate Command Bus.
addCommand ( Telegram\Bot\Commands\CommandInterface | string $command ) : CommandBus Add a command to the commands list.
addCommands ( array $commands ) : CommandBus Add a list of commands.
getCommands ( ) : array Returns the list of commands.
parseCommand ( $text ) : array Parse a Command for a Match.
removeCommand ( $name ) : CommandBus Remove a command from the list.
removeCommands ( array $names ) : CommandBus Removes a list of commands.

Protected Methods

Method Description
execute ( $name, $arguments, $message ) : mixed Execute the command.
handler ( $message, Update $update ) : Update Handles Inbound Messages and Executes Appropriate Command.

Method Details

__construct() public method

Instantiate Command Bus.
public __construct ( Api $telegram )
$telegram Telegram\Bot\Api

addCommand() public method

Add a command to the commands list.
public addCommand ( Telegram\Bot\Commands\CommandInterface | string $command ) : CommandBus
$command Telegram\Bot\Commands\CommandInterface | string Either an object or full path to the command class.
return CommandBus

addCommands() public method

Add a list of commands.
public addCommands ( array $commands ) : CommandBus
$commands array
return CommandBus

execute() protected method

Execute the command.
protected execute ( $name, $arguments, $message ) : mixed
$name
$arguments
$message
return mixed

getCommands() public method

Returns the list of commands.
public getCommands ( ) : array
return array

handler() protected method

Handles Inbound Messages and Executes Appropriate Command.
protected handler ( $message, Update $update ) : Update
$message
$update Telegram\Bot\Objects\Update
return Telegram\Bot\Objects\Update

parseCommand() public method

Parse a Command for a Match.
public parseCommand ( $text ) : array
$text
return array

removeCommand() public method

Remove a command from the list.
public removeCommand ( $name ) : CommandBus
$name
return CommandBus

removeCommands() public method

Removes a list of commands.
public removeCommands ( array $names ) : CommandBus
$names array
return CommandBus

Property Details

$commandAliases protected_oe property

Holds all commands' aliases.
protected $commandAliases

$commands protected_oe property

Holds all commands.
protected $commands