PHPackages                             quiec/boting - 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. quiec/boting

ActiveLibrary[API Development](/categories/api)

quiec/boting
============

Simple but powerful and Async(multi-thread) Telegram Bot library

4.0(5y ago)231.4k12MITPHP

Since Jun 23Pushed 5y ago4 watchersCompare

[ Source](https://github.com/yusufusta/Boting)[ Packagist](https://packagist.org/packages/quiec/boting)[ RSS](/packages/quiec-boting/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (2)Versions (8)Used By (0)

Boting
======

[](#boting)

> Simple yet Powerful.

[🇹🇷 Türkçe](https://github.com/Quiec/Boting/blob/master/README-tr.md) | [🇬🇧 English](https://github.com/Quiec/Boting/blob/master/README.md)

[![](https://camo.githubusercontent.com/f6b5208ed90fc45a744a7eaa65af921f5ef9f94c38a2d68de5239840a8b46f65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f71756965632f626f74696e67)](https://camo.githubusercontent.com/f6b5208ed90fc45a744a7eaa65af921f5ef9f94c38a2d68de5239840a8b46f65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f71756965632f626f74696e67) [![](https://camo.githubusercontent.com/9551423d017b23162eae2025aede068401910d347d2fb16dc1268ceff198b82b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f71756965632f626f74696e67)](https://camo.githubusercontent.com/9551423d017b23162eae2025aede068401910d347d2fb16dc1268ceff198b82b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f71756965632f626f74696e67) [![](https://camo.githubusercontent.com/b748c8461d83debd42b1251812703b00d6b03957c509d10924bb1eb53f1a6bce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f71756965632f626f74696e67)](https://camo.githubusercontent.com/b748c8461d83debd42b1251812703b00d6b03957c509d10924bb1eb53f1a6bce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f71756965632f626f74696e67) [![](https://camo.githubusercontent.com/d11c1c371bd5c46c6cb586c96b8e2539a14cfd29b2ea45a7f8c3122b08201de7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f71756965632f626f74696e67)](https://camo.githubusercontent.com/d11c1c371bd5c46c6cb586c96b8e2539a14cfd29b2ea45a7f8c3122b08201de7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f71756965632f626f74696e67)

*Boting*, The best Telegram Bot library for fast and asynchronous bot with PHP.

Features
--------

[](#features)

- %100 Async (😳)
- Always compatible with the latest BotAPI
- Single file, small size, simple to upload.
- File download/upload
- Events
- WebHook &amp; GetUpdates support

Requirements
------------

[](#requirements)

If you can install [Guzzle](http://docs.guzzlephp.org/en/stable/overview.html#requirements), you can use it easily.

Install
-------

[](#install)

If you have [Composer](https://getcomposer.org/download/), you can install it very easily:

```
composer require quiec/boting
```

If you want to use the beta version:

```
composer require quiec/boting:dev-master
```

If Composer is not installed, you can easily install it [Here](https://getcomposer.org/download/).

Get Update
----------

[](#get-update)

You can get Update with two ways;

### Webhook

[](#webhook)

If you are going to receive Updates with Webhook method, just add "true" to the handler.

```
...
$Bot->Handler("Token", true);
```

### Get Updates

[](#get-updates)

This method is used by default. You don't need to add anything extra.

```
...
$Bot->Handler("Token");
```

Events
------

[](#events)

With the new feature added to Boting 2.0, you can now add convenience commands and capture message types with `on`.

### $bot-&gt;command

[](#bot-command)

The command, must be **regex**.

**Example** (**Let's catch /start command**):

```
$Bot->command("/\/start/m", function ($Update, $Match) use ($Bot) {
    $ChatId = $Update["message"]["chat"]["id"];
    $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Started bot."]);
});
```

**Let's add another command handler:**

```
$Bot->command("/[!.\/]start/m", function ($Update, $Match) use ($Bot) {
    $ChatId = $Update["message"]["chat"]["id"];
    $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Started bot."]);
});
```

The bot will now also respond to `/start,!Start,.start` commands.

### $bot-&gt;on

[](#bot-on)

The bot will execute the function if a message of the specified type arrives.

**No match is used, On.**

**Example** (*If the photo comes*):

```
$Bot->on("photo", function ($Update) use ($Bot) {
    $ChatId = $Update["message"]["chat"]["id"];
    $Bot->sendMessage(["chat_id" => $ChatId, "text" => "Photo came"]);
});
```

You can look at the On Types [here](https://core.telegram.org/bots/api#message).

### $bot-&gt;answer

[](#bot-answer)

You can use the answer function to answer `inline_query` or` callback_query`.

**Example** (*Let's answer inline*):

```
$Bot->answer("inline_query", function ($Update) use ($Bot) {
    $Bir = ["type" => "article", "id" => 0, "title" => "test", "input_message_content" => ["message_text" => "This bot created by Boting..."]];
    $Bot->answerInlineQuery(["inline_query_id" => $Update["inline_query"]["id"], "results" => json_encode([$Bir])]);
});
```

### Special Events

[](#special-events)

If you do not want to use ready-made functions, you can define your own function.

❗️Type `true` if you are going to use Webhook or `false` if you will get it with GetUpdates.

```
$Main = function ($Update) {...};
$Bot->Handler("Token", false, $Main);
```

**Example** (*A function that responds to the /start message*):

```
