Documentation

Telegram
in package

Table of Contents

$admins_list  : array<string|int, mixed>
Admins list
$api_key  : string
Telegram API key
$bot_id  : string
Telegram Bot id
$bot_username  : string
Telegram Bot username
$botan_enabled  : bool
Botan.io integration
$commands_config  : array<string|int, mixed>
Commands config
$commands_paths  : array<string|int, mixed>
Custom commands paths
$download_path  : string
Download path
$getupdates_without_database  : bool
Is running getUpdates without DB enabled
$input  : string
Raw request data (json) for webhook methods
$last_command_response  : ServerResponse
ServerResponse of the last Command execution
$last_update_id  : int
Last update ID Only used when running getUpdates without a database
$mysql_enabled  : bool
MySQL integration
$pdo  : PDO
PDO object
$run_commands  : bool
Check if runCommands() is running in this session
$update  : Update
Current Update object
$upload_path  : string
Upload path
$version  : string
Version
__construct()  : mixed
Telegram constructor.
addCommandsPath()  : Telegram
Add a single custom commands path
addCommandsPaths()  : Telegram
Add multiple custom commands paths
deleteWebhook()  : mixed
Delete any assigned webhook
enableAdmin()  : Telegram
Enable a single Admin account
enableAdmins()  : Telegram
Enable a list of Admin Accounts
enableBotan()  : Telegram
Enable Botan.io integration
enableExternalMySql()  : Telegram
Initialize Database external connection
enableLimiter()  : Telegram
Enable requests limiter
enableMySql()  : Telegram
Initialize Database connection
executeCommand()  : mixed
Execute /command
getAdminList()  : array<string|int, mixed>
Get list of admins
getApiKey()  : string
Get API key
getBotId()  : string
Get Bot Id
getBotUsername()  : string
Get Bot name
getCommandConfig()  : array<string|int, mixed>
Get command config
getCommandObject()  : Command|null
Get an object instance of the passed command
getCommandsList()  : array<string|int, mixed>
Get commands list
getCommandsPaths()  : array<string|int, mixed>
Return the list of commands paths
getCustomInput()  : string
Get custom input string for debug purposes
getDownloadPath()  : string
Get custom download path
getLastCommandResponse()  : ServerResponse
Get the ServerResponse of the last Command execution
getLastUpdateId()  : int
Return last update id
getUploadPath()  : string
Get custom upload path
getVersion()  : string
Get Version
handle()  : bool
Handle bot request from webhook
handleGetUpdates()  : ServerResponse
Handle getUpdates method
isAdmin()  : bool
Check if the passed user is an admin
isDbEnabled()  : bool
Check if user required the db connection
isRunCommands()  : bool
Is this session initiated by runCommands()
processUpdate()  : ServerResponse
Process bot Update request
runCommands()  : mixed
Run provided commands
setCommandConfig()  : Telegram
Set command config
setCustomInput()  : Telegram
Set custom input string for debug purposes
setDownloadPath()  : Telegram
Set custom download path
setUploadPath()  : Telegram
Set custom upload path
setWebhook()  : ServerResponse
Set Webhook for bot
useGetUpdatesWithoutDatabase()  : mixed
Switch to enable running getUpdates without a database
getCommandFromType()  : string
Get the command name from the command type
sanitizeCommand()  : string
Sanitize Command
ucfirstUnicode()  : string
Replace function `ucfirst` for UTF-8 characters in the class definition and commands
ucwordsUnicode()  : string
Replace function `ucwords` for UTF-8 characters in the class definition and commands

Properties

$admins_list

Admins list

protected array<string|int, mixed> $admins_list = []

$api_key

Telegram API key

protected string $api_key = ''

$bot_id

Telegram Bot id

protected string $bot_id = ''

$bot_username

Telegram Bot username

protected string $bot_username = ''

$botan_enabled

Botan.io integration

protected bool $botan_enabled = false

$commands_config

Commands config

protected array<string|int, mixed> $commands_config = []

$commands_paths

Custom commands paths

protected array<string|int, mixed> $commands_paths = []

$download_path

Download path

protected string $download_path

$getupdates_without_database

Is running getUpdates without DB enabled

protected bool $getupdates_without_database = false

$input

Raw request data (json) for webhook methods

protected string $input

$last_command_response

ServerResponse of the last Command execution

protected ServerResponse $last_command_response

$last_update_id

Last update ID Only used when running getUpdates without a database

protected int $last_update_id = null

$mysql_enabled

MySQL integration

protected bool $mysql_enabled = false

$run_commands

Check if runCommands() is running in this session

protected bool $run_commands = false

$upload_path

Upload path

protected string $upload_path

$version

Version

protected string $version = '0.55.1'

Methods

__construct()

Telegram constructor.

public __construct(string $api_key[, string $bot_username = '' ]) : mixed
Parameters
$api_key : string
$bot_username : string = ''
Tags
throws
TelegramException
Return values
mixed

addCommandsPath()

Add a single custom commands path

public addCommandsPath(string $path[, bool $before = true ]) : Telegram
Parameters
$path : string

Custom commands path to add

$before : bool = true

If the path should be prepended or appended to the list

Return values
Telegram

addCommandsPaths()

Add multiple custom commands paths

public addCommandsPaths(array<string|int, mixed> $paths[, bool $before = true ]) : Telegram
Parameters
$paths : array<string|int, mixed>

Custom commands paths to add

$before : bool = true

If the paths should be prepended or appended to the list

Return values
Telegram

deleteWebhook()

Delete any assigned webhook

public deleteWebhook() : mixed
Tags
throws
TelegramException
Return values
mixed

enableAdmin()

Enable a single Admin account

public enableAdmin(int $admin_id) : Telegram
Parameters
$admin_id : int

Single admin id

