PHP Класс Telegram\Bot\Api

Наследование: use trait Telegram\Bot\Events\EmitsEvents
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$accessToken Telegram Bot API Access Token.
$client The Telegram client service.
$commandBus Telegram Command Bus.
$connectTimeOut integer Connection timeout of the request in seconds.
$container IoC Container
$isAsyncRequest Indicates if the request to Telegram will be asynchronous (non-blocking).
$lastResponse Stores the last request made to Telegram Bot API.
$timeOut integer Timeout of the request in seconds.

Открытые методы

Метод Описание
__call ( $method, $arguments ) : boolean | TelegramResponse | Telegram\Bot\Objects\UnknownObject Magic method to process any "get" requests.
__construct ( string $token = null, boolean $async = false, Telegram\Bot\HttpClients\HttpClientInterface $httpClientHandler = null ) Instantiates a new Telegram super-class object.
answerCallbackQuery ( array $params ) : boolean Send answers to callback queries sent from inline keyboards.
answerInlineQuery ( array $params = [] ) : boolean Use this method to send answers to an inline query.
commandsHandler ( boolean $webhook = false ) : Update | Update[] Processes Inbound Commands.
detectMessageType ( Update | Message $object ) : string | null Detect Message Type Based on Update or Message Object.
editMessageCaption ( array $params ) : Message | boolean Edit captions of messages sent by the bot or via the bot (for inline bots).
editMessageReplyMarkup ( array $params ) : Message | boolean Edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
editMessageText ( array $params ) : Message | boolean Edit text messages sent by the bot or via the bot (for inline bots).
forceReply ( array $params = [] ) : Keyboard Display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply').
forwardMessage ( array $params ) : Message Forward messages of any kind.
getAccessToken ( ) : string Returns Telegram Bot API Access Token.
getChat ( array $params ) : Telegram\Bot\Objects\Chat Get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel,
getChatAdministrators ( array $params ) : ChatMember[] Get a list of administrators in a chat.
getChatMember ( array $params ) : ChatMember Get information about a member of a chat.
getChatMembersCount ( array $params ) : integer Get the number of members in a chat
getClient ( ) : Telegram\Bot\TelegramClient Returns the TelegramClient service.
getCommandBus ( ) : CommandBus Returns SDK's Command Bus.
getConnectTimeOut ( ) : integer
getContainer ( ) : Illuminate\Contracts\Container\Container Get the IoC Container.
getFile ( array $params ) : Telegram\Bot\Objects\File Returns basic info about a file and prepare it for downloading.
getLastResponse ( ) : TelegramResponse Returns the last response returned from API request.
getMe ( ) : Telegram\Bot\Objects\User A simple method for testing your bot's auth token.
getTimeOut ( ) : integer
getUpdates ( array $params = [], boolean $shouldEmitEvents = true ) : Update[] Use this method to receive incoming updates using long polling.
getUserProfilePhotos ( array $params ) : Telegram\Bot\Objects\UserProfilePhotos Returns a list of profile pictures for a user.
getWebhookUpdate ( $shouldEmitEvent = true ) : Update Returns a webhook update sent by Telegram.
getWebhookUpdates ( boolean $shouldEmitEvent = true ) : Update Alias for getWebhookUpdate
hasContainer ( ) : boolean Check if IoC Container has been set.
isAsyncRequest ( ) : boolean Check if this is an asynchronous request (non-blocking).
isMessageType ( string $type, Update | Message $object ) Determine if a given type is the message.
kickChatMember ( array $params ) : boolean Kick a user from a group or a supergroup.
manager ( $config ) : BotsManager Invoke Bots Manager.
processCommand ( Update $update ) Check update object for a command and process.
removeWebhook ( ) : TelegramResponse Removes the outgoing webhook (if any).
replyKeyboardHide ( array $params = [] ) : string Hide the current custom keyboard and display the default letter-keyboard.
replyKeyboardMarkup ( array $params ) : string Builds a custom keyboard markup.
sendAudio ( array $params ) : Message Send regular audio files.
sendChatAction ( array $params ) : boolean Broadcast a Chat Action.
sendContact ( array $params ) : Message Send phone contacts.
sendDocument ( array $params ) : Message Send general files.
sendLocation ( array $params ) : Message Send point on the map.
sendMessage ( array $params ) : Message Send text messages.
sendPhoto ( array $params ) : Message Send Photos.
sendSticker ( array $params ) : Message Send .webp stickers.
sendVenue ( array $params ) : Message Send information about a venue.
sendVideo ( array $params ) : Message Send Video File, Telegram clients support mp4 videos (other formats may be sent as Document).
sendVoice ( array $params ) : Message Send voice audio files.
setAccessToken ( string $accessToken ) : Api Sets the bot access token to use with API requests.
setAsyncRequest ( boolean $isAsyncRequest ) : Api Make this request asynchronous (non-blocking).
setConnectTimeOut ( integer $connectTimeOut )
setContainer ( Illuminate\Contracts\Container\Container $container ) : void Set the IoC Container.
setTimeOut ( integer $timeOut )
setWebhook ( array $params ) : TelegramResponse Set a Webhook to receive incoming updates via an outgoing webhook.
triggerCommand ( string $name, Update $update ) : mixed Helper to Trigger Commands.
unbanChatMember ( array $params ) : boolean Unban a previously kicked user in a supergroup.

