{"id":13824706,"url":"https://github.com/ErfanBahramali/Telegram-Bot-PHP","last_synced_at":"2025-07-08T19:32:44.745Z","repository":{"id":56950360,"uuid":"390102517","full_name":"ErfanBahramali/Telegram-Bot-PHP","owner":"ErfanBahramali","description":"Telegram-Bot-PHP is a PHP library for interacting with the official Telegram Bot API","archived":false,"fork":false,"pushed_at":"2021-11-07T10:58:58.000Z","size":220,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-02-16T11:37:33.373Z","etag":null,"topics":["bot","hacktoberfest","hacktoberfest2023","php","psr-4","telegram","telegram-bot","telegram-bot-api","telegram-bot-php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ErfanBahramali.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-27T19:24:53.000Z","updated_at":"2023-12-05T08:59:19.000Z","dependencies_parsed_at":"2022-08-21T03:40:19.489Z","dependency_job_id":null,"html_url":"https://github.com/ErfanBahramali/Telegram-Bot-PHP","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ErfanBahramali/Telegram-Bot-PHP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErfanBahramali%2FTelegram-Bot-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErfanBahramali%2FTelegram-Bot-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErfanBahramali%2FTelegram-Bot-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErfanBahramali%2FTelegram-Bot-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ErfanBahramali","download_url":"https://codeload.github.com/ErfanBahramali/Telegram-Bot-PHP/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErfanBahramali%2FTelegram-Bot-PHP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264334152,"owners_count":23592370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","hacktoberfest","hacktoberfest2023","php","psr-4","telegram","telegram-bot","telegram-bot-api","telegram-bot-php"],"created_at":"2024-08-04T09:01:07.729Z","updated_at":"2025-07-08T19:32:44.428Z","avatar_url":"https://github.com/ErfanBahramali.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Telegram Bot PHP\nTelegram Bot PHP is a PHP Library for interaction with [Telegram Bot API](https://core.telegram.org/bots/api) 5.4 (November 5, 2021).\n\n## Table\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Security](#security)\n- [Config](#config)\n    - [Configs](#configs)\n    - [Logging](#logging)\n        - [onLog](#onlog)\n        - [onLogUpdate](#onlogupdate)\n        - [onLogRequestAndResponse](#onlogrequestandresponse)\n        - [onLogError](#onlogerror)\n    - [Main Config](#main-config)\n    - [Use Config](#use-config)\n    - [Set Config](#set-config)\n- [Update](#update)\n    - [Webhook](#webhook)\n    - [Get Updates](#get-updates)\n- [Methods](#methods)\n    - [Keyboards](#keyboards)\n- [Response](#response)\n    - [Get Response](#get-response)\n    - [Result](#result)\n    - [Example](#example)\n    - [Error](#error)\n    - [Request](#request)\n- [Download File](#download-file)\n- [Helper](#helper)\n- [Format](#format)\n- [Exceptions](#exceptions)\n- [Update Type](#update-type)\n- [Chat Action](#chat-action)\n- [Examples](#examples)\n- [Troubleshooting](#troubleshooting)\n- [About Us](#about-us)\n- [License](#license)\n\n\n## Requirements\n\n**Please read the [Telegram API document](https://core.telegram.org/bots/api) at least once**\n\n* Read [Telegram API document](https://core.telegram.org/bots/api)\n* php \u003e=7.4\n* ext-curl: *\n* ext-json: *\n* ext-mbstring: *\n* ext-openssl: *\n## Installation\nUse composer to require it,\n```\ncomposer require bahramali/telegram-bot-php\n```\n**or**\n\n```\nphp composer.phar require bahramali/telegram-bot-php\n```\n**or**\n\nCreate `composer.json` file and add\n```\n{\n    \"name\": \"\u003cvendor\u003e/\u003cname\u003e\",\n    \"require\": {\n        \"bahramali/telegram-bot-php\": \"*\"\n    }\n}\n```\nand run\n```\ncomposer update\n```\n\n**Note:** If you don't have [Composer](https://getcomposer.org/) you can download it [HERE](https://getcomposer.org/download/).\n\n## Usage\n\nTo use this library, you need to require the Composer Autoloader And create a new object from the bot class\n\n**Please read the [Telegram API document](https://core.telegram.org/bots/api) at least once**\n\n```php\n\nuse TelegramBotPHP\\Bot;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n/**\n * @link https://core.telegram.org/bots/api#authorizing-your-bot\n */\n$bot = new Bot('__BOT_API_TOKEN__');\n```\n## Security\n\n**You can add a specific parameter to your webhook url so that only you know about that link.**\n\n#### Example:\n```\nhttps://example.com/bot?example=1a79a4d60de6718e8e5b326e338ae533\n```\n\n**Then check in your code the parameter that must be present**\n\n```php\nif ($_GET['example'] == '1a79a4d60de6718e8e5b326e338ae533') {\n    // code\n} else {\n    // 404 not found\n}\n```\n\n**Be sure to check that the IP is the sender of the Telegram IP.**\n\n**You can use the 'isTelegramIp' function of 'bot' class to check Telegram IP**\n\n#### Example:\n```php\n\n$ip = $_SERVER['REMOTE_ADDR'];\n\nif (Bot::isTelegramIp($ip)) {\n    // code\n} else {\n    // 404 not found\n}\n```\n## Config\n### Configs\n\n**You can adjust the configuration and change it in each section**\n\nif you are using a local bot api server, Set up your server url\n\n```php\n/**\n * bot api server url\n * @link https://core.telegram.org/bots/api#using-a-local-bot-api-server\n */\npublic string $botApiServerUrl = 'https://api.telegram.org/bot'; // https://example.com/bot{__BOT_API_TOKEN__}/MethodName?parameters=values\n```\n\nif you are using a local bot api server, Set up your server file url, for download file\n\n```php\n/**\n * bot api server file url\n * @link https://core.telegram.org/bots/api#file\n */\npublic string $botApiServerFileUrl = 'https://api.telegram.org/file/bot'; // https://example.com/example/file/bot{__BOT_API_TOKEN__}/{__FILE_PATH__}\n```\n\nConvert updates and response to objects for easier access\n\nAlso you can set the variable to false and receive updates and response as an array\n\n```php\n/**\n * auto convert update and response to class For easier access\n */\npublic bool $convertToObject = true;\n```\n\nIf you don't want to use Webhook automatically, set this variable to false\n\n```php\n/**\n * Use webhook by default\n * if use getUpdates Set this variable to false\n */\npublic bool $autoUseWebhook = true;\n```\nIf you don't want some methods to have some of their parameters automatically, set this variable to false\n\n**Its accuracy is not always guaranteed**\n\n```php\n/**\n * In certain methods, some parameters are filled in automatically\n *\n * For example, in `sendMessage` method,\n\n * You can, not set \"chat_id\",\n\n * And the \"chat_id\" of the sender is considered automatic.\n */\npublic bool $autofillParameters = true;\n```\n\nIf you want the program to continue after the error, set this variable to false\n\n**This is only for when the response code of the submitted request is not equal to 200**\n\n```php\n/**\n * Stop the program when it encounters an error\n */\npublic bool $throwOnError = true;\n```\n### Logging\n\nThis library can log all their update , requests , responses and errors\n\nJust set the function for the desired log\n\n**You can change any of the functions anywhere in the app**\n\nGet the information and you can use any method you want to record it\n\n#### onLog\n\nFor updates , requests , responses and errors\n\nAt the end, the program is called and sends update and a list of all requests and responses and errors as input\n##### Example\n```php\n$config-\u003eonLog = function (array $log) {\n\n    $log = json_encode($log);\n    file_put_contents(__DIR__ . '/Bot.log', \"{$log}\\n\", FILE_APPEND);\n};\n\n```\n#### onLogUpdate\n\nFor update only\n\nWhen the update is received, the function is called\n\n##### Example\n```php\n$config-\u003eonLogUpdate = function (array $update) {\n\n    $logUpdate = json_encode($update);\n    file_put_contents(__DIR__ . '/Bot_update.log', \"{$logUpdate}\\n\", FILE_APPEND);\n};\n\n```\n\n#### onLogRequestAndResponse\n\nFor requests and responses only\n\nWhen a request is sent and the response code is 200\n\n##### Example\n```php\n$config-\u003eonLogRequestAndResponse = function (array $request, array $response) {\n\n    $logRequestAndResponse = [$request, $response];\n    $logRequestAndResponse = json_encode($logRequestAndResponse);\n    file_put_contents(__DIR__ . '/Bot_request_response.log', \"{$logRequestAndResponse}\\n\", FILE_APPEND);\n};\n\n```\n\n#### onLogError\n\nFor errors only\n\nWhen a request is sent and the response code is not 200\n##### Example\n```php\n$config-\u003eonLogError = function (array $error) {\n\n    $logError = json_encode($error);\n    file_put_contents(__DIR__ . '/Bot_error.log', \"{$logError}\\n\", FILE_APPEND);\n};\n\n```\n### Main Config\n\nThe main configuration is constant everywhere in the program And when a new configuration is created, the default value is the value set for the main configuration.\n\nYou can adjust the main configuration and change it in each section\n\n**Note: You can see the default values [above](#configs)**\n\n#### Use\n\nIt should only be used statically\n\n```php\n\nMainConfig::$onLog = function (array $log) {\n\n    $log = json_encode($log);\n    file_put_contents(__DIR__ . '/Bot.log', \"{$log}\\n\", FILE_APPEND);\n};\n\n// MainConfig::.... = ... ;\n```\n### Use Config\n\nJust create an object of config class and change the values\n\n**Note: The default configuration values are the [Main configuration](#main-config) values**\n\n```php\n$config = new Config();\n\n$config-\u003eonLog = function (array $log) {\n\n    $log = json_encode($log);\n    file_put_contents(__DIR__ . '/Bot.log', \"{$log}\\n\", FILE_APPEND);\n};\n\n$config-\u003eonLogUpdate = function ($update) {\n\n    $logUpdate = json_encode($update);\n    file_put_contents(__DIR__ . '/Bot_update.log', \"{$logUpdate}\\n\", FILE_APPEND);\n};\n\n// $config-\u003e ... = ... ;\n```\n### Set\n\nTo use the created configuration, it can be set to the second parameter of the bot class\n\n```php\n$bot = new Bot('__BOT_API_TOKEN__' , $config);\n```\n\nIt can also be changed later if needed\n\n```php\n$config-\u003ethrowOnError = true;\n// or\n$bot-\u003econfig-\u003ethrowOnError = true;\n\n$config-\u003eonLog = function (array $log) {\n\n    $log = json_encode($log);\n    file_put_contents(__DIR__ . '/Bot.log', \"{$log}\\n\", FILE_APPEND);\n};\n\n// $bot-\u003econfig-\u003e... = ...;\n```\n## Update\n\nThere are two ways to receive the update\n\n**There is no difference between camelCase and under_score to get the parameters**\n\n### Webhook\n\nIf you are using a webhook you can get updates using the 'getUpdate' and 'getInput' functions\n\nhttps://core.telegram.org/bots/api#setwebhook\n\n```php\n// Do not confuse this function with the 'getUpdates' method of Telegram, it is 'getupdate'\n$update = $bot-\u003egetUpdate(); // TelegramBotPHP\\Types\\Update Object ([updateId] =\u003e 585985242 [message] =\u003e TelegramBotPHP\\Types\\Message Object ( ... ))\n\n$update = $bot-\u003egetInput(); // Array ([update_id] =\u003e 585985243 [message] =\u003e Array ( ... ))\n```\n\n#### Example\n\n```php\n$update = $bot-\u003egetUpdate(); // TelegramBotPHP\\Types\\Update Object ([updateId] =\u003e 585985242 [message] =\u003e TelegramBotPHP\\Types\\Message Object ( ... ))\n\n$messageId = $update-\u003emessage-\u003emessage_id; // 28236\n// or\n$messageId = $update-\u003emessage-\u003emessageId; // 28236\n\n$text = $update-\u003emessage-\u003etext; // Example Text\n\n// or\n$update = $bot-\u003egetInput(); // Array ([update_id] =\u003e 585985243 [message] =\u003e Array ( ... ))\n\n$messageId = $update['message']['message_id']; // 28236\n\n$text = $update['message']['text']; // Example Text\n\n```\n### Get Updates\n\nReturns an array of update object\n\nhttps://core.telegram.org/bots/api#getupdates\n\n```php\n\n$updates = $bot-\u003egetUpdates()-\u003egetResult();// Array ([0] =\u003e TelegramBotPHP\\Types\\Update Object ( ... ) [1] =\u003e TelegramBotPHP\\Types\\Update Object ( ... ) [2] =\u003e TelegramBotPHP\\Types\\Update Object ( ... ))\n\n```\n\n#### Example:\n\n```php\n$updates = $bot-\u003egetUpdates()-\u003egetResult();// Array ([0] =\u003e TelegramBotPHP\\Types\\Update Object ( ... ) [1] =\u003e TelegramBotPHP\\Types\\Update Object ( ... ) [2] =\u003e TelegramBotPHP\\Types\\Update Object ( ... ))\nforeach ($updates as $key =\u003e $update) {\n\n    $chatId = $update-\u003echat-\u003eid; // 184171927\n    // or you can create helper\n}\n```\n\n## Methods\n\nTo use the methods, all you have to do is type in the name of the method and pass an array of parameters listed in the [Telegram api document](https://core.telegram.org/bots/api#available-methods).\n\n```php\n\n// now you can use all of telegram methods\n\n$bot-\u003emethodName([\n    // parameters\n    'example' =\u003e 'test',\n]);\n```\n#### Example:\n```php\n\n// https://core.telegram.org/bots/api#available-methods\n\n// chat_id is Unique identifier for the target chat or username of the target channel (in the format @channelusername)\n\n// send message\n$bot-\u003esendMessage([\n    'chat_id' =\u003e 184171927,\n    'text' =\u003e 'Example Text',\n]);\n\n// send photo\n$bot-\u003esendPhoto([\n    'chat_id' =\u003e 184171927,\n    'photo' =\u003e new CURLFile('example.png'),\n    'caption' =\u003e 'Example caption',\n]);\n\n// send document\n$bot-\u003esendDocument([\n    'chat_id' =\u003e 184171927,\n    'document' =\u003e new CURLFile('example.zip'),\n    'caption' =\u003e 'Example caption',\n]);\n\n// ...\n// $bot-\u003e...([\n//   ...\n// ]);\n\n```\n\nYou can also use static\n\n#### Example:\n\n```php\n// send message\nBot::sendMessage([\n    'chat_id' =\u003e 184171927,\n    'text' =\u003e 'Example Text',\n]);\n\n// send photo\nBot::sendPhoto([\n    'chat_id' =\u003e 184171927,\n    'photo' =\u003e new CURLFile('example.png'),\n    'caption' =\u003e 'Example caption',\n]);\n\n// send document\nBot::sendDocument([\n    'chat_id' =\u003e 184171927,\n    'document' =\u003e new CURLFile('example.zip'),\n    'caption' =\u003e 'Example caption',\n]);\n\n```\n\nAlso to use different **BOT_API_TOKEN**\n\nYou can in the second parameter of each method, Enter a new **BOT_API_TOKEN**\n\n#### Example:\n\n```php\n// send message\nBot::sendMessage([\n    'chat_id' =\u003e 184171927,\n    'text' =\u003e 'Example Text',\n], '__BOT_API_TOKEN__');\n```\n\n### Keyboards\n\n#### InlineKeyboardMarkup\n\n```php\n// send message\n$bot-\u003esendMessage([\n    'chat_id' =\u003e 184171927,\n    'text' =\u003e 'Example Text',\n    'reply_markup' =\u003e [\n        'inline_keyboard' =\u003e\n        [\n            [['text' =\u003e 'one', 'callback_data' =\u003e 'one'], ['text' =\u003e 'two', 'callback_data' =\u003e 'two']],\n\n            [['text' =\u003e 'three', 'callback_data' =\u003e 'three'], ['text' =\u003e 'four', 'callback_data' =\u003e 'four']],\n\n            [['text' =\u003e 'url', 'url' =\u003e 'https://github.com/ErfanBahramali/Telegram-Bot-PHP']],\n        ]\n    ]\n]);\n```\n\n#### ReplyKeyboardMarkup\n\n```php\n// send message\n$bot-\u003esendMessage([\n    'chat_id' =\u003e 184171927,\n    'text' =\u003e 'Example Text',\n    'reply_markup' =\u003e [\n        'keyboard' =\u003e\n        [\n            [['text' =\u003e 'one'], ['text' =\u003e 'two']],\n\n            [['text' =\u003e 'three'], ['text' =\u003e 'four']],\n\n            [['text' =\u003e 'request contact', 'request_contact' =\u003e true]],\n\n            [['text' =\u003e 'request location', 'request_location' =\u003e true]],\n        ],\n        'resize_keyboard' =\u003e true,\n    ]\n]);\n```\n\n#### ReplyKeyboardRemove\n\n```php\n// send message\n$bot-\u003esendMessage([\n    'chat_id' =\u003e 184171927,\n    'text' =\u003e 'Example Text',\n    'reply_markup' =\u003e [\n        'remove_keyboard' =\u003e true\n    ]\n]);\n```\n\n#### ForceReply\n\n```php\n// send message\n$bot-\u003esendMessage([\n    'chat_id' =\u003e 184171927,\n    'text' =\u003e 'Example Text',\n    'reply_markup' =\u003e [\n        'force_reply' =\u003e true,\n        'input_field_placeholder' =\u003e 'test',\n    ]\n]);\n```\n\n## Response\n\n**There is no difference between camelCase and under_score to get the parameters**\n### Get Response\n\n```php\n$response = $bot-\u003emethodName([\n    // parameters\n    'example' =\u003e 'test',\n]); // (TelegramBotPHP\\Response\\Response Object( .... ))\n\n```\n\n### Result\n\n```php\n// {\n//   \"ok\": true,\n//   \"result\": {\n//     \"message_id\": 28236,\n//     \"from\": {\n//       \"id\": 93372553,\n//       \"is_bot\": true,\n//       \"first_name\": \"BotFather\",\n//       \"username\": \"BotFather\"\n//     },\n//     \"chat\": {\n//       \"id\": 184171927,\n//       \"first_name\": \"Erfan\",\n//       \"type\": \"private\"\n//     },\n//     \"date\": 1627277790,\n//     \"text\": \"Example Text\"\n//   }\n// }\n\n$response-\u003eisOk(); // check response ok is true (true)\n\n$response-\u003egetResult(); // get response Result. The result is not always an object and may be an array and a bool (TelegramBotPHP\\Types\\Message Object([messageId] =\u003e 28236 [from] =\u003e TelegramBotPHP\\Types\\User Object( ... ) [date] =\u003e 1627277790[chat] =\u003e TelegramBotPHP\\Types\\Chat Object( ... )[text] =\u003e Example Text))\n\n$response-\u003egetResponseData(); // get all of response as an array (Array ([ok] =\u003e 1 [result] =\u003e Array ( [message_id] =\u003e 28236 [from] =\u003e Array  ( ... ) [chat] =\u003e Array ( ... ) [date] =\u003e 1627277790 [text] =\u003e Example Text )))\n```\n### Example:\n\n```php\n\n$result = $response-\u003egetResult();// TelegramBotPHP\\Types\\Message Object( ... )\n\n$messageId = $result-\u003emessage_id; // 28236\n$chatId = $result-\u003echat-\u003eid; // 184171927\n$text = $result-\u003etext; // Example Text\n\n// or in array\n$result = $response-\u003egetResponseData(); // Array ( ... )\n$result = $result['result']; // Array ( ... )\n\n$messageId = $result['message_id']; // 28236\n$chatId = $result['chat']['id']; // 184171927\n$text = $result['text']; // Example Text\n```\n\n### Error:\n\n```php\n\n// {\n//   \"ok\": false,\n//   \"error_code\": 400,\n//   \"description\": \"Bad Request: chat not found\"\n// }\n\n$response-\u003egetErrorCode(); // check response error_code (400)\n$response-\u003egetDescription(); // check response description (\"Bad Request: chat not found\")\n```\n### Request:\n```php\n$response-\u003egetRequestMethod(); // get request method name (sendMessage)\n$response-\u003egetRequestParameters(); // get request parameters as an array (['chat_id' =\u003e '184171927', 'text' =\u003e 'Example Text'])\n\n```\n\n# Download File\n\n```php\n\n// downloadFile($filePath, $localFilePath)\n\n// $fileSource = self::$config-\u003ebotApiServerFileUrl . self::$token . '/' . $filePath;\n\n$bot-\u003edownloadFile('documents/example.txt', __DIR__ . '/documents/example.txt');\n\n// $fileSource = self::$config-\u003ebotApiServerFileUrl . self::$token . '/' . 'documents/example.txt';\n\n// or\n\nBot::downloadFile('documents/example.txt', __DIR__ . '/documents/example.txt');\n\n```\n\n### download file by file_id\n\n```php\n\n// downloadFileByFileId($fileId, $localFilePath)\n\n$bot-\u003edownloadFileByFileId('BQACAgQAAxkBAAJ0T2EJUDHTeXGcSBUrqFMgzZCQ0OJGAAIhCQACg2tJUEqm6016cXE9IAQ', __DIR__ . '/documents/example.txt');\n\n// or\n\nBot::downloadFileByFileId('BQACAgQAAxkBAAJ0T2EJUDHTeXGcSBUrqFMgzZCQ0OJGAAIhCQACg2tJUEqm6016cXE9IAQ', __DIR__ . '/documents/example.txt');\n\n```\n\n## Helper\n\nHelpers are auxiliary functions for receiving certain values or checking some items or doing certain tasks\n\n**Note: You can see the full list of functions in the [`Helpers Folder`](https://github.com/ErfanBahramali/Telegram-Bot-PHP/tree/main/src/Helpers)**\n\n\n**There is no difference between camelCase and under_score to get the parameters**\n\n#### Example:\n\n```php\n\n$chatId = $bot-\u003egetHelper()-\u003egetChatId();\n// or\n$chatId = Helper::getChatId();\n// or\n$chatId = $bot-\u003egetUpdate()-\u003emessage-\u003echat-\u003eid;\n\n```\n\nYou can also create a new helper with the input update array\n\n```php\n$helper = new Helper({__Input_Update_Array__});\n\n// Example:\n$helper = new Helper($bot-\u003egetInput());\n```\n\nOf course, the bot builds the helper itself and there is no need to build a helper with its value,\nYou can get the bot helper with 'getHelper'\n\n#### Example:\n\n```php\n$helper = $bot-\u003egetHelper();\n```\n## Format\n\nThe Format class is a class to help create different text formats\n\nhttps://core.telegram.org/bots/api#formatting-options\n\n#### Mention\n\nYou can easily mention users\n\n```php\n$text = Format::mention('184171927','Erfan'); // [Erfan](tg://user?id=184171927)\n```\n\n#### Styles\n\n```php\n// escape markdownV2 style\n$text = Format::markdownV2('');\n\n// escape HTML style\n$text = Format::html('');\n\n// escape markdown style\n$text = Format::markdown('');\n```\n\n#### Example:\n\n```php\n// escape markdownV2 style\n$text = Format::markdownV2('*bold \\*text*'); // \\*bold \\\\\\*text\\*\n\n// escape HTML style\n$text = Format::html('\u003cb\u003ebold\u003c/b\u003e, \u003cstrong\u003ebold\u003c/strong\u003e'); // \u0026amp;lt;b\u0026amp;gt;bold\u0026amp;lt;/b\u0026amp;gt;, \u0026amp;lt;strong\u0026amp;gt;bold\u0026amp;lt;/strong\u0026amp;gt;\n\n// escape markdown style\n$text = Format::markdown('*bold text*'); // \\*bold text\\*\n```\n\n#### Example:\n\n```php\n\n$text = Format::markdownV2('*bold \\*text*');\n\nBot::sendMessage([\n    'chat_id' =\u003e '184171927',\n    'text' =\u003e \"*{$text}*\",\n    'parse_mode' =\u003e ParseMode::MARKDOWNV2,\n]);\n```\n\n## Exceptions\n\nYou can manage errors with [try catch](https://www.php.net/manual/en/language.exceptions.php)\n\n**BotException:** Main exception class used for exception handling\n\n**BotLogException:** exception class used for log\n\n**BotNotSupportException:** exception class Thrown when Feature not support\n\n## Update Type\n\nIf you want to check the type of updates\n\nYou can use helpers\n\n**You can see the full list of 'updateTypeIs...' functions in the [`helper type class`](https://github.com/ErfanBahramali/Telegram-Bot-PHP/blob/main/src/Helpers/Helper.php)**\n\n#### Example:\n\n```php\nif (Helper::updateTypeIsMessage()) {\n    # code...\n} elseif (Helper::updateTypeIsCallbackQuery()) {\n    # code...\n} elseif (Helper::updateTypeIsMyChatMember()) {\n    # code...\n}\n\n// or ...\n// Helper::updateTypeIs...()\n\n```\n\n**Or**\n\nYou can use the 'getUpdateType' helper to get the type of update and then check it using different types of updates\n\n**You can see the full list of update types in the [`update type class`](https://github.com/ErfanBahramali/Telegram-Bot-PHP/blob/main/src/Constants/UpdateType.php)**\n\n#### Example:\n\n```php\n$updateType = Helper::getUpdateType();\n\nif ($updateType === UpdateType::MESSAGE) {\n\n} elseif ($updateType === UpdateType::EDITED_MESSAGE) {\n\n} elseif ($updateType === UpdateType::CALLBACK_QUERY) {\n\n}\n\n```\n\n## Chat Action\n\nYou can use existing chat actions to send chat action\n\n**You can see the full list of chat actions in the chat [`action class`](https://github.com/ErfanBahramali/Telegram-Bot-PHP/blob/main/src/Constants/ChatAction.php)**\n\n#### Example:\n\n```php\nBot::sendChatAction([\n    'chat_id' =\u003e 184171927,\n    'action' =\u003e ChatAction::TYPING,\n]);\n\nBot::sendChatAction([\n    'chat_id' =\u003e 184171927,\n    'action' =\u003e ChatAction::RECORD_VOICE,\n]);\n\nBot::sendChatAction([\n    'chat_id' =\u003e 184171927,\n    'action' =\u003e ChatAction::FIND_LOCATION,\n]);\n\n```\n\n## Examples\n\n* [`parrot`](https://github.com/ErfanBahramali/Telegram-Bot-PHP/blob/main/examples/Parrot/index.php)\n\n## Troubleshooting\n\nplease report any bugs you find on the [issues](https://github.com/ErfanBahramali/Telegram-Bot-PHP/issues) page.\n\n## About Us\n\nThis library can be used for easy interaction with [Telegram Bot API](https://core.telegram.org/bots/api)\n\n## License\n\nTelegram-Bot-PHP is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FErfanBahramali%2FTelegram-Bot-PHP","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FErfanBahramali%2FTelegram-Bot-PHP","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FErfanBahramali%2FTelegram-Bot-PHP/lists"}