PhpBotFramework
2.0.2
A framework for Telegram Bots' APIs.
|
Implementations for Telegram Bot API's methods. More...
Functions | |
Array false | PhpBotFramework\Core\Chat::getMe () |
A simple method for testing bot's auth token. More... | |
Array false | PhpBotFramework\Core\Chat::getChat ($chat_id) |
Get info about a chat. More... | |
Array false | PhpBotFramework\Core\Chat::getChatAdministrators ($chat_id) |
Use this method to get the list of chat's administrators. More... | |
mixed | PhpBotFramework\Core\CoreBot::apiRequest (string $method, array $parameters) |
Execute any API request using this method. More... | |
Message false | PhpBotFramework\Core\Edit::editMessageText (int $message_id, string $text, string $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=true) |
Edit text of a message sent by the bot. More... | |
bool | PhpBotFramework\Core\Edit::editInlineMessageText (string $inline_message_id, string $text, string $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=false) |
Edit text of a message sent via the bot. More... | |
Message false | PhpBotFramework\Core\Edit::editMessageReplyMarkup (int $message_id, string $inline_keyboard) |
Edit only the inline keyboard of a message. More... | |
bool | PhpBotFramework\Core\Inline::answerCallbackQuery ($text='', $show_alert=false, string $url='') |
Answer a callback query. More... | |
bool | PhpBotFramework\Core\Inline::answerInlineQuery (string $results='', string $switch_pm_text='', $switch_pm_parameter='', bool $is_personal=true, int $cache_time=300) |
Answer a inline query (when the user write "Query") with a button, that will make user switch to the private chat with the bot, on the top of the results. Api reference More... | |
Message false | PhpBotFramework\Core\Send::sendMessage ($text, string $reply_markup=null, int $reply_to=null, string $parse_mode='HTML', bool $disable_web_preview=true, bool $disable_notification=false) |
Send a text message. More... | |
Message false | PhpBotFramework\Core\Send::forwardMessage ($from_chat_id, int $message_id, bool $disable_notification=false) |
Forward a message. More... | |
Message false | PhpBotFramework\Core\Send::sendPhoto (&$photo, string $reply_markup=null, string $caption='', bool $disable_notification=false) |
Send a photo. More... | |
Message false | PhpBotFramework\Core\Send::sendAudio ($audio, string $caption=null, string $reply_markup=null, int $duration=null, string $performer, string $title=null, bool $disable_notification=false, int $reply_to_message_id=null) |
Send an audio. More... | |
Message false | PhpBotFramework\Core\Send::sendDocument (string $document, string $caption='', string $reply_markup=null, bool $disable_notification=false, int $reply_to_message_id=null) |
Send a document. More... | |
Message false | PhpBotFramework\Core\Send::sendSticker ($sticker, string $reply_markup=null, bool $disable_notification=false, int $reply_to_message_id=null) |
Send a sticker. More... | |
Message false | PhpBotFramework\Core\Send::sendVoice ($voice, string $caption, int $duration, string $reply_markup=null, bool $disable_notification, int $reply_to_message_id=0) |
Send audio files. More... | |
bool | PhpBotFramework\Core\Send::sendChatAction (string $action) |
Say the user what action bot's going to do. More... | |
PhpBotFramework\Core\Updates::setWebhook (array $params) | |
Set bot's webhook. More... | |
Array false | PhpBotFramework\Core\Updates::getWebhookInfo () |
Get information about bot's webhook. More... | |
PhpBotFramework\Core\Updates::deleteWebhook () | |
Delete bot's webhook. More... | |
Array false | PhpBotFramework\Core\Updates::getUpdates (int $offset=0, int $limit=100, int $timeout=60) |
Request bot updates. More... | |
PhpBotFramework\Core\Updates::setUpdateReturned (array $allowed_updates=[]) | |
Set updates received by the bot for getUpdates handling. More... | |
Implementations for Telegram Bot API's methods.
bool PhpBotFramework\Core\Inline::answerCallbackQuery | ( | $text = '' , |
|
$show_alert = false , |
|||
string | $url = '' |
||
) |
Answer a callback query.
Remove the 'updating' circle icon on an inline keyboard button showing a message/alert to the user. It'll always answer the current callback query. Api reference
string | $text | Optional. Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters. |
bool | $show_alert | Optional. If true, an alert will be shown by the client instead of a notification at the top of the chat screen. |
string | $url | Optional. URL that will be opened by the user's client. If you have created a Game and accepted the conditions via , specify the URL that opens your game – note that this will only work if the query comes from a callback_game button. Otherwise, you may use links like telegram.me/your_bot?start=XXXX that open your bot with a parameter. |
bool PhpBotFramework\Core\Inline::answerInlineQuery | ( | string | $results = '' , |
string | $switch_pm_text = '' , |
||
$switch_pm_parameter = '' , |
|||
bool | $is_personal = true , |
||
int | $cache_time = 300 |
||
) |
Answer a inline query (when the user write "Query") with a button, that will make user switch to the private chat with the bot, on the top of the results. Api reference
string | $results | A JSON-serialized array of results for the inline query. Use PhpBotFramework class to create and get them. |
string | $switch_pm_text | If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter $switch_pm_parameter. |
bool | $is_personal | Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query. |
int | $cache_time | The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. |
mixed PhpBotFramework\Core\CoreBot::apiRequest | ( | string | $method, |
array | $parameters | ||
) |
Execute any API request using this method.
Use this method for custom api calls using this syntax:
$param = [ 'chat_id' => $_chat_id, 'text' => 'Hello!' ]; apiRequest("sendMessage", $param);
string | $method | The method to call. |
array | $parameters | Parameters to add. |
PhpBotFramework\Core\Updates::deleteWebhook | ( | ) |
Delete bot's webhook.
Delete bot's webhook if it exists.
bool PhpBotFramework\Core\Edit::editInlineMessageText | ( | string | $inline_message_id, |
string | $text, | ||
string | $reply_markup = null , |
||
string | $parse_mode = 'HTML' , |
||
bool | $disable_web_preview = false |
||
) |
Edit text of a message sent via the bot.
Use this method to edit text messages sent via the bot (for inline queries). API reference
string | $inline_message_id | Identifier of the inline message. |
string | $text | New text of the message. |
string | $reply_markup | Reply markup of the message will have (will be removed if this is null). |
string | $parse_mode | Optional. Send Markdown or HTML. |
bool | $disable_web_preview | Optional. Disables link previews for links in this message. |
Message false PhpBotFramework\Core\Edit::editMessageReplyMarkup | ( | int | $message_id, |
string | $inline_keyboard | ||
) |
Edit only the inline keyboard of a message.
int | $message_id | Identifier of the message to edit |
string | $inline_keyboard | Inlike keyboard array. API reference |
Message false PhpBotFramework\Core\Edit::editMessageText | ( | int | $message_id, |
string | $text, | ||
string | $reply_markup = null , |
||
string | $parse_mode = 'HTML' , |
||
bool | $disable_web_preview = true |
||
) |
Edit text of a message sent by the bot.
Use this method to edit text and game messages sent by the bot. API reference
int | $message_id | Unique identifier of the sent message. |
string | $text | New text of the message. |
string | $reply_markup | Reply markup of the message will have (will be removed if this is null). |
string | $parse_mode | Optional. Send Markdown or HTML. |
bool | $disable_web_preview | Optional. Disables link previews for links in this message. |
Message false PhpBotFramework\Core\Send::forwardMessage | ( | $from_chat_id, | |
int | $message_id, | ||
bool | $disable_notification = false |
||
) |
Forward a message.
Use this method to forward messages of any kind. API reference
$from_chat_id | The chat where the original message was sent. |
$message_id | Message identifier (id). |
$disable_notification | Optional. Sends the message silently. |
Array false PhpBotFramework\Core\Chat::getChat | ( | $chat_id | ) |
Get info about a chat.
Use this method to get information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). API reference
int | string | $chat_id | Unique identifier for the target chat or username of the target supergroup or channel (in the format ) |
Array false PhpBotFramework\Core\Chat::getChatAdministrators | ( | $chat_id | ) |
Use this method to get the list of chat's administrators.
string | $chat_id | Unique identifier for the target chat or username of the target supergroup or channel (in the format ) |
Array false PhpBotFramework\Core\Chat::getMe | ( | ) |
A simple method for testing bot's auth token.
Requires no parameters. Returns basic information about the bot
Array false PhpBotFramework\Core\Updates::getUpdates | ( | int | $offset = 0 , |
int | $limit = 100 , |
||
int | $timeout = 60 |
||
) |
Request bot updates.
Request updates received by the bot using method getUpdates of Telegram API. API reference
int | $offset | Optional. Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten. |
int | $limit | Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. |
int | $timeout | Optional. Timeout in seconds for long polling. |
Array false PhpBotFramework\Core\Updates::getWebhookInfo | ( | ) |
Get information about bot's webhook.
Returns an hash which contains information about bot's webhook.
Message false PhpBotFramework\Core\Send::sendAudio | ( | $audio, | |
string | $caption = null , |
||
string | $reply_markup = null , |
||
int | $duration = null , |
||
string | $performer, | ||
string | $title = null , |
||
bool | $disable_notification = false , |
||
int | $reply_to_message_id = null |
||
) |
Send an audio.
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. API reference Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
$audio | Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or give the local path of an audio to upload. |
$caption | Optional. Audio caption, 0-200 characters. |
$reply_markup | Optional. Reply markup of the message. |
$duration | Optional. Duration of the audio in seconds. |
$performer | Optional. Performer. |
$title | Optional. Track name. |
$disable_notification | Optional. Sends the message silently. |
$reply_to_message_id | Optional. If the message is a reply, ID of the original message. |
bool PhpBotFramework\Core\Send::sendChatAction | ( | string | $action | ) |
Say the user what action bot's going to do.
Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). API reference
string | $action | Type of action to broadcast. Choose one, depending on what the user is about to receive:
|
Message false PhpBotFramework\Core\Send::sendDocument | ( | string | $document, |
string | $caption = '' , |
||
string | $reply_markup = null , |
||
bool | $disable_notification = false , |
||
int | $reply_to_message_id = null |
||
) |
Send a document.
Use this method to send general files. API reference
string | $document | File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or give the local path of an document to upload it. Only some document are allowed through url sending (this is a Telegram limitation). |
string | $caption | Optional. Document caption (may also be used when resending documents by file_id), 0-200 characters. |
string | $reply_markup | Optional. Reply markup of the message. |
bool | $disable_notification | Optional. Sends the message silently. |
int | $reply_to_message_id | Optional. If the message is a reply, ID of the original message. |
Message false PhpBotFramework\Core\Send::sendMessage | ( | $text, | |
string | $reply_markup = null , |
||
int | $reply_to = null , |
||
string | $parse_mode = 'HTML' , |
||
bool | $disable_web_preview = true , |
||
bool | $disable_notification = false |
||
) |
Send a text message.
Use this method to send text messages. API reference
$text | Text of the message. |
$reply_markup | Optional. Reply_markup of the message. |
$parse_mode | Optional. Parse mode of the message. |
$disable_web_preview | Optional. Disables link previews for links in this message. |
$disable_notification | Optional. Sends the message silently. |
Message false PhpBotFramework\Core\Send::sendPhoto | ( | & | $photo, |
string | $reply_markup = null , |
||
string | $caption = '' , |
||
bool | $disable_notification = false |
||
) |
Send a photo.
Use this method to send photos. API reference
$photo | Photo to send, can be a file_id or a string referencing the location of that image(both local or remote path). |
$reply_markup | Optional. Reply markup of the message. |
$caption | Optional. Photo caption (may also be used when resending photos by file_id), 0-200 characters. |
$disable_notification | Optional. Sends the message silently. |
Message false PhpBotFramework\Core\Send::sendSticker | ( | $sticker, | |
string | $reply_markup = null , |
||
bool | $disable_notification = false , |
||
int | $reply_to_message_id = null |
||
) |
Send a sticker.
Use this method to send .webp stickers. API reference
mixed | $sticker | Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data. |
string | $reply_markup | Optional. Reply markup of the message. |
bool | $disable_notification | Sends the message silently. |
int | $reply_to_message_id | Optional. If the message is a reply, ID of the original message. |
bool | On success, the sent message. |
Message false PhpBotFramework\Core\Send::sendVoice | ( | $voice, | |
string | $caption, | ||
int | $duration, | ||
string | $reply_markup = null , |
||
bool | $disable_notification, | ||
int | $reply_to_message_id = 0 |
||
) |
Send audio files.
Use this method to send audio files, if you want Telegram clients to 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).o Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
mixed | $voice | Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or the local path of a voice to upload. |
string | $caption | Optional. Voice message caption, 0-200 characters |
int | $duration | Optional. Duration of the voice message in seconds |
string | $reply_markup | Optional. Reply markup of the message. |
bool | $disable_notification | Optional. Sends the message silently. |
int | $reply_to_message_id | Optional. If the message is a reply, ID of the original message. |
PhpBotFramework\Core\Updates::setUpdateReturned | ( | array | $allowed_updates = [] | ) |
Set updates received by the bot for getUpdates handling.
List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. Specify an empty list to receive all updates regardless of type. Set it one time and it won't change until next setUpdateReturned call.
Array | $allowed_updates | Optional. List of updates allowed. |
PhpBotFramework\Core\Updates::setWebhook | ( | array | $params | ) |
Set bot's webhook.
Set a webhook for the current bot in order to receive incoming updates via an outgoing webhook.
$params | See Telegram API for more information about the available parameters. |