Защищенные методы

Метод Описание
get ( string $endpoint, array $params = [] ) : TelegramResponse Sends a GET request to Telegram Bot API and returns the result.
isValidFileOrUrl ( string $name, string $contents ) : boolean Determines if the string passed to be uploaded is a valid file on the local file system, or a valid remote URL.
markUpdateAsRead ( $params ) : Update[] An alias for getUpdates that helps readability.
post ( string $endpoint, array $params = [], boolean $fileUpload = false ) : TelegramResponse Sends a POST request to Telegram Bot API and returns the result.
request ( string $method, string $endpoint, array $params = [] ) : Telegram\Bot\TelegramRequest Instantiates a new TelegramRequest entity.
sendRequest ( string $method, string $endpoint, array $params = [] ) : TelegramResponse Sends a request to Telegram Bot API and returns the result.
uploadFile ( string $endpoint, array $params = [] ) : TelegramResponse Sends a multipart/form-data request to Telegram Bot API and returns the result.

Описание методов

__call() публичный Метод

Magic method to process any "get" requests.
public __call ( $method, $arguments ) : boolean | TelegramResponse | Telegram\Bot\Objects\UnknownObject
$method
$arguments
Результат boolean | TelegramResponse | Telegram\Bot\Objects\UnknownObject

__construct() публичный Метод

Instantiates a new Telegram super-class object.
public __construct ( string $token = null, boolean $async = false, Telegram\Bot\HttpClients\HttpClientInterface $httpClientHandler = null )
$token string The Telegram Bot API Access Token.
$async boolean (Optional) Indicates if the request to Telegram will be asynchronous (non-blocking).
$httpClientHandler Telegram\Bot\HttpClients\HttpClientInterface (Optional) Custom HTTP Client Handler.

answerCallbackQuery() публичный Метод

he answer will be displayed to the user as a notification at the top of the chat screen or as an alert. $params = [ 'callback_query_id' => '', 'text' => '', 'show_alert' => '', ];
public answerCallbackQuery ( array $params ) : boolean
$params array
Результат boolean

answerInlineQuery() публичный Метод

$params = [ 'inline_query_id' => '', 'results' => [], 'cache_time' => 0, 'is_personal' => false, 'next_offset' => '', 'switch_pm_text' => '', 'switch_pm_parameter' => '', ];
public answerInlineQuery ( array $params = [] ) : boolean
$params array
Результат boolean

commandsHandler() публичный Метод

Processes Inbound Commands.
public commandsHandler ( boolean $webhook = false ) : Update | Update[]
$webhook boolean
Результат Telegram\Bot\Objects\Update | Telegram\Bot\Objects\Update[]

detectMessageType() публичный Метод

Detect Message Type Based on Update or Message Object.
Устаревший: Call method detectType directly on Message object To be removed in next major version.
public detectMessageType ( Update | Message $object ) : string | null
$object Telegram\Bot\Objects\Update | Telegram\Bot\Objects\Message
Результат string | null

editMessageCaption() публичный Метод

