PHP 클래스 Longman\TelegramBot\Telegram

저자: Avtandil Kikabidze ([email protected])
파일 보기 프로젝트 열기: akalongman/php-telegram-bot 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$admins_list array Admins list
$api_key string Telegram API key
$bot_name string Telegram Bot name
$botan_enabled boolean Botan.io integration
$commands_config array Commands config
$commands_paths array Custom commands paths
$download_path string Download path
$input string Raw request data (json) for webhook methods
$last_command_response Longman\TelegramBot\Entities\ServerResponse ServerResponse of the last Command execution
$mysql_enabled boolean MySQL integration
$pdo PDO PDO object
$update Longman\TelegramBot\Entities\Update Current Update object
$upload_path string Upload path
$version string Version

공개 메소드들

메소드 설명
__construct ( string $api_key, string $bot_name ) Telegram constructor.
addCommandsPath ( string $path, boolean $before = true ) : Telegram Add a single custom commands path
addCommandsPaths ( array $paths, boolean $before = true ) : Telegram Add multiple custom commands paths
enableAdmin ( integer $admin_id ) : Telegram Enable a single Admin account
enableAdmins ( array $admin_ids ) : Telegram Enable a list of Admin Accounts
enableBotan ( $token ) : Telegram Enable Botan.io integration
enableExternalMySql ( PD\PDO $external_pdo_connection, string $table_prefix = null ) : Telegram Initialize Database external connection
enableMySql ( array $credential, string $table_prefix = null, string $encoding = 'utf8mb4' ) : Telegram Initialize Database connection
executeCommand ( string $command ) : mixed Execute /command
getAdminList ( ) : array Get list of admins
getApiKey ( ) : string Get API key
getBotName ( ) : string Get Bot name
getCommandConfig ( string $command ) : array Get command config
getCommandObject ( string $command ) : Command | null Get an object instance of the passed command
getCommandsList ( ) : array Get commands list
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
getUploadPath ( ) : string Get custom upload path
getVersion ( ) : string Get Version
handle ( ) : boolean Handle bot request from webhook
handleGetUpdates ( integer | null $limit = null, integer | null $timeout = null ) : ServerResponse Handle getUpdates method
isAdmin ( integer | null $user_id = null ) : boolean Check if the passed user is an admin
isDbEnabled ( ) : boolean Check if user required the db connection
processUpdate ( Update $update ) : ServerResponse Process bot Update request
setCommandConfig ( string $command, array $config ) : Telegram Set command config
setCustomInput ( string $input ) : Telegram Set custom input string for debug purposes
setDownloadPath ( string $path ) : Telegram Set custom download path
setUploadPath ( string $path ) : Telegram Set custom upload path
setWebHook ( string $url, string | null $path_certificate = null ) : ServerResponse Set Webhook for bot
unsetWebHook ( ) : mixed Unset Webhook for bot

보호된 메소드들

메소드 설명
sanitizeCommand ( string $command ) : string Sanitize Command
ucfirstUnicode ( string $str, string $encoding = 'UTF-8' ) : string Replace function ucfirst for UTF-8 characters in the class definition and commands
ucwordsUnicode ( string $str, string $encoding = 'UTF-8' ) : string Replace function ucwords for UTF-8 characters in the class definition and commands

비공개 메소드들

메소드 설명
getCommandFromType ( string $type ) : string Get the command name from the command type

메소드 상세

__construct() 공개 메소드

Telegram constructor.
public __construct ( string $api_key, string $bot_name )
$api_key string
$bot_name string

addCommandsPath() 공개 메소드

Add a single custom commands path
public addCommandsPath ( string $path, boolean $before = true ) : Telegram
$path string Custom commands path to add
$before boolean If the path should be prepended or appended to the list
리턴 Telegram

addCommandsPaths() 공개 메소드

Add multiple custom commands paths
public addCommandsPaths ( array $paths, boolean $before = true ) : Telegram
$paths array Custom commands paths to add
$before boolean If the paths should be prepended or appended to the list
리턴 Telegram

enableAdmin() 공개 메소드

Enable a single Admin account
public enableAdmin ( integer $admin_id ) : Telegram
$admin_id integer Single admin id
리턴 Telegram

enableAdmins() 공개 메소드

Enable a list of Admin Accounts
public enableAdmins ( array $admin_ids ) : Telegram
$admin_ids array List of admin ids
리턴 Telegram

enableBotan() 공개 메소드

Enable Botan.io integration
public enableBotan ( $token ) : Telegram
$token
리턴 Telegram

enableExternalMySql() 공개 메소드

Initialize Database external connection
public enableExternalMySql ( PD\PDO $external_pdo_connection, string $table_prefix = null ) : Telegram
$external_pdo_connection PD\PDO PDO database object
$table_prefix string
리턴 Telegram

enableMySql() 공개 메소드

Initialize Database connection
public enableMySql ( array $credential, string $table_prefix = null, string $encoding = 'utf8mb4' ) : Telegram
$credential array
$table_prefix string
$encoding string
리턴 Telegram

executeCommand() 공개 메소드

Execute /command
public executeCommand ( string $command ) : mixed
$command string
리턴 mixed

getAdminList() 공개 메소드

Get list of admins
public getAdminList ( ) : array
리턴 array

getApiKey() 공개 메소드

Get API key
public getApiKey ( ) : string
리턴 string

getBotName() 공개 메소드

