PHP 클래스 Telegram\Bot\Api

상속: use trait Telegram\Bot\Events\EmitsEvents
파일 보기 프로젝트 열기: irazasyed/telegram-bot-sdk 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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