{"id":13609724,"url":"https://github.com/smoqadam/php-telegram-bot","last_synced_at":"2025-07-31T11:36:35.701Z","repository":{"id":34409195,"uuid":"38339038","full_name":"smoqadam/php-telegram-bot","owner":"smoqadam","description":"a wrapper class for telegram bot api","archived":false,"fork":false,"pushed_at":"2017-10-11T07:38:18.000Z","size":44,"stargazers_count":21,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T15:06:16.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/smoqadam.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":"2015-06-30T23:50:56.000Z","updated_at":"2024-12-27T22:46:09.000Z","dependencies_parsed_at":"2022-09-11T22:40:31.175Z","dependency_job_id":null,"html_url":"https://github.com/smoqadam/php-telegram-bot","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/smoqadam/php-telegram-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoqadam%2Fphp-telegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoqadam%2Fphp-telegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoqadam%2Fphp-telegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoqadam%2Fphp-telegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smoqadam","download_url":"https://codeload.github.com/smoqadam/php-telegram-bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoqadam%2Fphp-telegram-bot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268031101,"owners_count":24184444,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-01T19:01:37.445Z","updated_at":"2025-07-31T11:36:35.637Z","avatar_url":"https://github.com/smoqadam.png","language":"PHP","readme":"[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/smoqadam/php-telegram-bot/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/smoqadam/php-telegram-bot/?branch=master)\n[![Codacy Badge](https://www.codacy.com/project/badge/7008dc0d211c4bba95e5b31537702050)](https://www.codacy.com/app/phpro-ir/php-telegram-bot)\n# php-telegram-bot\nA wrapper class for Telegram Bot API\n\n## Install\ncreate composer.json :\n```\n{\n    \"require\": {\n        \"smoqadam/php-telegram-bot\": \"v1.0\"\n    }\n}\n```\n\n`$ composer install`\n\n## How to use:\n`Smoqadam\\Telegram` is a wrapper around Telegram bot API. After you instantiate `Telegram` object, you can register callbacks on the updates you receive and then respond accordingly.\n\n**Register callbacks:** Use following functions:\n-  `cmd()`, all normal messages\n-  `inlineQuery()`\n\n\n**API Methods:**\nThe available methods are almost same of official Telegram API (for now the wrapper does not natively handles games and messages update):\n-   `sendMessage()`, `getMe()`, `forwardMessage()`, `sendPhoto()`, `sendVideo()`, `sendSticker()`, `sendLocation()`, `sendDocument()`, `sendAudio()`, `sendChatAction()`, `getUserProfilePhotos()`, `answerInlineQuery()`\n\n**Getting current update:**\nThe current update is stored in the property `Telegram::result` (that is an object).\n\n**Inline Result helper:**\nTo facilitate the creation of Inline Bot there are some helper classes under namespace `InlineQuery\\Result`:\n-   `Article`\n\n**Keyboards helper:**\nAlso the same with keyboards; namespace is `Keyboard`:\n-   `Standard`, classic keyboard\n-   `Remove`, remove custom keyboard and show letter-keyboard\n-   `Inline`, inline keyboard\n\n**Use Keyboard:**\nUse the keyboard is pretty simple with helpers, after you instantiate keyboard (`Standard` or `Inline`) you use:\n-  `addButton()`\n-  `addRow()`\n\n_Note:_ These methods are chainable.\n\n## Example\n**Using long polling:**\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse Smoqadam\\Telegram;\n\n$tg = new Telegram('API_TOKEN');\n\n$tg-\u003ecmd('\\/name:\u003c\u003c[a-zA-Z]{0,}\u003e\u003e', function ($args) use ($tg){\n\t$tg-\u003esendMessage(\"my username is @\".$args , $tg-\u003egetChatId());\n});\n\n\n$tg-\u003ecmd('\\/number: \u003c\u003c:num\u003e\u003e' , function($args) use($tg){\n\t$tg-\u003esendMessage(\"your number is : \".$args , $tg-\u003egetChatId());\n});\n\n\n$tg-\u003ecmd('Hello',function () use ($tg){\n\t$tg-\u003esendChatAction(Telegram::ACTION_TYPING);\n\t$image = 'urltoqrcode.png';\n\t$tg-\u003esendPhoto($image);\n});\n\n$tg-\u003erun();\n\n```\n\n\n**Using webHooks:**\n\nIf you want to use webhooks you have to first call `setWebhook` method or open the following URL with your own data:\n\n`https://api.telegram.org/API_TOKEN/setWebhook?url=https://yourdomain.com/index.php`\n\u003eplease change API_TOKEN and url parameter\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\n$message = file_get_contents('php://input');\n\nuse Smoqadam\\Telegram;\n\n$tg = new Telegram('API_TOKEN');\n\n$tg-\u003ecmd('\\/name:\u003c\u003c[a-zA-Z]{0,}\u003e\u003e', function ($args) use ($tg){\n\t\t$tg-\u003esendMessage(\"my username is @\".$args , $tg-\u003egetChatId());\n});\n\n\n$tg-\u003ecmd('\\/number: \u003c\u003c:num\u003e\u003e' , function($args) use($tg){\n\t$tg-\u003esendMessage(\"your number is : \".$args , $tg-\u003egetChatId());\n});\n\n\n$tg-\u003ecmd('Hello',function () use ($tg){\n\t$tg-\u003esendChatAction(Telegram::ACTION_TYPING);\n\t$image = 'urltoqrcode.png';\n\t$tg-\u003esendPhoto($image);\n});\n\n$tg-\u003eprocess(json_decode($message, true));\n\n```\nNow when you send `/number 123` in telegram bot page , bot will answer to you `your number is 123`\n\nYou can set argument in regex between \u003c\u003c and \u003e\u003e\n\n## Running bot\n`$ php index.php`\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoqadam%2Fphp-telegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoqadam%2Fphp-telegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoqadam%2Fphp-telegram-bot/lists"}