Skip to content

Commit 08405f1

Browse files
author
Pietro Albini
committed
Add narrative documentation about creating bots
1 parent 7cbca4a commit 08405f1

File tree

4 files changed

+72
-13
lines changed

4 files changed

+72
-13
lines changed

docs/bot-creation.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.. Copyright (c) 2016 Pietro Albini <[email protected]>
2+
Released under the MIT license
3+
4+
.. _bot-creation:
5+
6+
=========================
7+
Create a new Telegram bot
8+
=========================
9+
10+
Before you start writing any code, you should create your bot on Telegram. This
11+
reserves your bot an username, and gives you the API key you need to control
12+
your bot. This chapter explains you how to do so.
13+
14+
.. _bot-creation-naming:
15+
16+
Choose a good username for your bot
17+
===================================
18+
19+
The username of your bot is really important: users will use it to tell their
20+
friends about your bot, and it will appear on telegram.me links. Also, you're
21+
not allowed to change username without recreating your bot, and so without
22+
losing users.
23+
24+
Bot usernames must adhere to the following rules:
25+
26+
* The username must be long at least five characters
27+
* The username can only contain letters, digits and underscores
28+
* The username must end with ``bot``
29+
30+
For example, all the following usernames are valid: ``my_awesome_bot``,
31+
``SpamBot``, ``test123bot``.
32+
33+
.. _bot-creation-botfather:
34+
35+
Create the bot with @botfather
36+
==============================
37+
38+
Currently, you can only create a new bot... with another bot. With your
39+
Telegram client open, contact `@botfather`_, start it and execute the
40+
``/newbot`` command. It will ask you some questions about your bot.
41+
42+
Then it will give you an unique API key, which you can use to communicate with
43+
your bot. **Be sure to keep this key secret!** Everyone with your API key can
44+
take full control of your bot, and that's not a fun thing.
45+
46+
.. _bot-creation-customization:
47+
48+
Customize your bot
49+
==================
50+
51+
Other than allowing you to create it, `@botfather`_ also permits you to
52+
customize your bot. For example, you can use it to change your bot's avatar,
53+
its name, or its description. In order to see what you can do, just use the
54+
``/help`` command on @botfather. Then execute the command for the thing you
55+
want to customize.
56+
57+
If you want to use your bot just to manage a channel, you probably don't need
58+
to do this.
59+
60+
.. _@botfather: https://telegram.me/botfather

docs/channels.rst

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@ With botogram you can easily do that, without even the need to run the bot.
1818
Preparation
1919
===========
2020

21-
In order to start working with channels, you need to get a bot's API key. If
22-
you already have a bot you can skip this step. First of all you need to contact
23-
the `@botfather`_ Telegram account, and then send to it the ``/newbot``
24-
command. After you provide all the information he needs, you will get an API
25-
key, which looks like this fake one::
21+
Before you can start working with channels, you need to create a bot which will
22+
be able to send messages to your channel. If you haven't done that already,
23+
check the :ref:`bot creation <bot-creation>` chapter of this documentation.
2624

27-
123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi
28-
29-
The final step is to add your bot as an administrator of the channel. Open your
30-
favourite Telegram client, and go to the administrators' section of your
31-
channel. From it you should add your bot, and then you're ready.
25+
After that you need to allow your bot to send messages to your channel. Open
26+
your favorite Telegram client, and go to the administrators' section of your
27+
channel. From there you should add your bot, and then you're ready.
3228

3329
.. _channels-standalone:
3430

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Narrative documentation
5353
.. toctree::
5454
:maxdepth: 2
5555

56+
bot-creation
5657
shared-memory
5758
tasks
5859
custom-components

docs/quickstart/api-key.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ it needs to know, it will give you an API key, like this fake one::
2020

2121
123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi
2222

23-
Write it down somewhere. You can further customize the bot from that chat,
24-
check `the @botfather documentation`_ if you want to know more.
23+
Write it down somewhere, but **be sure to keep it secret!** Everyone with your
24+
API key can take full control of your bot, and that's not a fun thing.
25+
26+
If you want to learn more about creating and customizing bots, check the
27+
:ref:`bot creation <bot-creation>` chapter of this documentation.
2528

2629
.. _@botfather: https://telegram.me/botfather
27-
.. _the @botfather documentation: https://core.telegram.org/bots/#botfather

0 commit comments

Comments
 (0)