aiogram/docs/source/quick_start.rst

46 lines
1,014 B
ReStructuredText
Raw Normal View History

===========
2017-06-03 11:58:26 +03:00
Quick start
===========
Simple template
---------------
2018-01-23 12:48:09 +03:00
At first you have to import all necessary modules
.. literalinclude:: ../../examples/echo_bot.py
:language: python
2018-12-18 15:29:13 +03:00
:lines: 6-8
2018-01-23 12:48:09 +03:00
Then you have to initialize bot and dispatcher instances.
2017-11-16 19:37:52 +02:00
Bot token you can get from `@BotFather <https://t.me/BotFather>`_
.. literalinclude:: ../../examples/echo_bot.py
:language: python
2018-12-18 15:29:13 +03:00
:lines: 10-17
2018-01-23 12:48:09 +03:00
Next step: interaction with bots starts with one command. Register your first command handler:
.. literalinclude:: ../../examples/echo_bot.py
:language: python
2019-04-21 01:16:42 +03:00
:lines: 20-25
2018-09-07 21:24:13 +03:00
If you want to handle all messages in the chat simply add handler without filters:
.. literalinclude:: ../../examples/echo_bot.py
:language: python
2019-04-21 01:16:42 +03:00
:lines: 35-37
2018-09-07 21:24:13 +03:00
2018-01-23 12:48:09 +03:00
Last step: run long polling.
.. literalinclude:: ../../examples/echo_bot.py
:language: python
2019-04-21 01:16:42 +03:00
:lines: 40-41
2017-11-16 19:37:52 +02:00
Summary
-------
.. literalinclude:: ../../examples/echo_bot.py
:language: python
:linenos:
2018-12-18 15:29:13 +03:00
:lines: -19,27-