$params = [ 'chat_id' => '', 'message_id' => '', 'inline_message_id' => '', 'caption' => '', 'reply_markup' => '', ];
public editMessageCaption ( array $params ) : Message | boolean
$params array
Результат Telegram\Bot\Objects\Message | boolean

editMessageReplyMarkup() публичный Метод

$params = [ 'chat_id' => '', 'message_id' => '', 'inline_message_id' => '', 'reply_markup' => '', ];
public editMessageReplyMarkup ( array $params ) : Message | boolean
$params array
Результат Telegram\Bot\Objects\Message | boolean

editMessageText() публичный Метод

$params = [ 'chat_id' => '', 'message_id' => '', 'inline_message_id' => '', 'text' => '', 'parse_mode' => '', 'disable_web_page_preview' => '', 'reply_markup' => '', ];
public editMessageText ( array $params ) : Message | boolean
$params array
Результат Telegram\Bot\Objects\Message | boolean

forceReply() публичный статический Метод

$params = [ 'force_reply' => true, 'selective' => false, ];
Устаревший: Use Telegram\Bot\Keyboard\Keyboard::forceReply(array $params = []) instead. To be removed in next major version.
public static forceReply ( array $params = [] ) : Keyboard
$params array
Результат Telegram\Bot\Keyboard\Keyboard

forwardMessage() публичный Метод

$params = [ 'chat_id' => '', 'from_chat_id' => '', 'disable_notification' => '', 'message_id' => '', ];
public forwardMessage ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

get() защищенный Метод

Sends a GET request to Telegram Bot API and returns the result.
protected get ( string $endpoint, array $params = [] ) : TelegramResponse
$endpoint string
$params array
Результат TelegramResponse

getAccessToken() публичный Метод

Returns Telegram Bot API Access Token.
public getAccessToken ( ) : string
Результат string

getChat() публичный Метод

$params = [ 'chat_id' => '', ];
public getChat ( array $params ) : Telegram\Bot\Objects\Chat
$params array
Результат Telegram\Bot\Objects\Chat

getChatAdministrators() публичный Метод

$params = [ 'chat_id' => '', ];
public getChatAdministrators ( array $params ) : ChatMember[]
$params array
Результат Telegram\Bot\Objects\ChatMember[]

getChatMember() публичный Метод

$params = [ 'chat_id' => '', 'user_id' => '', ];
public getChatMember ( array $params ) : ChatMember
$params array
Результат Telegram\Bot\Objects\ChatMember

getChatMembersCount() публичный Метод

$params = [ 'chat_id' => '', ];
public getChatMembersCount ( array $params ) : integer
$params array
Результат integer

getClient() публичный Метод

Returns the TelegramClient service.
public getClient ( ) : Telegram\Bot\TelegramClient
Результат Telegram\Bot\TelegramClient

getCommandBus() публичный Метод

Returns SDK's Command Bus.
public getCommandBus ( ) : CommandBus
Результат Telegram\Bot\Commands\CommandBus

getConnectTimeOut() публичный Метод

public getConnectTimeOut ( ) : integer
Результат integer

getContainer() публичный Метод

Get the IoC Container.
public getContainer ( ) : Illuminate\Contracts\Container\Container
Результат Illuminate\Contracts\Container\Container

getFile() публичный Метод

$params = [ 'file_id' => '', ]; The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response.
public getFile ( array $params ) : Telegram\Bot\Objects\File
$params array
Результат Telegram\Bot\Objects\File

getLastResponse() публичный Метод

Returns the last response returned from API request.
public getLastResponse ( ) : TelegramResponse
Результат TelegramResponse

getMe() публичный Метод

Returns basic information about the bot in form of a User object.
public getMe ( ) : Telegram\Bot\Objects\User
Результат Telegram\Bot\Objects\User

getTimeOut() публичный Метод

public getTimeOut ( ) : integer
Результат integer

getUpdates() публичный Метод

$params = [ 'offset' => '', 'limit' => '', 'timeout' => '', ];
public getUpdates ( array $params = [], boolean $shouldEmitEvents = true ) : Update[]
$params array
$shouldEmitEvents boolean
Результат Telegram\Bot\Objects\Update[]

