Command
in package
Class Command
Base class for commands. It includes some helper methods that can fetch data directly from the Update object.
Table of Contents
- $config : array<string|int, mixed>
- Command config
- $description : string
- Description
- $enabled : bool
- If this command is enabled
- $name : string
- Name
- $need_mysql : bool
- If this command needs mysql
- $private_only : mixed
- $show_in_help : bool
- Show in Help
- $telegram : Telegram
- Telegram object
- $update : Update
- Update object
- $usage : string
- Usage
- $version : string
- Version
- __call() : Command
- Relay any non-existing function calls to Update object.
- __construct() : mixed
- Constructor
- execute() : ServerResponse
- Execute command
- executeNoDb() : ServerResponse
- Execution if MySQL is required but not available
- getCallbackQuery() :
- getChannelPost() :
- getChosenInlineResult() :
- getConfig() : array<string|int, mixed>|mixed|null
- Get command config
- getDescription() : string
- Get description
- getEditedChannelPost() :
- getEditedMessage() :
- getInlineQuery() :
- getMessage() :
- getName() : string
- Get name
- getTelegram() : Telegram
- Get telegram object
- getUpdate() : Update
- Get update object
- getUsage() : string
- Get usage
- getVersion() : string
- Get version
- isAdminCommand() : bool
- If this is an AdminCommand
- isEnabled() : bool
- Check if command is enabled
- isPrivateOnly() : bool
- If this command is intended for private chats only.
- isSystemCommand() : bool
- If this is a SystemCommand
- isUserCommand() : bool
- If this is a UserCommand
- preExecute() : ServerResponse
- Pre-execute command
- replyToChat() : ServerResponse
- Helper to reply to a chat directly.
- replyToUser() : ServerResponse
- Helper to reply to a user directly.
- setUpdate() : Command
- Set update object
- showInHelp() : bool
- Get Show in Help
- removeNonPrivateMessage() : bool
- Delete the current message if it has been called in a non-private chat.
Properties
$config
Command config
protected
array<string|int, mixed>
$config
= []
$description
Description
protected
string
$description
= 'Command description'
$enabled
If this command is enabled
protected
bool
$enabled
= true
$name
Name
protected
string
$name
= ''
$need_mysql
If this command needs mysql
protected
bool
$need_mysql
= false
$private_only
protected
mixed
$private_only
= false
$show_in_help
Show in Help
protected
bool
$show_in_help
= true
$telegram
Telegram object
protected
Telegram
$telegram
$update
Update object
protected
Update
$update
$usage
Usage
protected
string
$usage
= 'Command usage'
$version
Version
protected
string
$version
= '1.0.0'
Methods
__call()
Relay any non-existing function calls to Update object.
public
__call(string $name, array<string|int, mixed> $arguments) : Command
This is purely a helper method to make requests from within execute() method easier.
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Return values
Command —__construct()
Constructor
public
__construct(Telegram $telegram[, Update $update = null ]) : mixed
Parameters
Return values
mixed —execute()
Execute command
public
abstract execute() : ServerResponse
Tags
Return values
ServerResponse —executeNoDb()
Execution if MySQL is required but not available
public
executeNoDb() : ServerResponse
Tags
Return values
ServerResponse —getCallbackQuery()
public
getCallbackQuery() :
Optional. New incoming callback query
Return values
—getChannelPost()
public
getChannelPost() :
Optional. New post in the channel, can be any kind — text, photo, sticker, etc.
Return values
—getChosenInlineResult()
public
getChosenInlineResult() :
Optional. The result of an inline query that was chosen by a user and sent to their chat partner.
Return values
—getConfig()
Get command config
public
getConfig([string|null $name = null ]) : array<string|int, mixed>|mixed|null
Look for config $name if found return it, if not return null. If $name is not set return all set config.
Parameters
- $name : string|null = null
Return values
array<string|int, mixed>|mixed|null —getDescription()
Get description
public
getDescription() : string
Return values
string —getEditedChannelPost()
public
getEditedChannelPost() :
Optional. New version of a post in the channel that is known to the bot and was edited
Return values
—getEditedMessage()
public
getEditedMessage() :
Optional. New version of a message that is known to the bot and was edited
Return values
—getInlineQuery()
public
getInlineQuery() :
Optional. New incoming inline query
Return values
—getMessage()
public
getMessage() :
Optional. New incoming message of any kind — text, photo, sticker, etc.
Return values
—getName()
Get name
public
getName() : string
Return values
string —getTelegram()
Get telegram object
public
getTelegram() : Telegram
Return values
Telegram —getUpdate()
Get update object
public
getUpdate() : Update
Return values
Update —getUsage()
Get usage
public
getUsage() : string
Return values
string —getVersion()
Get version
public
getVersion() : string
Return values
string —isAdminCommand()
If this is an AdminCommand
public
isAdminCommand() : bool
Return values
bool —isEnabled()
Check if command is enabled
public
isEnabled() : bool
Return values
bool —isPrivateOnly()
If this command is intended for private chats only.
public
isPrivateOnly() : bool
Return values
bool —isSystemCommand()
If this is a SystemCommand
public
isSystemCommand() : bool
Return values
bool —isUserCommand()
If this is a UserCommand
public
isUserCommand() : bool
Return values
bool —preExecute()
Pre-execute command
public
preExecute() : ServerResponse
Tags
Return values
ServerResponse —replyToChat()
Helper to reply to a chat directly.
public
replyToChat(string $text[, array<string|int, mixed> $data = [] ]) : ServerResponse
Parameters
- $text : string
- $data : array<string|int, mixed> = []
Return values
ServerResponse —replyToUser()
Helper to reply to a user directly.
public
replyToUser(string $text[, array<string|int, mixed> $data = [] ]) : ServerResponse
Parameters
- $text : string
- $data : array<string|int, mixed> = []
Return values
ServerResponse —setUpdate()
Set update object
public
setUpdate([Update $update = null ]) : Command
Parameters
- $update : Update = null
Return values
Command —showInHelp()
Get Show in Help
public
showInHelp() : bool
Return values
bool —removeNonPrivateMessage()
Delete the current message if it has been called in a non-private chat.
protected
removeNonPrivateMessage() : bool