README.md 23.3 KB
Newer Older
LONGMAN's avatar
LONGMAN committed
1 2
# PHP Telegram Bot

3
[![Join the bot support group on Telegram](https://img.shields.io/badge/telegram-@PHP__Telegram__Bot__Support-32a2da.svg)](https://telegram.me/PHP_Telegram_Bot_Support)
4
[![Donate](https://img.shields.io/badge/%F0%9F%92%99-Donate-blue.svg)](#donate)
LONGMAN's avatar
LONGMAN committed
5

6
[![Build Status](https://travis-ci.org/php-telegram-bot/core.svg?branch=master)](https://travis-ci.org/php-telegram-bot/core)
7
[![Dependencies](https://tidelift.com/badges/github/php-telegram-bot/core)][Tidelift]
8 9
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-telegram-bot/core/develop.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-telegram-bot/core/?b=develop)
[![Code Quality](https://img.shields.io/scrutinizer/g/php-telegram-bot/core/develop.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-telegram-bot/core/?b=develop)
10
[![Latest Stable Version](https://img.shields.io/packagist/v/Longman/telegram-bot.svg)](https://packagist.org/packages/longman/telegram-bot)
LONGMAN's avatar
LONGMAN committed
11 12
[![Total Downloads](https://img.shields.io/packagist/dt/Longman/telegram-bot.svg)](https://packagist.org/packages/longman/telegram-bot)
[![Downloads Month](https://img.shields.io/packagist/dm/Longman/telegram-bot.svg)](https://packagist.org/packages/longman/telegram-bot)
13
[![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D5.6-8892BF.svg)](https://php.net/)
14
[![License](https://img.shields.io/packagist/l/longman/telegram-bot.svg)](https://github.com/php-telegram-bot/core/LICENSE)
LONGMAN's avatar
LONGMAN committed
15

16
![Telegram Bot API Logo](assets/logo/512px/logo_plain.png)
LONGMAN's avatar
LONGMAN committed
17

18
A Telegram Bot based on the official [Telegram Bot API][Telegram-Bot-API]
LONGMAN's avatar
LONGMAN committed
19

20 21 22 23 24 25 26 27 28
## 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)
29
    - [getUpdates installation](#getupdates-installation)
30 31 32 33 34 35 36 37
- [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)
Alexey Shishkov's avatar
Alexey Shishkov committed
38
    - [getFile and downloadFile](#getfile-and-downloadfile)
39 40 41 42 43 44 45 46 47 48 49 50
    - [Send message to all active chats](#send-message-to-all-active-chats)
- [Utils](#utils)
    - [MySQL storage (Recommended)](#mysql-storage-recommended)
    - [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)
MBoretto's avatar
MBoretto committed
51
- [Logging](doc/01-utils.md)
52
- [Documentation](#documentation)
53
- [Example bot](#example-bot)
54 55 56
- [Projects with this library](#projects-with-this-library)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
57
- [Security](#security)
58
- [Donate](#donate)
59 60 61 62 63 64 65
- [License](#license)
- [Credits](#credits)





LONGMAN's avatar
LONGMAN committed
66

67 68 69
## Introduction

This is a pure PHP Telegram Bot, fully extensible via plugins.
MBoretto's avatar
MBoretto committed
70 71 72
Telegram recently 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
73
Bot aims to provide a platform where one can simply write a plugin
MBoretto's avatar
MBoretto committed
74
and have interactions in a matter of minutes.
75

76
The Bot can:
77
- retrieve updates with webhook and getUpdates methods.
MBoretto's avatar
MBoretto committed
78
- supports all types and methods according to Telegram API (25 May 2016).
MBoretto's avatar
MBoretto committed
79
- supports supergroups.
MBoretto's avatar
MBoretto committed
80
- handle commands in chat with other bots.
81
- manage Channel from the bot admin interface.
82
- full support for **inline bots**.
MBoretto's avatar
MBoretto committed
83
- inline keyboard.
84
- Messages, InlineQuery and ChosenInlineQuery are stored in the Database.
85
- Conversation feature
86 87 88

-----
This code is available on
89
[Github](https://github.com/php-telegram-bot/core). Pull requests are welcome.
LONGMAN's avatar
LONGMAN committed
90

MBoretto's avatar
MBoretto committed
91
## Instructions
92

MBoretto's avatar
MBoretto committed
93
### Create your first bot
LONGMAN's avatar
LONGMAN committed
94

MBoretto's avatar
MBoretto committed
95 96 97
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
98
field on your Telegram app and type `@botfather`, where you should be able
MBoretto's avatar
MBoretto committed
99 100
to initiate a conversation. Be careful not to send it to the wrong
contact, because some users has similar usernames to `botfather`.
LONGMAN's avatar
LONGMAN committed
101

LONGMAN's avatar
LONGMAN committed
102
   ![botfather initial conversation](http://i.imgur.com/aI26ixR.png)
LONGMAN's avatar
LONGMAN committed
103

MBoretto's avatar
MBoretto committed
104 105
2. @botfather replies with `Alright, a new bot. How are we going to
call it? Please choose a name for your bot.`
LONGMAN's avatar
LONGMAN committed
106 107 108

3. Type whatever name you want for your bot.

109
4. @botfather replies with ```Good. Now let's choose a username for your
MBoretto's avatar
MBoretto committed
110
bot. It must end in `bot`. Like this, for example: TetrisBot or
111
tetris_bot.```
LONGMAN's avatar
LONGMAN committed
112

MBoretto's avatar
MBoretto committed
113 114
5. Type whatever username you want for your bot, minimum 5 characters,
and must end with `bot`. For example: `telesample_bot`
LONGMAN's avatar
LONGMAN committed
115 116 117

6. @botfather replies with:

118
    ```
MBoretto's avatar
MBoretto committed
119
    Done! Congratulations on your new bot. You will find it at
120 121 122
    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.
LONGMAN's avatar
LONGMAN committed
123 124

    Use this token to access the HTTP API:
125
    123456789:AAG90e14-0f8-40183D-18491dDE
LONGMAN's avatar
LONGMAN committed
126

MBoretto's avatar
MBoretto committed
127
    For a description of the Bot API, see this page:
128 129
    https://core.telegram.org/bots/api
    ```
LONGMAN's avatar
LONGMAN committed
130 131 132 133 134

7. Note down the 'token' mentioned above.

8. Type `/setprivacy` to @botfather.

LONGMAN's avatar
LONGMAN committed
135
   ![botfather later conversation](http://i.imgur.com/tWDVvh4.png)
LONGMAN's avatar
LONGMAN committed
136 137 138

9. @botfather replies with `Choose a bot to change group messages settings.`

139
10. Type (or select) `@telesample_bot` (change to the username you set at step 5
MBoretto's avatar
MBoretto committed
140
above, but start it with `@`)
LONGMAN's avatar
LONGMAN committed
141 142 143

11. @botfather replies with

144 145
    ```
    'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username.
LONGMAN's avatar
LONGMAN committed
146 147
    'Disable' - your bot will receive all messages that people send to groups.
    Current status is: ENABLED
148
    ```
LONGMAN's avatar
LONGMAN committed
149

150
12. Type (or select) `Disable` to let your bot receive all messages sent to a
MBoretto's avatar
MBoretto committed
151
group. This step is up to you actually.
LONGMAN's avatar
LONGMAN committed
152 153 154

13. @botfather replies with `Success! The new status is: DISABLED. /help`

MBoretto's avatar
MBoretto committed
155
### Require this package with Composer
156

157 158
Install this package through [Composer][composer].
Edit your project's `composer.json` file to require `longman/telegram-bot`.
LONGMAN's avatar
LONGMAN committed
159

160
Create *composer.json* file
161
```json
LONGMAN's avatar
LONGMAN committed
162 163 164 165
{
    "name": "yourproject/yourproject",
    "type": "project",
    "require": {
166
        "php": ">=5.5",
LONGMAN's avatar
LONGMAN committed
167 168 169 170
        "longman/telegram-bot": "*"
    }
}
```
171
and run `composer update`
LONGMAN's avatar
LONGMAN committed
172

173 174 175
**or**

run this command in your command line:
LONGMAN's avatar
LONGMAN committed
176

177
```bash
LONGMAN's avatar
LONGMAN committed
178 179
composer require longman/telegram-bot
```
LONGMAN's avatar
LONGMAN committed
180

MBoretto's avatar
MBoretto committed
181
### Choose how to retrieve Telegram updates
182

183
The bot can handle updates with **Webhook** or **getUpdates** method:
LONGMAN's avatar
LONGMAN committed
184

185
|      | Webhook | getUpdates |
MBoretto's avatar
MBoretto committed
186
| ---- | :----: | :----: |
187
| Description | Telegram sends the updates directly to your host | You have to fetch Telegram updates manually |
MBoretto's avatar
MBoretto committed
188
| Host with https | Required | Not required |
189
| MySQL | Not required | ([Not](#getupdates-without-database)) Required  |
190

LONGMAN's avatar
LONGMAN committed
191

MBoretto's avatar
MBoretto committed
192
## Webhook installation
193

194 195 196
Note: For a more detailed explanation, head over to the [example-bot repository][example-bot-repository] and follow the instructions there.

In order to set a [Webhook][api-setwebhook] you need a server with HTTPS and composer support.
197 198
(For a [self signed certificate](#self-signed-certificate) you need to add some extra code)

199
Create [*set.php*][set.php] with the following contents:
LONGMAN's avatar
LONGMAN committed
200 201
```php
<?php
202 203
// Load composer
require __DIR__ . '/vendor/autoload.php';
LONGMAN's avatar
LONGMAN committed
204

205 206
$bot_api_key  = 'your:bot_api_key';
$bot_username = 'username_bot';
207
$hook_url     = 'https://your-domain/path/to/hook.php';
208

LONGMAN's avatar
LONGMAN committed
209
try {
210
    // Create Telegram API object
211
    $telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);
212 213

    // Set webhook
214
    $result = $telegram->setWebhook($hook_url);
MBoretto's avatar
MBoretto committed
215 216 217
    if ($result->isOk()) {
        echo $result->getDescription();
    }
LONGMAN's avatar
LONGMAN committed
218
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
219 220
    // log telegram errors
    // echo $e->getMessage();
LONGMAN's avatar
LONGMAN committed
221
}
LONGMAN's avatar
LONGMAN committed
222
```
223

224
Open your *set.php* via the browser to register the webhook with Telegram.
225
You should see `Webhook was set`.
LONGMAN's avatar
LONGMAN committed
226

227
Now, create [*hook.php*][hook.php] with the following contents:
LONGMAN's avatar
LONGMAN committed
228 229
```php
<?php
230 231
// Load composer
require __DIR__ . '/vendor/autoload.php';
LONGMAN's avatar
LONGMAN committed
232

233 234 235
$bot_api_key  = 'your:bot_api_key';
$bot_username = 'username_bot';

LONGMAN's avatar
LONGMAN committed
236
try {
237
    // Create Telegram API object
238
    $telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);
239

240
    // Handle telegram webhook request
LONGMAN's avatar
LONGMAN committed
241 242
    $telegram->handle();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
243
    // Silence is golden!
LONGMAN's avatar
LONGMAN committed
244
    // log telegram errors
245
    // echo $e->getMessage();
LONGMAN's avatar
LONGMAN committed
246
}
LONGMAN's avatar
LONGMAN committed
247
```
248

249 250 251
### Self Signed Certificate

To upload the certificate, add the certificate path as a parameter in *set.php*:
252
```php
253
$result = $telegram->setWebhook($hook_url, ['certificate' => '/path/to/certificate']);
254 255
```

256 257
### Unset Webhook

258
Edit [*unset.php*][unset.php] with your bot credentials and execute it.
259

260
## getUpdates installation
LONGMAN's avatar
LONGMAN committed
261

262
For best performance, the MySQL database should be enabled for the `getUpdates` method!
263

264
Create [*getUpdatesCLI.php*][getUpdatesCLI.php] with the following contents:
MBoretto's avatar
MBoretto committed
265
```php
MBoretto's avatar
MBoretto committed
266 267
#!/usr/bin/env php
<?php
268
require __DIR__ . '/vendor/autoload.php';
MBoretto's avatar
MBoretto committed
269

270 271
$bot_api_key  = 'your:bot_api_key';
$bot_username = 'username_bot';
272

273 274
$mysql_credentials = [
   'host'     => 'localhost',
275
   'port'     => 3306, // optional
276 277 278 279
   'user'     => 'dbuser',
   'password' => 'dbpass',
   'database' => 'dbname',
];
MBoretto's avatar
MBoretto committed
280 281

try {
282
    // Create Telegram API object
283
    $telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);
284 285

    // Enable MySQL
286
    $telegram->enableMySql($mysql_credentials);
287

288
    // Handle telegram getUpdates request
MBoretto's avatar
MBoretto committed
289 290 291
    $telegram->handleGetUpdates();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
    // log telegram errors
292
    // echo $e->getMessage();
293
}
MBoretto's avatar
MBoretto committed
294
```
MBoretto's avatar
MBoretto committed
295

296 297 298
Next, give the file permission to execute:
```bash
$ chmod +x getUpdatesCLI.php
MBoretto's avatar
MBoretto committed
299
```
300 301 302 303

Lastly, run it!
```bash
$ ./getUpdatesCLI.php
MBoretto's avatar
MBoretto committed
304
```
MBoretto's avatar
MBoretto committed
305

306 307 308 309 310 311 312
### getUpdates without database

If you choose to / or are obliged to use the `getUpdates` method without a database, you can replace the `$telegram->useMySQL(...);` line above with:
```php
$telegram->useGetUpdatesWithoutDatabase();
```

313 314 315
## Support

### Types
316 317 318 319 320

All types are implemented according to Telegram API (20 January 2016).

### Inline Query

MBoretto's avatar
MBoretto committed
321
Full support for inline query according to Telegram API (20 January 2016).
322

MBoretto's avatar
MBoretto committed
323 324
### Methods

325 326 327 328 329
All methods are implemented according to Telegram API (20 January 2016).

#### Send Message

Messages longer than 4096 characters are split up into multiple messages.
MBoretto's avatar
MBoretto committed
330 331

```php
332 333 334 335
$result = Request::sendMessage([
    'chat_id' => $chat_id,
    'text'    => 'Your utf8 text 😜 ...',
]);
MBoretto's avatar
MBoretto committed
336 337
```

338 339
#### Send Photo

340
To send a local photo, add it properly to the `$data` parameter using the file path:
341 342

```php
343
$result = Request::sendPhoto([
344 345
    'chat_id' => $chat_id,
    'photo'   => Request::encodeFile('/path/to/pic.jpg'),
346
]);
347 348
```

349
If you know the `file_id` of a previously uploaded file, just use it directly in the data array:
MBoretto's avatar
MBoretto committed
350 351

```php
352
$result = Request::sendPhoto([
353
    'chat_id' => $chat_id,
354 355
    'photo'   => 'AAQCCBNtIhAoAAss4tLEZ3x6HzqVAAqC',
]);
MBoretto's avatar
MBoretto committed
356 357
```

358 359 360
To send a remote photo, use the direct URL instead:

```php
361
$result = Request::sendPhoto([
362 363
    'chat_id' => $chat_id,
    'photo'   => 'https://example.com/path/to/pic.jpg',
364
]);
365 366
```

367
*sendAudio*, *sendDocument*, *sendAnimation*, *sendSticker*, *sendVideo*, *sendVoice* and *sendVideoNote* all work in the same way, just check the [API documentation](https://core.telegram.org/bots/api#sendphoto) for the exact usage.
368
See the [*ImageCommand.php*][ImageCommand.php] for a full example.
369 370

#### Send Chat Action
MBoretto's avatar
MBoretto committed
371 372

```php
373 374
Request::sendChatAction([
    'chat_id' => $chat_id,
375
    'action'  => Longman\TelegramBot\ChatAction::TYPING,
376
]);
MBoretto's avatar
MBoretto committed
377 378
```

379 380
#### getUserProfilePhoto

381
Retrieve the user photo, see [*WhoamiCommand.php*][WhoamiCommand.php] for a full example.
382

383
#### getFile and downloadFile
384

385
Get the file path and download it, see [*WhoamiCommand.php*][WhoamiCommand.php] for a full example.
MBoretto's avatar
MBoretto committed
386

MBoretto's avatar
MBoretto committed
387
#### Send message to all active chats
388 389

To do this you have to enable the MySQL connection.
390
Here's an example of use (check [`DB::selectChats()`][DB::selectChats] for parameter usage):
MBoretto's avatar
MBoretto committed
391 392

```php
393
$results = Request::sendToActiveChats(
394 395 396 397 398 399 400 401 402
    'sendMessage', // Callback function to execute (see Request.php methods)
    ['text' => 'Hey! Check out the new features!!'], // Param to evaluate the request
    [
        'groups'      => true,
        'supergroups' => true,
        'channels'    => false,
        'users'       => true,
    ]
);
MBoretto's avatar
MBoretto committed
403
```
MBoretto's avatar
MBoretto committed
404

405
You can also broadcast a message to users, from the private chat with your bot. Take a look at the [admin commands](#admin-commands) below.
406 407

## Utils
LONGMAN's avatar
LONGMAN committed
408

409 410
### MySQL storage (Recommended)

411
If you want to save messages/users/chats for further usage in commands, create a new database (`utf8mb4_unicode_520_ci`), import *structure.sql* and enable MySQL support after object creation and BEFORE `handle()` method:
412 413 414 415

```php
$mysql_credentials = [
   'host'     => 'localhost',
416
   'port'     => 3306, // optional
417 418 419 420 421
   'user'     => 'dbuser',
   'password' => 'dbpass',
   'database' => 'dbname',
];

422
$telegram->enableMySql($mysql_credentials);
MBoretto's avatar
MBoretto committed
423
```
424

425
You can set a custom prefix to all the tables while you are enabling MySQL:
426 427

```php
428
$telegram->enableMySql($mysql_credentials, $bot_username . '_');
429
```
430

431 432
You can also store inline query and chosen inline query data in the database.

433
#### External Database connection
434 435 436

It is possible to provide the library with an external MySQL PDO connection.
Here's how to configure it:
437

438
```php
439 440
$telegram->enableExternalMySql($external_pdo_connection)
//$telegram->enableExternalMySql($external_pdo_connection, $table_prefix)
441
```
442 443 444
### Channels Support

All methods implemented can be used to manage channels.
445
With [admin commands](#admin-commands) you can manage your channels directly with your bot private chat.
446

MBoretto's avatar
MBoretto committed
447
### Commands
448

449 450
#### Predefined Commands

451
The bot is able to recognise commands in a chat with multiple bots (/command@mybot).
452

453
It can execute commands that get triggered by chat events.
MBoretto's avatar
MBoretto committed
454

455
Here's the list:
456

457 458 459 460 461 462 463 464 465 466 467 468
- *StartCommand.php* (A new user starts to use the bot.)
- *NewChatMembersCommand.php* (A new member(s) was added to the group, information about them.)
- *LeftChatMemberCommand.php* (A member was removed from the group, information about them.)
- *NewChatTitleCommand.php* (A chat title was changed to this value.)
- *NewChatPhotoCommand.php* (A chat photo was changed to this value.)
- *DeleteChatPhotoCommand.php* (Service message: the chat photo was deleted.)
- *GroupChatCreatedCommand.php* (Service message: the group has been created.)
- *SupergroupChatCreatedCommand.php* (Service message: the supergroup has been created.)
- *ChannelChatCreatedCommand.php* (Service message: the channel has been created.)
- *MigrateToChatIdCommand.php* (The group has been migrated to a supergroup with the specified identifier.)
- *MigrateFromChatIdCommand.php* (The supergroup has been migrated from a group with the specified identifier.)
- *PinnedMessageCommand.php* (Specified message was pinned.)
469

470 471 472 473
- *GenericmessageCommand.php* (Handle any type of message.)
- *GenericCommand.php* (Handle commands that don't exist or to use commands as a variable.)
    - Favourite colour? */black, /red*
    - Favourite number? */1, /134*
MBoretto's avatar
MBoretto committed
474

475 476
#### Custom Commands

477 478
Maybe you would like to develop your own commands.
There is a guide to help you [create your own commands][wiki-create-your-own-commands].
479

480
Also, be sure to have a look at the [example commands][ExampleCommands-folder] to learn more about custom commands and how they work.
MBoretto's avatar
MBoretto committed
481

MBoretto's avatar
MBoretto committed
482
#### Commands Configuration
483

484
With this method you can set some command specific parameters, for example:
485

MBoretto's avatar
MBoretto committed
486
```php
487
// Google geocode/timezone API key for /date command
488 489 490
$telegram->setCommandConfig('date', [
    'google_api_key' => 'your_google_api_key_here',
]);
491

492
// OpenWeatherMap API key for /weather command
493 494 495
$telegram->setCommandConfig('weather', [
    'owm_api_key' => 'your_owm_api_key_here',
]);
MBoretto's avatar
MBoretto committed
496 497
```

498
### Admin Commands
499

500
Enabling this feature, the bot admin can perform some super user commands like:
MBoretto's avatar
MBoretto committed
501
- List all the chats started with the bot */chats*
502 503 504
- Clean up old database entries */cleanup*
- Show debug information about the bot */debug*
- Send message to all chats */sendtoall*
505
- Post any content to your channels */sendtochannel*
506 507 508
- Inspect a user or a chat with */whois*

Take a look at all default admin commands stored in the [*src/Commands/AdminCommands/*][AdminCommands-folder] folder.
509 510 511

#### Set Admins

512
You can specify one or more admins with this option:
513

514
```php
515
// Single admin
516 517
$telegram->enableAdmin(your_telegram_user_id);

518
// Multiple admins
519 520 521 522
$telegram->enableAdmins([
    your_telegram_user_id,
    other_telegram_user_id,
]);
523
```
524
Telegram user id can be retrieved with the [*/whoami*][WhoamiCommand.php] command.
525 526

#### Channel Administration
MBoretto's avatar
MBoretto committed
527

528
To enable this feature follow these steps:
529
- Add your bot as channel administrator, this can be done with any Telegram client.
MBoretto's avatar
MBoretto committed
530
- Enable admin interface for your user as explained in the admin section above.
531
- Enter your channel name as a parameter for the [*/sendtochannel*][SendtochannelCommand.php] command:
MBoretto's avatar
MBoretto committed
532
```php
533 534 535 536 537
$telegram->setCommandConfig('sendtochannel', [
    'your_channel' => [
        '@type_here_your_channel',
    ]
]);
538
```
539
- If you want to manage more channels:
540
```php
541 542 543 544 545 546 547
$telegram->setCommandConfig('sendtochannel', [
    'your_channel' => [
        '@type_here_your_channel',
        '@type_here_another_channel',
        '@and_so_on',
    ]
]);
548
```
MBoretto's avatar
MBoretto committed
549 550 551
- Enjoy!

### Upload and Download directory path
552

553
To use the Upload and Download functionality, you need to set the paths with:
554
```php
555 556
$telegram->setDownloadPath('/your/path/Download');
$telegram->setUploadPath('/your/path/Upload');
MBoretto's avatar
MBoretto committed
557
```
558 559

## Documentation
560

561
Take a look at the repo [Wiki][wiki] for further information and tutorials!
MBoretto's avatar
MBoretto committed
562 563
Feel free to improve!

564 565 566
## Example bot

We're busy working on a full A-Z example bot, to help get you started with this library and to show you how to use all its features.
567
You can check the progress of the [example bot repository][example-bot-repository]).
568

569 570
## Projects with this library

MBoretto's avatar
MBoretto committed
571
Here's a list of projects that feats this library, feel free to add yours!
572 573
- [Inline Games](https://github.com/jacklul/inlinegamesbot) ([@inlinegamesbot](https://telegram.me/inlinegamesbot))
- [Super-Dice-Roll](https://github.com/RafaelDelboni/Super-Dice-Roll) ([@superdiceroll_bot](https://telegram.me/superdiceroll_bot))
Alexander Grüßung's avatar
Alexander Grüßung committed
574
- [tg-mentioned-bot](https://github.com/gruessung/tg-mentioned-bot)
575

MBoretto's avatar
MBoretto committed
576
## Troubleshooting
577

MBoretto's avatar
MBoretto committed
578
If you like living on the edge, please report any bugs you find on the
579
[PHP Telegram Bot issues][issues] page.
580

MBoretto's avatar
MBoretto committed
581
## Contributing
582

583
See [CONTRIBUTING](.github/CONTRIBUTING.md) for more information.
584

585 586 587 588
## Security

See [SECURITY](SECURITY.md) for more information.

589 590 591 592 593 594 595
## Donate

All work on this bot consists of many hours of coding during our free time, to provide you with a Telegram Bot library that is easy to use and extend.
If you enjoy using this library and would like to say thank you, donations are a great way to show your support.

Donations are invested back into the project :+1:

596 597
Thank you for keeping this project alive :pray:

598 599 600 601 602 603 604 605
- [![Patreon](https://user-images.githubusercontent.com/9423417/59235980-a5fa6b80-8be3-11e9-8ae7-020bc4ae9baa.png) Patreon.com/phptelegrambot][Patreon]
- [![OpenCollective](https://user-images.githubusercontent.com/9423417/59235978-a561d500-8be3-11e9-89be-82ec54be1546.png) OpenCollective.com/php-telegram-bot][OpenCollective]
- [![Ko-fi](https://user-images.githubusercontent.com/9423417/59235976-a561d500-8be3-11e9-911d-b1908c3e6a33.png) Ko-fi.com/phptelegrambot][Ko-fi]
- [![Tidelift](https://user-images.githubusercontent.com/9423417/59235982-a6930200-8be3-11e9-8ac2-bfb6991d80c5.png) Tidelift.com/longman/telegram-bot][Tidelift]
- [![Liberapay](https://user-images.githubusercontent.com/9423417/59235977-a561d500-8be3-11e9-9d16-bc3b13d3ceba.png) Liberapay.com/PHP-Telegram-Bot][liberapay]
- [![PayPal](https://user-images.githubusercontent.com/9423417/59235981-a5fa6b80-8be3-11e9-9761-15eb7a524cb0.png) PayPal.me/noplanman][PayPal-noplanman] (account of @noplanman)
- [![Bitcoin](https://user-images.githubusercontent.com/9423417/59235974-a4c93e80-8be3-11e9-9fde-260c821b6eae.png) 166NcyE7nDxkRPWidWtG1rqrNJoD5oYNiV][Bitcoin]
- [![Ethereum](https://user-images.githubusercontent.com/9423417/59235975-a4c93e80-8be3-11e9-8762-7a47c62c968d.png) 0x485855634fa212b0745375e593fAaf8321A81055][Ethereum]
606

607 608
## License

609
Please see the [LICENSE](LICENSE) included in this repository for a full copy of the MIT license,
610 611
which this project is licensed under.

LONGMAN's avatar
LONGMAN committed
612 613
## Credits

LONGMAN's avatar
LONGMAN committed
614
Credit list in [CREDITS](CREDITS)
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633

[Telegram-Bot-API]: https://core.telegram.org/bots/api "Telegram Bot API"
[composer]: https://getcomposer.org/ "Composer"
[example-bot-repository]: https://github.com/php-telegram-bot/example-bot "Example Bot repository"
[api-setwebhook]: https://core.telegram.org/bots/api#setwebhook "Webhook on Telegram Bot API"
[set.php]: https://github.com/php-telegram-bot/example-bot/blob/master/set.php "example set.php"
[unset.php]: https://github.com/php-telegram-bot/example-bot/blob/master/unset.php "example unset.php"
[hook.php]: https://github.com/php-telegram-bot/example-bot/blob/master/hook.php "example hook.php"
[getUpdatesCLI.php]: https://github.com/php-telegram-bot/example-bot/blob/master/getUpdatesCLI.php "example getUpdatesCLI.php"
[AdminCommands-folder]: https://github.com/php-telegram-bot/core/tree/master/src/Commands/AdminCommands "Admin commands folder"
[ExampleCommands-folder]: https://github.com/php-telegram-bot/example-bot/blob/master/Commands "Example commands folder"
[ImageCommand.php]: https://github.com/php-telegram-bot/example-bot/blob/master/Commands/ImageCommand.php "example /image command"
[WhoamiCommand.php]: https://github.com/php-telegram-bot/example-bot/blob/master/Commands/WhoamiCommand.php "example /whoami command"
[HelpCommand.php]: https://github.com/php-telegram-bot/example-bot/blob/master/Commands/HelpCommand.php "example /help command"
[SendtochannelCommand.php]: https://github.com/php-telegram-bot/core/blob/master/src/Commands/AdminCommands/SendtochannelCommand.php "/sendtochannel admin command"
[DB::selectChats]: https://github.com/php-telegram-bot/core/blob/0.46.0/src/DB.php#L1000 "DB::selectChats() parameters"
[wiki]: https://github.com/php-telegram-bot/core/wiki "PHP Telegram Bot Wiki"
[wiki-create-your-own-commands]: https://github.com/php-telegram-bot/core/wiki/Create-your-own-commands "Create your own commands"
[issues]: https://github.com/php-telegram-bot/core/issues "PHP Telegram Bot Issues"
634

635 636 637 638 639 640 641 642
[Patreon]: https://www.patreon.com/phptelegrambot "Support us on Patreon"
[OpenCollective]: https://opencollective.com/php-telegram-bot "Support us on Open Collective"
[Ko-fi]: https://ko-fi.com/phptelegrambot "Support us on Ko-fi"
[Tidelift]: https://tidelift.com/subscription/pkg/packagist-longman-telegram-bot?utm_source=packagist-longman-telegram-bot&utm_medium=referral&utm_campaign=readme "Support us on Tidelift"
[liberapay]: https://liberapay.com/PHP-Telegram-Bot "Donate with Liberapay"
[PayPal-noplanman]: https://paypal.me/noplanman "Donate with PayPal"
[Bitcoin]: https://www.blockchain.com/btc/address/166NcyE7nDxkRPWidWtG1rqrNJoD5oYNiV "Donate with Bitcoin"
[Ethereum]: https://etherscan.io/address/0x485855634fa212b0745375e593fAaf8321A81055 "Donate with Ethereum"