PHP Класс Longman\TelegramBot\Request

Показать файл Открыть проект Примеры использования класса

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

Метод Описание
answerCallbackQuery ( array $data ) : ServerResponse Use this method to send answers to callback queries sent from inline keyboards. On success, True is returned.
answerInlineQuery ( array $data ) : ServerResponse Use this method to send answers to an inline query. On success, True is returned.
downloadFile ( Longman\TelegramBot\Entities\File $file ) : boolean Download file
editMessageCaption ( array $data ) : ServerResponse Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
editMessageReplyMarkup ( array $data ) : ServerResponse Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
editMessageText ( array $data ) : ServerResponse Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
emptyResponse ( ) : ServerResponse Return an empty Server Response
execute ( string $action, array $data = [] ) : string Execute HTTP Request
forwardMessage ( array $data ) : ServerResponse Use this method to forward messages of any kind. On success, the sent Message is returned
generateGeneralFakeServerResponse ( array $data = [] ) : array Generate general fake server response
getChat ( array $data ) : ServerResponse Use this method to 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, etc.). Returns a Chat object on success.
getChatAdministrators ( array $data ) : ServerResponse Use this method to get a list of administrators in a chat.
getChatMember ( array $data ) : ServerResponse Use this method to get information about a member of a chat. Returns a ChatMember object on success.
getChatMembersCount ( array $data ) : ServerResponse Use this method to get the number of members in a chat. Returns Int on success.
getFile ( array $data ) : ServerResponse Use this method to get basic info about a file and prepare it for downloading. On success, a File object is returned.
getInput ( ) : string Set input from custom input or stdin and return it
getMe ( ) : ServerResponse Returns basic information about the bot in form of a User object
getUpdates ( array $data ) : ServerResponse Get updates
getUserProfilePhotos ( array $data ) : ServerResponse Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
getWebhookInfo ( ) : ServerResponse Use this method to get current webhook status.
initialize ( Telegram $telegram ) Initialize
kickChatMember ( array $data ) : ServerResponse Use this method to kick a user from a group or a supergroup. Returns True on success.
leaveChat ( array $data ) : ServerResponse Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
send ( string $action, array $data = [] ) : ServerResponse Send command
sendAudio ( array $data, string $file = null ) : ServerResponse Use this method to send audio files
sendChatAction ( array $data ) : ServerResponse Use this method when you need to tell the user that something is happening on the bot's side.
sendContact ( array $data ) : ServerResponse Use this method to send phone contacts. On success, the sent Message is returned.
sendDocument ( array $data, string $file = null ) : ServerResponse Use this method to send general files. On success, the sent Message is returned.
sendLocation ( array $data ) : ServerResponse Use this method to send point on the map. On success, the sent Message is returned.
sendMessage ( array $data ) : ServerResponse Use this method to send text messages. On success, the sent Message is returned
sendPhoto ( array $data, string $file = null ) : ServerResponse Use this method to send photos. On success, the sent Message is returned
sendSticker ( array $data, string $file = null ) : ServerResponse Use this method to send .webp stickers. On success, the sent Message is returned.
sendToActiveChats ( string $callback_function, array $data, boolean $send_groups = true, boolean $send_super_groups = true, boolean $send_users = true, string $date_from = null, string $date_to = null ) : array Send message to all active chats
sendVenue ( array $data ) : ServerResponse Use this method to send information about a venue. On success, the sent Message is returned.
sendVideo ( array $data, string $file = null ) : ServerResponse Use this method to send video files. On success, the sent Message is returned.
sendVoice ( array $data, string $file = null ) : ServerResponse Use this method to send audio files. On success, the sent Message is returned.
setWebhook ( string $url = '', string $file = null ) : ServerResponse Set webhook
unbanChatMember ( array $data ) : ServerResponse Use this method to unban a previously kicked user in a supergroup. Returns True on success.

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

Метод Описание
encodeFile ( string $file ) : resource Encode file

Приватные методы

Метод Описание
assignEncodedFile ( array &$data, string $field, string $file ) Assign an encoded file to a data array
ensureNonEmptyData ( array $data ) Make sure the data isn't empty, else throw an exception
ensureValidAction ( string $action ) Make sure the action is valid, else throw an exception
setUpRequestParams ( array $data ) : array Properly set up the request params

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

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

