PHPackages                             pochepochka/telegram-bot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. pochepochka/telegram-bot

ActiveLibrary[API Development](/categories/api)

pochepochka/telegram-bot
========================

PHP Telegram bot

0.63.1(5y ago)068MITPHPPHP ^5.5|^7.0

Since Jun 26Pushed 5y agoCompare

[ Source](https://github.com/pochepochka/core)[ Packagist](https://packagist.org/packages/pochepochka/telegram-bot)[ Docs](https://github.com/php-telegram-bot/core)[ RSS](/packages/pochepochka-telegram-bot/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (81)Used By (0)

 PHP Telegram Bot

 [![PHP Telegram Bot logo](https://raw.githubusercontent.com/php-telegram-bot/assets/master/logo/512px/logo_plain.png "PHP Telegram Bot")](https://raw.githubusercontent.com/php-telegram-bot/assets/master/logo/512px/logo_plain.png)

============================================================================================================================================================================================================================================================

[](#----php-telegram-bot----)

A Telegram Bot based on the official [Telegram Bot API](https://core.telegram.org/bots/api "Telegram Bot API")

[![API Version](https://camo.githubusercontent.com/723d8da4b694e895122da29975fa5953adcb4bf90eff44e59a1ce7f8e4936bf5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f426f742532304150492d342e392532302532384a756e65253230323032302532392d3332613264612e737667)](https://core.telegram.org/bots/api#june-4-2020)[![Join the bot support group on Telegram](https://camo.githubusercontent.com/471c1499869f264b2640d365d2b92f8f0461afb6d9eef50960e862b37c08b93f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74656c656772616d2d405048505f5f54656c656772616d5f5f426f745f5f537570706f72742d3634363539642e737667)](https://telegram.me/PHP_Telegram_Bot_Support)[![Donate](https://camo.githubusercontent.com/e529dd950cc97c0a203bb51d44eb58499d67bb2a4e7dde44b6a895254abe3fec/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2546302539462539322539392d446f6e617465253230253246253230537570706f727425323055732d626c75652e737667)](#donate)

[![Build Status](https://camo.githubusercontent.com/3e073012c5712d355139ddc4ea95f6560e0119623f6ce0f4e266f1340cc6e963/68747470733a2f2f7472617669732d63692e6f72672f7068702d74656c656772616d2d626f742f636f72652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-telegram-bot/core)[![Code Coverage](https://camo.githubusercontent.com/a5485a616d70b8b99c67fe86ab798c63de0c0c4a010ee9856f974b47203ce2a2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7068702d74656c656772616d2d626f742f636f72652f6d61737465722e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/php-telegram-bot/core/?b=master)[![Code Quality](https://camo.githubusercontent.com/ef5eb7391f890c02920f14904072f6582d74e859356e8e22965d3ae554e3a6a6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7068702d74656c656772616d2d626f742f636f72652f6d61737465722e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/php-telegram-bot/core/?b=master)[![Latest Stable Version](https://camo.githubusercontent.com/b3d7db2a7b2f0351e9a1f8444fbe9228063860a9b88d355404f46dd4bc38c92e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f6e676d616e2f74656c656772616d2d626f742e737667)](https://packagist.org/packages/longman/telegram-bot)[![Dependencies](https://camo.githubusercontent.com/c18997f20ab9e6a98e61224314759dfe37eb6823f328a7b7b965319b8f495731/68747470733a2f2f746964656c6966742e636f6d2f6261646765732f6769746875622f7068702d74656c656772616d2d626f742f636f72653f7374796c653d666c6174)](https://tidelift.com/subscription/pkg/packagist-longman-telegram-bot?utm_source=packagist-longman-telegram-bot&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Learn more about the Tidelift Subscription")[![Total Downloads](https://camo.githubusercontent.com/b65ad1c4cc323e9b0c24955112fe0b4210526abba4ed30ab1a29d29deacaad9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f6e676d616e2f74656c656772616d2d626f742e737667)](https://packagist.org/packages/longman/telegram-bot)[![Downloads Month](https://camo.githubusercontent.com/f65f9987e2bb11356c941e8ddd89a12d42503d02cb8fcea0078adb7b174f7f45/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6c6f6e676d616e2f74656c656772616d2d626f742e737667)](https://packagist.org/packages/longman/telegram-bot)[![Minimum PHP Version](https://camo.githubusercontent.com/3c66b413733fe72f056485e12551cfa626a3acd96d9d7e441ca52dbc3a39646a/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344352e362d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/aad9aebce7ea1c1ec50fb209f26b9a9fc1fd27944a512546ed9fbcee4cec682c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6f6e676d616e2f74656c656772616d2d626f742e737667)](https://github.com/php-telegram-bot/core/LICENSE)

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Instructions](#instructions)
    - [Create your first bot](#create-your-first-bot)
    - [Require this package with Composer](#require-this-package-with-composer)
    - [Choose how to retrieve Telegram updates](#choose-how-to-retrieve-telegram-updates)
- [Webhook installation](#webhook-installation)
    - [Self Signed Certificate](#self-signed-certificate)
    - [Unset Webhook](#unset-webhook)
- [getUpdates installation](#getupdates-installation)
    - [getUpdates without database](#getupdates-without-database)
- [Support](#support)
    - [Types](#types)
    - [Inline Query](#inline-query)
    - [Methods](#methods)
    - [Send Message](#send-message)
    - [Send Photo](#send-photo)
    - [Send Chat Action](#send-chat-action)
    - [getUserProfilePhoto](#getuserprofilephoto)
    - [getFile and downloadFile](#getfile-and-downloadfile)
    - [Send message to all active chats](#send-message-to-all-active-chats)
    - [Filter Update](#filter-update)
- [Utils](#utils)
    - [MySQL storage (Recommended)](#mysql-storage-recommended)
        - [External Database connection](#external-database-connection)
    - [Channels Support](#channels-support)
- [Commands](#commands)
    - [Predefined Commands](#predefined-commands)
    - [Custom Commands](#custom-commands)
    - [Commands Configuration](#commands-configuration)
    - [Admin Commands](#admin-commands)
        - [Set Admins](#set-admins)
        - [Channel Administration](#channel-administration)
- [Upload and Download directory path](#upload-and-download-directory-path)
- [Logging](doc/01-utils.md)
- [Documentation](#documentation)
- [Assets](#assets)
- [Example bot](#example-bot)
- [Projects with this library](#projects-with-this-library)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [Security](#security)
- [Donate](#donate)
- [For enterprise](#for-enterprise)
- [License](#license)
- [Credits](#credits)

Introduction
------------

[](#introduction)

This is a pure PHP Telegram Bot, fully extensible via plugins.

Telegram announced official support for a [Bot API](https://telegram.org/blog/bot-revolution), allowing integrators of all sorts to bring automated interactions to the mobile platform. This Bot aims to provide a platform where one can simply write a bot and have interactions in a matter of minutes.

The Bot can:

- Retrieve updates with [webhook](#webhook-installation) and [getUpdates](#getupdates-installation) methods.
- Supports all types and methods according to Telegram Bot API 4.9 (June 2020).
- Supports supergroups.
- Handle commands in chat with other bots.
- Manage Channel from the bot admin interface.
- Full support for **inline bots**.
- Inline keyboard.
- Messages, InlineQuery and ChosenInlineQuery are stored in the Database.
- Conversation feature.

---

This code is available on [GitHub](https://github.com/php-telegram-bot/core). Pull requests are welcome.

Instructions
------------

[](#instructions)

### Create your first bot

[](#create-your-first-bot)

1. Message [`@BotFather`](https://telegram.me/BotFather) with the following text: `/newbot`

    If you don't know how to message by username, click the search field on your Telegram app and type `@BotFather`, where you should be able to initiate a conversation. Be careful not to send it to the wrong contact, because some users have similar usernames to `BotFather`.

    [![BotFather initial conversation](https://user-images.githubusercontent.com/9423417/60736229-bc2aeb80-9f45-11e9-8d35-5b53145347bc.png)](https://user-images.githubusercontent.com/9423417/60736229-bc2aeb80-9f45-11e9-8d35-5b53145347bc.png)
2. `@BotFather` replies with:

    ```
    Alright, a new bot. How are we going to call it? Please choose a name for your bot.

    ```
3. Type whatever name you want for your bot.
4. `@BotFather` replies with:

    ```
    Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.

    ```
5. Type whatever username you want for your bot, minimum 5 characters, and must end with `bot`. For example: `telesample_bot`
6. `@BotFather` replies with:

    ```
    Done! Congratulations on your new bot. You will find it at
    telegram.me/telesample_bot. You can now add a description, about
    section and profile picture for your bot, see /help for a list of
    commands.

    Use this token to access the HTTP API:
    123456789:AAG90e14-0f8-40183D-18491dDE

    For a description of the Bot API, see this page:
    https://core.telegram.org/bots/api

    ```
7. Note down the 'token' mentioned above.

*Optionally set the bot privacy:*

1. Send `/setprivacy` to `@BotFather`.

    [![BotFather later conversation](https://user-images.githubusercontent.com/9423417/60736340-26439080-9f46-11e9-970f-8f33bbe39c5f.png)](https://user-images.githubusercontent.com/9423417/60736340-26439080-9f46-11e9-970f-8f33bbe39c5f.png)
2. `@BotFather` replies with:

    ```
    Choose a bot to change group messages settings.

    ```
3. Type (or select) `@telesample_bot` (change to the username you set at step 5 above, but start it with `@`)
4. `@BotFather` replies with:

    ```
    'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username.
    'Disable' - your bot will receive all messages that people send to groups.
    Current status is: ENABLED

    ```
5. Type (or select) `Disable` to let your bot receive all messages sent to a group.
6. `@BotFather` replies with:

    ```
    Success! The new status is: DISABLED. /help

    ```

### Require this package with Composer

[](#require-this-package-with-composer)

Install this package through [Composer](https://getcomposer.org/ "Composer"). Edit your project's `composer.json` file to require `longman/telegram-bot`.

Create *composer.json* file

```
{
    "name": "yourproject/yourproject",
    "type": "project",
    "require": {
        "php": ">=5.5",
        "longman/telegram-bot": "*"
    }
}
```

and run `composer update`

**or**

run this command in your command line:

```
composer require longman/telegram-bot
```

### Choose how to retrieve Telegram updates

[](#choose-how-to-retrieve-telegram-updates)

The bot can handle updates with [**Webhook**](#webhook-installation) or [**getUpdates**](#getupdates-installation) method:

WebhookgetUpdatesDescriptionTelegram sends the updates directly to your hostYou have to fetch Telegram updates manuallyHost with httpsRequiredNot requiredMySQLNot required([Not](#getupdates-without-database)) RequiredWebhook installation
--------------------

[](#webhook-installation)

Note: For a more detailed explanation, head over to the [example-bot repository](https://github.com/php-telegram-bot/example-bot "Example Bot repository") and follow the instructions there.

In order to set a [Webhook](https://core.telegram.org/bots/api#setwebhook "Webhook on Telegram Bot API") you need a server with HTTPS and composer support. (For a [self signed certificate](#self-signed-certificate) you need to add some extra code)

Create [*set.php*](https://github.com/php-telegram-bot/example-bot/blob/master/set.php "example set.php") with the following contents:

```
