![]() |
PhpBotFramework
1.0.0
A framework for Telegram Bots' APIs.
|
Functions | |
| DanySpin97\PhpBotFramework\Bot::__construct (string $token) | |
| Construct an empy bot. More... | |
| DanySpin97\PhpBotFramework\Bot::__destruct () | |
| Descruct the class. | |
| & | DanySpin97\PhpBotFramework\Bot::getText () |
| Get the text of the message (for updates of type "message"). More... | |
| & | DanySpin97\PhpBotFramework\Bot::getData () |
| Get the data received from the callback query (for updates of type "callback_query"). More... | |
| & | DanySpin97\PhpBotFramework\Bot::getQuery () |
| Get the query received from the inline query (for updates of type "inline_query"). More... | |
| DanySpin97\PhpBotFramework\Bot::processWebhookUpdate () | |
| Get update and process it. More... | |
| DanySpin97\PhpBotFramework\Bot::processMessage (&$message) | |
| Called every message received by the bot. More... | |
| DanySpin97\PhpBotFramework\Bot::processCallbackQuery (&$callback_query) | |
| Called every callback query received by the bot. More... | |
| DanySpin97\PhpBotFramework\Bot::processInlineQuery (&$inline_query) | |
| Called every inline query received by the bot. More... | |
| DanySpin97\PhpBotFramework\Bot::processChosenInlineResult (&$chosen_inline_result) | |
| Called every chosen inline result received by the bot. More... | |
| DanySpin97\PhpBotFramework\Bot::processEditedMessage (&$edited_message) | |
| Called every chosen edited message received by the bot. More... | |
| DanySpin97\PhpBotFramework\Bot::getUpdatesRedis (int $limit=100, int $timeout=60, string $offset_key='offset') | |
| Get updates received by the bot, using redis to save and get the last offset. More... | |
| DanySpin97\PhpBotFramework\Bot::getUpdatesLocal (int $limit=100, int $timeout=60) | |
| Get updates received by the bot, and hold the offset in $offset. More... | |
| DanySpin97\PhpBotFramework\Bot::getUpdatesDatabase (int $limit=100, int $timeout=0, string $table_name='telegram', string $column_name='bot_offset') | |
| Get updates received by the bot, using the sql database to store and get the last offset. More... | |
| DanySpin97\PhpBotFramework\Bot::addMessageCommand (string $command, $script) | |
| Add a function that will be executed everytime a message contain the selected command. More... | |
| & | DanySpin97\PhpBotFramework\CoreBot::getChatID () |
| Get chat id of the current user. More... | |
| DanySpin97\PhpBotFramework\CoreBot::setChatID ($chat_id) | |
| Set current chat id. More... | |
Variables | |
| DanySpin97\PhpBotFramework\CoreBot::$chat_id | |
| Chat_id of the user that interacted with the bot. | |
| DanySpin97\PhpBotFramework\Bot::__construct | ( | string | $token | ) |
Construct an empy bot.
Construct a bot with commands, multilanguage and status.
| DanySpin97\PhpBotFramework\Bot::addMessageCommand | ( | string | $command, |
| $script | |||
| ) |
Add a function that will be executed everytime a message contain the selected command.
Use this syntax:
addMessageCommand("start", function($bot, $message) {
$bot->sendMessage("Hi"); });
| $command | The command that will trigger this function (without slash). Eg: "start", "help", "about" |
| $script | The function that will be triggered by a command. Must take an object(the bot) and an array(the message received). |
| & DanySpin97\PhpBotFramework\CoreBot::getChatID | ( | ) |
Get chat id of the current user.
| & DanySpin97\PhpBotFramework\Bot::getData | ( | ) |
Get the data received from the callback query (for updates of type "callback_query").
| & DanySpin97\PhpBotFramework\Bot::getQuery | ( | ) |
Get the query received from the inline query (for updates of type "inline_query").
| & DanySpin97\PhpBotFramework\Bot::getText | ( | ) |
Get the text of the message (for updates of type "message").
| DanySpin97\PhpBotFramework\Bot::getUpdatesDatabase | ( | int | $limit = 100, |
| int | $timeout = 0, |
||
| string | $table_name = 'telegram', |
||
| string | $column_name = 'bot_offset' |
||
| ) |
Get updates received by the bot, using the sql database to store and get the last offset.
It check if an offset exists on redis, then get it, or call getUpdates to set it. Then it start an infinite loop where it process updates and update the offset on redis. Each update is surrounded by a try/catch.
| $limit | Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. |
| $timeout | Optional. Timeout in seconds for long polling. |
| $table_name | Optional. Name of the table where offset is saved in the database |
| $column_name | Optional. Name of the column where the offset is saved in the database |
| DanySpin97\PhpBotFramework\Bot::getUpdatesLocal | ( | int | $limit = 100, |
| int | $timeout = 60 |
||
| ) |
Get updates received by the bot, and hold the offset in $offset.
Get the update_id of the first update to parse, set it in $offset and then it start an infinite loop where it processes updates and keep $offset on the update_id of the last update received. Each processUpdate() method call is surrounded by a try/catch.
| $limit | Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. |
| $timeout | Optional. Timeout in seconds for long polling. |
| DanySpin97\PhpBotFramework\Bot::getUpdatesRedis | ( | int | $limit = 100, |
| int | $timeout = 60, |
||
| string | $offset_key = 'offset' |
||
| ) |
Get updates received by the bot, using redis to save and get the last offset.
It check if an offset exists on redis, then get it, or call getUpdates to set it. Then it start an infinite loop where it process updates and update the offset on redis. Each update is surrounded by a try/catch.
| $limit | Optional. Limits the number of updates to be retrieved. Values between 1—100 are accepted. |
| $timeout | Optional. Timeout in seconds for long polling. |
| $offset_key | Optional. Name of the variable where the offset is saved on Redis |
|
protected |
Called every callback query received by the bot.
Override it to script the bot answer for each callback. $chat_id and $data(use getData() to access it) set inside of this function.
| $callback_query | Reference to the callback query received. |
|
protected |
Called every chosen inline result received by the bot.
Override it to script the bot answer for each chosen inline result. $chat_id set inside of this function.
| $chosen_inline_result | Reference to the chosen inline result received. |
|
protected |
Called every chosen edited message received by the bot.
Override it to script the bot answer for each edited message. $chat_id set inside of this function.
| $edited_message | Reference to the edited message received. |
|
protected |
Called every inline query received by the bot.
Override it to script the bot answer for each inline query. $chat_id and $query(use getQuery() to access it) set inside of this function.
| $inline_query | Reference to the inline query received. |
|
protected |
Called every message received by the bot.
Override it to script the bot answer for each message. $chat_id and $text(use getText to access it) set inside of this function.
| $message | Reference to the message received. |
| DanySpin97\PhpBotFramework\Bot::processWebhookUpdate | ( | ) |
Get update and process it.
Call this method if you are using webhook. It will get update from php::, check it and then process it using processUpdate.
| DanySpin97\PhpBotFramework\CoreBot::setChatID | ( | $chat_id | ) |
Set current chat id.
Change the chat id which the bot execute api methods.
| $chat_id | The new chat id to set. |
1.8.12