| 1 |
Telegram backend configuration |
| 2 |
============================== |
| 3 |
|
| 4 |
This backend lets you connect to |
| 5 |
`Telegram Messenger <https://telegram.org/>`_. |
| 6 |
To select this backend, |
| 7 |
set `BACKEND = 'Telegram'`. |
| 8 |
|
| 9 |
Extra Dependencies |
| 10 |
------------------ |
| 11 |
|
| 12 |
You need to install this dependency before using Errbot with Telegram:: |
| 13 |
|
| 14 |
pip install python-telegram-bot |
| 15 |
|
| 16 |
Account setup |
| 17 |
------------- |
| 18 |
|
| 19 |
You will first need to create a bot account on Telegram |
| 20 |
for errbot to use. |
| 21 |
You can do this by talking to `@BotFather`_ |
| 22 |
(see also: `BotFather docs <https://core.telegram.org/bots#6-botfather>`_). |
| 23 |
Make sure you take note of the token you receive, |
| 24 |
you'll need it later. |
| 25 |
|
| 26 |
Once you have created a bot account on Telegram |
| 27 |
you may configure the account in errbot |
| 28 |
by setting up `BOT_IDENTITY` as follows:: |
| 29 |
|
| 30 |
BOT_IDENTITY = { |
| 31 |
'token': '103419016:AAbcd1234...', |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
Bot admins |
| 36 |
---------- |
| 37 |
|
| 38 |
You can setup `BOT_ADMINS` to designate which users are bot admins, |
| 39 |
but on Telegram this is a little more difficult to do. |
| 40 |
In order to configure a user here |
| 41 |
you will have to obtain their user ID. |
| 42 |
|
| 43 |
The easiest way to do this is to start the bot with no `BOT_ADMINS` defined. |
| 44 |
Then, have the user for which you want to obtain the user ID message the bot |
| 45 |
and send it the `!whoami` command. |
| 46 |
|
| 47 |
This will print some info about the user, including the following: |
| 48 |
`string representation is '123669037'`. |
| 49 |
It is this number that needs to be filled in for `BOT_ADMINS`. |
| 50 |
For example: `BOT_ADMINS = (123669037,)` |
| 51 |
|
| 52 |
|
| 53 |
Rooms |
| 54 |
----- |
| 55 |
|
| 56 |
Telegram does not expose any room management to bots. |
| 57 |
As a group admin, you will have to add a bot to a groupchat |
| 58 |
at which point it will automatically join. |
| 59 |
|
| 60 |
By default the bot will not receive any messages |
| 61 |
which makes interacting with it in a groupchat difficult. |
| 62 |
|
| 63 |
To give the bot access to all messages in a groupchat, |
| 64 |
you can use the `/setprivacy` command when talking to |
| 65 |
`@BotFather`_. |
| 66 |
|
| 67 |
.. note:: |
| 68 |
|
| 69 |
Because Telegram does not support room management, |
| 70 |
you must set `CHATROOM_PRESENCE = ()` |
| 71 |
otherwise you will see errors. |
| 72 |
|
| 73 |
|
| 74 |
Slash commands |
| 75 |
-------------- |
| 76 |
|
| 77 |
Telegram treats messages which |
| 78 |
`start with a / <https://core.telegram.org/bots#commands>`_ |
| 79 |
differently, |
| 80 |
which is designed specifically for interacting with bots. |
| 81 |
|
| 82 |
We therefor suggest setting `BOT_PREFIX = '/'` to take advantage of this. |
| 83 |
|
| 84 |
.. _`@BotFather`: https://telegram.me/botfather |