getUserProfilePhotos() публичный Метод

$params = [ 'user_id' => '', 'offset' => '', 'limit' => '', ];
public getUserProfilePhotos ( array $params ) : Telegram\Bot\Objects\UserProfilePhotos
$params array
Результат Telegram\Bot\Objects\UserProfilePhotos

getWebhookUpdate() публичный Метод

Works only if you set a webhook.
См. также: setWebhook
public getWebhookUpdate ( $shouldEmitEvent = true ) : Update
Результат Telegram\Bot\Objects\Update

getWebhookUpdates() публичный Метод

Alias for getWebhookUpdate
Устаревший: Call method getWebhookUpdate (note lack of letter s at end) To be removed in next major version.
public getWebhookUpdates ( boolean $shouldEmitEvent = true ) : Update
$shouldEmitEvent boolean
Результат Telegram\Bot\Objects\Update

hasContainer() публичный Метод

Check if IoC Container has been set.
public hasContainer ( ) : boolean
Результат boolean

isAsyncRequest() публичный Метод

Check if this is an asynchronous request (non-blocking).
public isAsyncRequest ( ) : boolean
Результат boolean

isMessageType() публичный Метод

Determine if a given type is the message.
Устаревший: Call method isType directly on Message object To be removed in next major version.
public isMessageType ( string $type, Update | Message $object )
$type string
$object Telegram\Bot\Objects\Update | Telegram\Bot\Objects\Message

isValidFileOrUrl() защищенный Метод

Determines if the string passed to be uploaded is a valid file on the local file system, or a valid remote URL.
protected isValidFileOrUrl ( string $name, string $contents ) : boolean
$name string
$contents string
Результат boolean

kickChatMember() публичный Метод

In the case of supergroups, the user will not be able to return to the group on their own using invite links etc., unless unbanned first. The bot must be an administrator in the group for this to work. $params = [ 'chat_id' => '', 'user_id' => '', ];
public kickChatMember ( array $params ) : boolean
$params array
Результат boolean

manager() публичный статический Метод

Invoke Bots Manager.
public static manager ( $config ) : BotsManager
$config
Результат BotsManager

markUpdateAsRead() защищенный Метод

An alias for getUpdates that helps readability.
protected markUpdateAsRead ( $params ) : Update[]
$params
Результат Telegram\Bot\Objects\Update[]

post() защищенный Метод

Sends a POST request to Telegram Bot API and returns the result.
protected post ( string $endpoint, array $params = [], boolean $fileUpload = false ) : TelegramResponse
$endpoint string
$params array
$fileUpload boolean Set true if a file is being uploaded.
Результат TelegramResponse

processCommand() публичный Метод

Check update object for a command and process.
public processCommand ( Update $update )
$update Telegram\Bot\Objects\Update

removeWebhook() публичный Метод

Removes the outgoing webhook (if any).
public removeWebhook ( ) : TelegramResponse
Результат TelegramResponse

replyKeyboardHide() публичный статический Метод

$params = [ 'hide_keyboard' => true, 'selective' => false, ];
Устаревший: Use Telegram\Bot\Keyboard\Keyboard::hide(array $params = []) instead. To be removed in next major version.
public static replyKeyboardHide ( array $params = [] ) : string
$params array
Результат string

replyKeyboardMarkup() публичный Метод

$params = [ 'keyboard' => '', 'resize_keyboard' => '', 'one_time_keyboard' => '', 'selective' => '', ];
Устаревший: Use Telegram\Bot\Keyboard\Keyboard::make(array $params = []) instead. To be removed in next major version.
public replyKeyboardMarkup ( array $params ) : string
$params array
Результат string

request() защищенный Метод

Instantiates a new TelegramRequest entity.
protected request ( string $method, string $endpoint, array $params = [] ) : Telegram\Bot\TelegramRequest
$method string
$endpoint string
$params array
Результат Telegram\Bot\TelegramRequest

sendAudio() публичный Метод