The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
public static answerCallbackQuery ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

No more than 50 results per query are allowed.
public static answerInlineQuery ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Download file
public static downloadFile ( Longman\TelegramBot\Entities\File $file ) : boolean
$file Longman\TelegramBot\Entities\File
Результат boolean

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

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
public static editMessageCaption ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
public static editMessageReplyMarkup ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
public static editMessageText ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

No request to telegram are sent, this function is used in commands that don't need to fire a message after execution
public static emptyResponse ( ) : ServerResponse
Результат Longman\TelegramBot\Entities\ServerResponse

encodeFile() защищенный статический Метод

Encode file
protected static encodeFile ( string $file ) : resource
$file string
Результат resource

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

Execute HTTP Request
public static execute ( string $action, array $data = [] ) : string
$action string Action to execute
$data array Data to attach to the execution
Результат string Result of the HTTP Request

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

Use this method to forward messages of any kind. On success, the sent Message is returned
public static forwardMessage ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Generate general fake server response
public static generateGeneralFakeServerResponse ( array $data = [] ) : array
$data array Data to add to fake response
Результат array Fake response data

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

Use this method to 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, etc.). Returns a Chat object on success.
public static getChat ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
public static getChatAdministrators ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to get information about a member of a chat. Returns a ChatMember object on success.
public static getChatMember ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to get the number of members in a chat. Returns Int on success.
public static getChatMembersCount ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

For the moment, bots can download files of up to 20MB in size. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
public static getFile ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Set input from custom input or stdin and return it
public static getInput ( ) : string
Результат string

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

Returns basic information about the bot in form of a User object
public static getMe ( ) : ServerResponse
Результат Longman\TelegramBot\Entities\ServerResponse

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

Get updates
public static getUpdates ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
public static getUserProfilePhotos ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to get current webhook status.
public static getWebhookInfo ( ) : ServerResponse
Результат Longman\TelegramBot\Entities\ServerResponse

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

Initialize
public static initialize ( Telegram $telegram )
$telegram Telegram

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.
public static kickChatMember ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
public static leaveChat ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Send command
public static send ( string $action, array $data = [] ) : ServerResponse
$action string
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use the sendVoice method instead.
public static sendAudio ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Результат Longman\TelegramBot\Entities\ServerResponse

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

The status is set for 5 seconds or less. (when a message arrives from your bot, Telegram clients clear its typing status)
public static sendChatAction ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to send phone contacts. On success, the sent Message is returned.
public static sendContact ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
public static sendDocument ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to send point on the map. On success, the sent Message is returned.
public static sendLocation ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to send text messages. On success, the sent Message is returned
public static sendMessage ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to send photos. On success, the sent Message is returned
public static sendPhoto ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Результат Longman\TelegramBot\Entities\ServerResponse

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

Use this method to send .webp stickers. On success, the sent Message is returned.
public static sendSticker ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Результат Longman\TelegramBot\Entities\ServerResponse

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

Send message to all active chats
public static sendToActiveChats ( string $callback_function, array $data, boolean $send_groups = true, boolean $send_super_groups = true, boolean $send_users = true, string $date_from = null, string $date_to = null ) : array
$callback_function string
$data array
$send_groups boolean
$send_super_groups boolean
$send_users boolean
$date_from string
$date_to string
Результат array

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

Use this method to send information about a venue. On success, the sent Message is returned.
public static sendVenue ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse

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

Telegram clients support mp4 videos (other formats may be sent as Document). Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
public static sendVideo ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Результат Longman\TelegramBot\Entities\ServerResponse

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

Telegram clients will display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
public static sendVoice ( array $data, string $file = null ) : ServerResponse
$data array
$file string
Результат Longman\TelegramBot\Entities\ServerResponse

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

Set webhook
public static setWebhook ( string $url = '', string $file = null ) : ServerResponse
$url string
$file string
Результат Longman\TelegramBot\Entities\ServerResponse

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.
public static unbanChatMember ( array $data ) : ServerResponse
$data array
Результат Longman\TelegramBot\Entities\ServerResponse