![]() |
PhpBotFramework
1.0.0
A framework for Telegram Bots' APIs.
|
Bot class to handle updates and commandes. More...
Public Member Functions | |
| __construct (string $token) | |
| Construct an empy bot. More... | |
| __destruct () | |
| Descruct the class. | |
| getQuery () | |
| Get the query received from the inline query (for updates of type "inline_query"). More... | |
| processWebhookUpdate () | |
| Get update and process it. More... | |
| processUpdate (array $update) | |
| Dispatch each update to the right method (processMessage, processCallbackQuery, etc). More... | |
| 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... | |
| getUpdatesLocal (int $limit=100, int $timeout=60) | |
| Get updates received by the bot, and hold the offset in $offset. More... | |
| 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... | |
| addMessageCommand (string $command, callable $script) | |
| Add a function that will be executed everytime a message contain the selected command. More... | |
| addMessageCommandRegex (string $regex_rule, callable $script) | |
| Add a function that will be executed everytime a message contain a command that match the regex. More... | |
| addCallbackCommand (string $data, callable $script) | |
| Add a function that will be executed everytime a callback query contains a string as data. More... | |
| getLanguageDatabase ($default_language='en') | |
| Get current user language from the database, and set it in $language. More... | |
| getLanguageRedis ($default_language='en') | |
| Get current user language from redis, and set it in language. More... | |
| getLanguageRedisAsCache ($default_language='en', $expiring_time='86400') | |
| Get current user language from redis, as a cache, and set it in language. More... | |
| setLanguageRedisAsCache ($language, $expiring_time='86400') | |
| Set the current user language in both redis, sql database and $language. More... | |
| loadLocalization ($dir='./localization') | |
| Load localization files (JSON-serialized) from a folder and set them in $local variable. More... | |
| getStatus ($default_status=-1) | |
| Get current user status from redis and set it in status variable. More... | |
| setStatus ($status) | |
| Set the status of the bot in both redis and $status. More... | |
| addUser ($chat_id) | |
| Add a user to the database. More... | |
| broadcastMessage ($text, string $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=true, bool $disable_notification=false) | |
| Broadcast a message to all user registred on the database. More... | |
Public Member Functions inherited from DanySpin97\PhpBotFramework\CoreBot | |
| __construct (string $token) | |
| Contrusct an empty bot. More... | |
| __destruct () | |
| Destroy the object. | |
| getChatID () | |
| Get chat id of the current user. More... | |
| setChatID ($chat_id) | |
| Set current chat id. More... | |
| 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... | |
| forwardMessage ($from_chat_id, int $message_id, bool $disable_notification=false) | |
| Forward a message. More... | |
| sendPhoto ($photo, string $reply_markup=null, string $caption='', bool $disable_notification=false) | |
| Send a photo. More... | |
| 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... | |
| sendDocument ($document, string $caption='', string $reply_markup=null, bool $disable_notification=false, int $reply_to_message_id=null) | |
| Send a document. More... | |
| sendSticker ($sticker, string $reply_markup=null, bool $disable_notification=false, int $reply_to_message_id=null) | |
| Send a sticker. More... | |
| sendVoice ($voice, string $caption, int $duration, string $reply_markup=null, bool $disable_notification, int $reply_to_message_id=0) | |
| Send audio files. More... | |
| sendChatAction (string $action) | |
| Say the user what action is the bot doing. More... | |
| getChat ($chat_id) | |
| Get info about a chat. More... | |
| answerCallbackQuery ($text='', $show_alert=false, string $url='') | |
| editMessageText (int $message_id, $text, $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=false) | |
| Edit text of a message sent by the bot. More... | |
| editInlineMessageText (string $inline_message_id, $text, string $reply_markup=null, string $parse_mode='HTML', bool $disable_web_preview=false) | |
| Edit text of a message sent via the bot. More... | |
| editMessageReplyMarkup ($message_id, $inline_keyboard) | |
| answerInlineQuerySwitchPM ($results, $switch_pm_text, $switch_pm_parameter='', $is_personal=true, $cache_time=300) | |
| answerEmptyInlineQuerySwitchPM ($switch_pm_text, $switch_pm_parameter='', $is_personal=true, $cache_time=300) | |
| apiRequest (string $method, array $parameters) | |
| Exec any api request using this method. More... | |
Public Attributes | |
| $inline_keyboard | |
| Store the inline keyboard. | |
| $pdo | |
| Pdo reference. | |
| $redis | |
| Redis connection. | |
| $language | |
| Store the language for a multi-language bot. | |
| $local | |
| Store localization data. | |
| $user_table = '"User"' | |
| Table contaning bot users data in the sql database. | |
| $id_column = 'chat_id' | |
| Name of the column that represents the user id in the sql database. | |
| $status | |
| Status of the bot to handle data inserting and menu-like bot. | |
Public Attributes inherited from DanySpin97\PhpBotFramework\CoreBot | |
| $ch | |
| Curl connection for request. | |
Protected Member Functions | |
| processMessage ($message) | |
| Called every message received by the bot. More... | |
| processCallbackQuery ($callback_query) | |
| Called every callback query received by the bot. More... | |
| processInlineQuery ($inline_query) | |
| Called every inline query received by the bot. More... | |
| processChosenInlineResult ($chosen_inline_result) | |
| Called every chosen inline result received by the bot. More... | |
| processEditedMessage ($edited_message) | |
| Called every chosen edited message received by the bot. More... | |
| processChannelPost ($post) | |
| Called every new post in the channel where the bot is in. More... | |
| processEditedChannelPost ($edited_post) | |
| Called every time a post get edited in the channel where the bot is in. More... | |
Protected Member Functions inherited from DanySpin97\PhpBotFramework\CoreBot | |
| getUpdates (int $offset=0, int $limit=100, int $timeout=60) | |
| Request bot updates. More... | |
| exec_curl_request ($url) | |
| Core function to execute url request. More... | |
Additional Inherited Members | |
Protected Attributes inherited from DanySpin97\PhpBotFramework\CoreBot | |
| $chat_id | |
| Chat_id of the user that interacted with the bot. | |
| $api_url | |
| Url request (containing $token). | |
Bot class to handle updates and commandes.
Class Bot to handle task like api request, or more specific api function(sendMessage, editMessageText, etc). Usage example in webhook.php
1.8.12