{"id":24206502,"url":"https://github.com/olaviinha/php-telegram-bot","last_synced_at":"2025-06-11T14:35:51.543Z","repository":{"id":87557723,"uuid":"584104248","full_name":"olaviinha/PHP-Telegram-Bot","owner":"olaviinha","description":"Regular PHP Telegram bot","archived":false,"fork":false,"pushed_at":"2024-09-06T04:48:38.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T14:13:13.538Z","etag":null,"topics":["bot","telegram","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olaviinha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-01T11:35:32.000Z","updated_at":"2024-09-06T04:48:41.000Z","dependencies_parsed_at":"2024-06-26T20:43:51.725Z","dependency_job_id":null,"html_url":"https://github.com/olaviinha/PHP-Telegram-Bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaviinha%2FPHP-Telegram-Bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaviinha%2FPHP-Telegram-Bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaviinha%2FPHP-Telegram-Bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaviinha%2FPHP-Telegram-Bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olaviinha","download_url":"https://codeload.github.com/olaviinha/PHP-Telegram-Bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaviinha%2FPHP-Telegram-Bot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259280660,"owners_count":22833434,"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","telegram","telegram-bot"],"created_at":"2025-01-14T00:33:46.178Z","updated_at":"2025-06-11T14:35:51.522Z","avatar_url":"https://github.com/olaviinha.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Telegram Bot\n\n## Minimal bot example\n\n[minimal_tg_bot_example.php](https://github.com/olaviinha/PHP-Telegram-Bot/blob/main/minimal_tg_bot_example.php) is a fully functional Telegram bot written in PHP with a single example command. Leaving it here solely because a file like this would have helped me when I started to make a bot from scratch, so hopefully it will help someone else. To make the file function as a bot in Telegram, see [Setup](#setup).\n\n## Regular bot example\n\nThe rest of the files in this repository represent a fully functional, rationally structured bot written in PHP, with a few minimal example commands. Note that this bot uses flat files (in `logs/` dir) instead of a database for all features that require logging or saving data of any kind.\n\n- All the important settings and commands are listed neatly in `index.php`.\n- Code of each command (when needed) is listed  in, and included from, `commands/` dir.\n- `sys_gpt.php` contains the _necessities_ to utilize GPT3 or GPT4 (chatGPT). I think it currently does not contain e.g. remembering past convos – will add that later.\n- `sys_global_functions.php` contains all the necessary PHP functions.\n- Localization can be found in `sys_locale.php` – it is perhaps not the best way to do localization out there, but it works as long as your bot has one main language.\n\n## Setup\n\nWhether you use just `minimal_tg_bot_example.php` or the whole repository, you must setup your bot as follows:\n\n1. Create a new bot in Telegram using [@BotFather](https://t.me/BotFather) (Telegram's own official bot for that purpose).\n2. @BotFather will provide you a token. Place token in the PHP file.\n3. Place PHP file on a public server.\n4. Set write permission to `logs` dir (i.e. `chown -R www-data:www-data logs`) if you want to enable features and commands that require any kind of logging.\n5. In the URL below, replace `{my_bot_token}` with your token, `{url_to_this_PHP_file}` with the URL to the PHP file located on your server (index.php or minimal_tg_bot_example.php from this repo) and just open the full URL in your browser:\n```\nhttps://api.telegram.org/bot{my_bot_token}/setWebhook?url={url_to_this_PHP_file}/\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaviinha%2Fphp-telegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folaviinha%2Fphp-telegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaviinha%2Fphp-telegram-bot/lists"}