Get Bot name
public getBotName ( ) : string
리턴 string

getCommandConfig() 공개 메소드

Get command config
public getCommandConfig ( string $command ) : array
$command string
리턴 array

getCommandObject() 공개 메소드

Get an object instance of the passed command
public getCommandObject ( string $command ) : Command | null
$command string
리턴 Longman\TelegramBot\Commands\Command | null

getCommandsList() 공개 메소드

Get commands list
public getCommandsList ( ) : array
리턴 array $commands

getCustomInput() 공개 메소드

Get custom input string for debug purposes
public getCustomInput ( ) : string
리턴 string

getDownloadPath() 공개 메소드

Get custom download path
public getDownloadPath ( ) : string
리턴 string

getLastCommandResponse() 공개 메소드

Get the ServerResponse of the last Command execution
public getLastCommandResponse ( ) : ServerResponse
리턴 Longman\TelegramBot\Entities\ServerResponse

getUploadPath() 공개 메소드

Get custom upload path
public getUploadPath ( ) : string
리턴 string

getVersion() 공개 메소드

Get Version
public getVersion ( ) : string
리턴 string

handle() 공개 메소드

Handle bot request from webhook
public handle ( ) : boolean
리턴 boolean

handleGetUpdates() 공개 메소드

Handle getUpdates method
public handleGetUpdates ( integer | null $limit = null, integer | null $timeout = null ) : ServerResponse
$limit integer | null
$timeout integer | null
리턴 Longman\TelegramBot\Entities\ServerResponse

isAdmin() 공개 메소드

If no user id is passed, the current update is checked for a valid message sender.
public isAdmin ( integer | null $user_id = null ) : boolean
$user_id integer | null
리턴 boolean

isDbEnabled() 공개 메소드

Check if user required the db connection
public isDbEnabled ( ) : boolean
리턴 boolean

processUpdate() 공개 메소드

Process bot Update request
public processUpdate ( Update $update ) : ServerResponse
$update Longman\TelegramBot\Entities\Update
리턴 Longman\TelegramBot\Entities\ServerResponse

sanitizeCommand() 보호된 메소드

Sanitize Command
protected sanitizeCommand ( string $command ) : string
$command string
리턴 string

setCommandConfig() 공개 메소드

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
리턴 Telegram

setCustomInput() 공개 메소드

Set custom input string for debug purposes
public setCustomInput ( string $input ) : Telegram
$input string (json format)
리턴 Telegram

setDownloadPath() 공개 메소드

Set custom download path
public setDownloadPath ( string $path ) : Telegram
$path string Custom download path
리턴 Telegram

setUploadPath() 공개 메소드

Set custom upload path
public setUploadPath ( string $path ) : Telegram
$path string Custom upload path
리턴 Telegram

setWebHook() 공개 메소드

Set Webhook for bot
public setWebHook ( string $url, string | null $path_certificate = null ) : ServerResponse
$url string
$path_certificate string | null
리턴 Longman\TelegramBot\Entities\ServerResponse

ucfirstUnicode() 보호된 메소드

Replace function ucfirst for UTF-8 characters in the class definition and commands
protected ucfirstUnicode ( string $str, string $encoding = 'UTF-8' ) : string
$str string
$encoding string (default = 'UTF-8')
리턴 string

ucwordsUnicode() 보호된 메소드

Replace function ucwords for UTF-8 characters in the class definition and commands
protected ucwordsUnicode ( string $str, string $encoding = 'UTF-8' ) : string
$str string
$encoding string (default = 'UTF-8')
리턴 string

unsetWebHook() 공개 메소드

Unset Webhook for bot
public unsetWebHook ( ) : mixed
리턴 mixed

프로퍼티 상세

$admins_list 보호되어 있는 프로퍼티

Admins list
protected array $admins_list
리턴 array

$api_key 보호되어 있는 프로퍼티

Telegram API key
protected string $api_key
리턴 string

$bot_name 보호되어 있는 프로퍼티

Telegram Bot name
protected string $bot_name
리턴 string

$botan_enabled 보호되어 있는 프로퍼티

Botan.io integration
protected bool $botan_enabled
리턴 boolean

$commands_config 보호되어 있는 프로퍼티

Commands config
protected array $commands_config
리턴 array

$commands_paths 보호되어 있는 프로퍼티

Custom commands paths
protected array $commands_paths
리턴 array

$download_path 보호되어 있는 프로퍼티

Download path
protected string $download_path
리턴 string

$input 보호되어 있는 프로퍼티

Raw request data (json) for webhook methods
protected string $input
리턴 string

$last_command_response 보호되어 있는 프로퍼티

ServerResponse of the last Command execution
protected ServerResponse,Longman\TelegramBot\Entities $last_command_response
리턴 Longman\TelegramBot\Entities\ServerResponse

$mysql_enabled 보호되어 있는 프로퍼티

MySQL integration
protected bool $mysql_enabled
리턴 boolean

$pdo 보호되어 있는 프로퍼티

PDO object
protected PDO $pdo
리턴 PDO

$update 보호되어 있는 프로퍼티

Current Update object
protected Update,Longman\TelegramBot\Entities $update
리턴 Longman\TelegramBot\Entities\Update

$upload_path 보호되어 있는 프로퍼티

Upload path
protected string $upload_path
리턴 string

$version 보호되어 있는 프로퍼티

Version
protected string $version
리턴 string