PhpBotFramework  1.0.0
A framework for Telegram Bots' APIs.
Functions
Api Methods

Functions

DanySpin97\PhpBotFramework\CoreBot::getUpdates (int $offset=0, int $limit=100, int $timeout=60)
 Request bot updates. More...
 
DanySpin97\PhpBotFramework\CoreBot::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...
 
DanySpin97\PhpBotFramework\CoreBot::forwardMessage ($from_chat_id, int $message_id, bool $disable_notification=false)
 Forward a message. More...
 
DanySpin97\PhpBotFramework\CoreBot::sendPhoto ($photo, string $reply_markup=null, string $caption='', bool $disable_notification=false)
 Send a photo. More...
 
DanySpin97\PhpBotFramework\CoreBot::sendAudio ($audio, string $caption=null, string $reply_markup=null, int $duration=null, string $title=null, bool $disable_notification=false, int $reply_to_message_id=null)
 Send an audio. More...
 
DanySpin97\PhpBotFramework\CoreBot::senddocument ($document, string $caption='', string $reply_markup=null, bool $disable_notification=false, int $reply_to_message_id=null)
 Send a document. More...
 
DanySpin97\PhpBotFramework\CoreBot::sendSticker ($sticker, string $reply_markup=null, bool $disable_notification=false, int $reply_to_message_id=null)
 Send a sticker. More...
 
DanySpin97\PhpBotFramework\CoreBot::sendChatAction (string $action)
 Say the user what action is the bot doing. More...
 
DanySpin97\PhpBotFramework\CoreBot::getChat ($chat_id)
 Get info about a chat. More...
 
DanySpin97\PhpBotFramework\CoreBot::answerCallbackQuery ($text='', $show_alert=false, string $url='')
 
DanySpin97\PhpBotFramework\CoreBot::editMessageText ($text, int $message_id, $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=false)
 Edit text of a message sent by the bot. More...
 
DanySpin97\PhpBotFramework\CoreBot::editInlineMessageText ($text, string $inline_message_id, string $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=false)
 Edit text of a message sent via the bot. More...
 
DanySpin97\PhpBotFramework\CoreBot::editMessageReplyMarkup ($message_id, $inline_keyboard)
 
DanySpin97\PhpBotFramework\CoreBot::answerInlineQuerySwitchPM ($results, $switch_pm_text, $switch_pm_parameter='', $is_personal=true, $cache_time=300)
 
DanySpin97\PhpBotFramework\CoreBot::answerEmptyInlineQuerySwitchPM ($switch_pm_text, $switch_pm_parameter='', $is_personal=true, $cache_time=300)
 
DanySpin97\PhpBotFramework\CoreBot::apiRequest (string $method, array $parameters)
 Exec any api request using this method. More...
 

Detailed Description

Function Documentation

§ apiRequest()

& DanySpin97\PhpBotFramework\CoreBot::apiRequest ( string  $method,
array  $parameters 
)

Exec 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);
Parameters
$methodThe method to call.
$parametersParameters to add.
Returns
Depends on api method.

§ editInlineMessageText()

& DanySpin97\PhpBotFramework\CoreBot::editInlineMessageText (   $text,
string  $inline_message_id,
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

Parameters
$textNew text of the message.
$inline_message_idIdentifier of the inline message.
$reply_markupReply markup of the message will have (will be removed if this is null).
$parse_modeOptional. Send Markdown or HTML.
$disable_web_previewOptional. Disables link previews for links in this message.

§ editMessageText()

& DanySpin97\PhpBotFramework\CoreBot::editMessageText (   $text,
int  $message_id,
  $reply_markup = null,
string  $parse_mode = 'HTML',
bool  $disable_web_preview = false 
)

Edit text of a message sent by the bot.

Use this method to edit text and game messages sent by the bot. Api reference

Parameters
$textNew text of the message.
$message_idUnique identifier of the sent message.
$reply_markupReply markup of the message will have (will be removed if this is null).
$parse_modeOptional. Send Markdown or HTML.
$disable_web_previewOptional. Disables link previews for links in this message.

§ forwardMessage()

& DanySpin97\PhpBotFramework\CoreBot::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

Parameters
$from_chat_idThe chat where the original message was sent.
$message_idMessage identifier (id).
$disable_notificationOptional. Sends the message silently.
Returns
On success, the sent message.

§ getChat()

& DanySpin97\PhpBotFramework\CoreBot::getChat (   $chat_id)

Get info about a chat.

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.). Api reference

Parameters
Uniqueidentifier for the target chat or username of the target supergroup or channel (in the format )

§ getUpdates()

& DanySpin97\PhpBotFramework\CoreBot::getUpdates ( int  $offset = 0,
int  $limit = 100,
int  $timeout = 60 
)
protected

Request bot updates.

Request updates received by the bot using method getUpdates of Telegram API. Api reference

Parameters
$offsetOptional. 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.
$limitOptional. Limits the number of updates to be retrieved. Values between 1—100 are accepted.
$timeoutOptional. Timeout in seconds for long polling.
Returns
Array of updates (can be empty).

§ sendAudio()

& DanySpin97\PhpBotFramework\CoreBot::sendAudio (   $audio,
string  $caption = null,
string  $reply_markup = null,
int  $duration = null,
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.

Parameters
$audioAudio 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 upload a new one using multipart/form-data.
$captionOptional. Audio caption, 0-200 characters.
reply_markupOptional. JSON-serialized object for keyboard.
$durationOptional. Duration of the audio in seconds.
$performerOptional. Performer.
$titleOptional. Track name.
$disable_notificationOptional. Sends the message silently.
$reply_to_message_idOptional. If the message is a reply, ID of the original message.
Returns
On success, the sent message.

§ sendChatAction()

& DanySpin97\PhpBotFramework\CoreBot::sendChatAction ( string  $action)

Say the user what action is the bot doing.

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

Parameters
$actionType of action to broadcast. Choose one, depending on what the user is about to receive:
  • typing for text messages
  • upload_photo for photos
  • record_video or upload_video for videos
  • record_audio or upload_audio for audio files
  • upload_document for general files
  • find_location for location data
Returns
True on success.

§ senddocument()

& DanySpin97\PhpBotFramework\CoreBot::senddocument (   $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

Parameters
$documentFile 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 upload a new one using multipart/form-data.
<i>Optional</i>.Document caption (may also be used when resending documents by file_id), 0-200 characters.
$reply_markup
<i>Optional</i>.Sends the message silently.
<i>Optional</i>.If the message is a reply, ID of the original message.

§ sendMessage()

& DanySpin97\PhpBotFramework\CoreBot::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

Parameters
$textText of the message.
$reply_markupOptional. Reply_markup of the message.
$parse_modeOptional. Parse mode of the message.
$disable_web_previewOptional. Disables link previews for links in this message.
$disable_notificationOptional. Sends the message silently.
Returns
On success, the sent message.

§ sendPhoto()

& DanySpin97\PhpBotFramework\CoreBot::sendPhoto (   $photo,
string  $reply_markup = null,
string  $caption = '',
bool  $disable_notification = false 
)

Send a photo.

Use this method to send photos. Api reference

Parameters
$photoPhoto to send, can be a file_id or a string referencing the location of that image.
$reply_markupOptional. Reply markup of the message.
$captionOptional. Photo caption (may also be used when resending photos by file_id), 0-200 characters.
$disable_notificationOptional. Sends the message silently.
Returns
On success, the sent message.

§ sendSticker()

& DanySpin97\PhpBotFramework\CoreBot::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

Parameters
$stickerSticker 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.
$disable_notificationSends the message silently.
Onsuccess, the sent message.