$params = [ 'chat_id' => '', 'audio' => '', 'duration' => '', 'performer' => '', 'title' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendAudio ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendChatAction() публичный Метод

$params = [ 'chat_id' => '', 'action' => '', ];
public sendChatAction ( array $params ) : boolean
$params array
Результат boolean

sendContact() публичный Метод

$params = [ 'chat_id' => '', 'phone_number' => '', 'first_name' => '', 'last_name' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendContact ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendDocument() публичный Метод

$params = [ 'chat_id' => '', 'document' => '', 'caption' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendDocument ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendLocation() публичный Метод

$params = [ 'chat_id' => '', 'latitude' => '', 'longitude' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendLocation ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendMessage() публичный Метод

$params = [ 'chat_id' => '', 'text' => '', 'parse_mode' => '', 'disable_web_page_preview' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendMessage ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendPhoto() публичный Метод

$params = [ 'chat_id' => '', 'photo' => '', 'caption' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendPhoto ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendRequest() защищенный Метод

Sends a request to Telegram Bot API and returns the result.
protected sendRequest ( string $method, string $endpoint, array $params = [] ) : TelegramResponse
$method string
$endpoint string
$params array
Результат TelegramResponse

sendSticker() публичный Метод

$params = [ 'chat_id' => '', 'sticker' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendSticker ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendVenue() публичный Метод

$params = [ 'chat_id' => '', 'latitude' => '', 'longitude' => '', 'title' => '', 'address' => '', 'foursquare_id' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendVenue ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendVideo() публичный Метод

$params = [ 'chat_id' => '', 'video' => '', 'duration' => '', 'width' => '', 'height' => '', 'caption' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
См. также: sendDocument
public sendVideo ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

sendVoice() публичный Метод

$params = [ 'chat_id' => '', 'voice' => '', 'duration' => '', 'disable_notification' => '', 'reply_to_message_id' => '', 'reply_markup' => '', ];
public sendVoice ( array $params ) : Message
$params array
Результат Telegram\Bot\Objects\Message

setAccessToken() публичный Метод

Sets the bot access token to use with API requests.
public setAccessToken ( string $accessToken ) : Api
$accessToken string The bot access token to save.
Результат Api

setAsyncRequest() публичный Метод

Make this request asynchronous (non-blocking).
public setAsyncRequest ( boolean $isAsyncRequest ) : Api
$isAsyncRequest boolean
Результат Api

setConnectTimeOut() публичный Метод

public setConnectTimeOut ( integer $connectTimeOut )
$connectTimeOut integer

setContainer() публичный статический Метод

Set the IoC Container.
public static setContainer ( Illuminate\Contracts\Container\Container $container ) : void
$container Illuminate\Contracts\Container\Container Container instance
Результат void

setTimeOut() публичный Метод

public setTimeOut ( integer $timeOut )
$timeOut integer

setWebhook() публичный Метод

$params = [ 'url' => '', 'certificate' => '', ];
public setWebhook ( array $params ) : TelegramResponse
$params array
Результат TelegramResponse

triggerCommand() публичный Метод

Helper to Trigger Commands.
public triggerCommand ( string $name, Update $update ) : mixed
$name string Command Name
$update Telegram\Bot\Objects\Update Update Object
Результат mixed

unbanChatMember() публичный Метод

The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work. $params = [ 'chat_id' => '', 'user_id' => '', ];
public unbanChatMember ( array $params ) : boolean
$params array
Результат boolean

uploadFile() защищенный Метод

Used primarily for file uploads.
protected uploadFile ( string $endpoint, array $params = [] ) : TelegramResponse
$endpoint string
$params array
Результат TelegramResponse

Описание свойств

$accessToken защищенное свойство

Telegram Bot API Access Token.
protected $accessToken

$client защищенное свойство

The Telegram client service.
protected $client

$commandBus защищенное свойство

Telegram Command Bus.
protected $commandBus

$connectTimeOut защищенное свойство

Connection timeout of the request in seconds.
protected int $connectTimeOut
Результат integer

$container защищенное статическое свойство

IoC Container
protected static $container

$isAsyncRequest защищенное свойство

Indicates if the request to Telegram will be asynchronous (non-blocking).
protected $isAsyncRequest

$lastResponse защищенное свойство

Stores the last request made to Telegram Bot API.
protected $lastResponse

$timeOut защищенное свойство

Timeout of the request in seconds.
protected int $timeOut
Результат integer