Return values
Telegram

enableAdmins()

Enable a list of Admin Accounts

public enableAdmins(array<string|int, mixed> $admin_ids) : Telegram
Parameters
$admin_ids : array<string|int, mixed>

List of admin ids

Return values
Telegram

enableBotan()

Enable Botan.io integration

public enableBotan(string $token[, array<string|int, mixed> $options = [] ]) : Telegram
Parameters
$token : string
$options : array<string|int, mixed> = []
Tags
throws
TelegramException
Return values
Telegram

enableExternalMySql()

Initialize Database external connection

public enableExternalMySql(PDO $external_pdo_connection[, string $table_prefix = null ]) : Telegram
Parameters
$external_pdo_connection : PDO

PDO database object

$table_prefix : string = null
Tags
throws
TelegramException
Return values
Telegram

enableLimiter()

Enable requests limiter

public enableLimiter([array<string|int, mixed> $options = [] ]) : Telegram
Parameters
$options : array<string|int, mixed> = []
Return values
Telegram

enableMySql()

Initialize Database connection

public enableMySql(array<string|int, mixed> $credential[, string $table_prefix = null ][, string $encoding = 'utf8mb4' ]) : Telegram
Parameters
$credential : array<string|int, mixed>
$table_prefix : string = null
$encoding : string = 'utf8mb4'
Tags
throws
TelegramException
Return values
Telegram

executeCommand()

Execute /command

public executeCommand(string $command) : mixed
Parameters
$command : string
Tags
throws
TelegramException
Return values
mixed

getAdminList()

Get list of admins

public getAdminList() : array<string|int, mixed>
Return values
array<string|int, mixed>

getApiKey()

Get API key

public getApiKey() : string
Return values
string

getBotId()

Get Bot Id

public getBotId() : string
Return values
string

getBotUsername()

Get Bot name

public getBotUsername() : string
Return values
string

getCommandConfig()

Get command config

public getCommandConfig(string $command) : array<string|int, mixed>
Parameters
$command : string
Return values
array<string|int, mixed>

getCommandObject()

Get an object instance of the passed command

public getCommandObject(string $command) : Command|null
Parameters
$command : string
Return values
Command|null

getCommandsList()

Get commands list

public getCommandsList() : array<string|int, mixed>
Tags
throws
TelegramException
Return values
array<string|int, mixed>

$commands

getCommandsPaths()

Return the list of commands paths

public getCommandsPaths() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCustomInput()

Get custom input string for debug purposes

public getCustomInput() : string
Return values
string

getDownloadPath()

Get custom download path

public getDownloadPath() : string
Return values
string

getLastUpdateId()

Return last update id

public getLastUpdateId() : int
Return values
int

getUploadPath()

Get custom upload path

public getUploadPath() : string
Return values
string

getVersion()

Get Version

public getVersion() : string
Return values
string

handleGetUpdates()

Handle getUpdates method

public handleGetUpdates([int|null $limit = null ][, int|null $timeout = null ]) : ServerResponse
Parameters
$limit : int|null = null
$timeout : int|null = null
Tags
throws
TelegramException
Return values
ServerResponse

isAdmin()

Check if the passed user is an admin

public isAdmin([int|null $user_id = null ]) : bool

If no user id is passed, the current update is checked for a valid message sender.

Parameters
$user_id : int|null = null
Return values
bool

isDbEnabled()

Check if user required the db connection

public isDbEnabled() : bool
Return values
bool

isRunCommands()

Is this session initiated by runCommands()

public isRunCommands() : bool
Return values
bool

runCommands()

Run provided commands

public runCommands(array<string|int, mixed> $commands) : mixed
Parameters
$commands : array<string|int, mixed>
Tags
throws
TelegramException
Return values
mixed

setCommandConfig()

Set command config

public setCommandConfig(string $command, array<string|int, mixed> $config) : Telegram

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.

Parameters
$command : string
$config : array<string|int, mixed>
Return values
Telegram

setCustomInput()

Set custom input string for debug purposes

public setCustomInput(string $input) : Telegram
Parameters
$input : string

(json format)

Return values
Telegram

setDownloadPath()

Set custom download path

public setDownloadPath(string $path) : Telegram
Parameters
$path : string

Custom download path

Return values
Telegram

setUploadPath()

Set custom upload path

public setUploadPath(string $path) : Telegram
Parameters
$path : string

Custom upload path

Return values
Telegram

setWebhook()

Set Webhook for bot

public setWebhook(string $url[, array<string|int, mixed> $data = [] ]) : ServerResponse
Parameters
$url : string
$data : array<string|int, mixed> = []

Optional parameters.

Tags
throws
TelegramException
Return values
ServerResponse

useGetUpdatesWithoutDatabase()

Switch to enable running getUpdates without a database

public useGetUpdatesWithoutDatabase([bool $enable = true ]) : mixed
Parameters
$enable : bool = true
Return values
mixed

getCommandFromType()

Get the command name from the command type

protected getCommandFromType(string $type) : string
Parameters
$type : string
Return values
string

sanitizeCommand()

Sanitize Command

protected sanitizeCommand(string $command) : string
Parameters
$command : string
Return values
string

ucfirstUnicode()

Replace function `ucfirst` for UTF-8 characters in the class definition and commands

protected ucfirstUnicode(string $str[, string $encoding = 'UTF-8' ]) : string
Parameters
$str : string
$encoding : string = 'UTF-8'

(default = 'UTF-8')

Return values
string

ucwordsUnicode()

Replace function `ucwords` for UTF-8 characters in the class definition and commands

protected ucwordsUnicode(string $str[, string $encoding = 'UTF-8' ]) : string
Parameters
$str : string
$encoding : string = 'UTF-8'

(default = 'UTF-8')

Return values
string

Search results