Add autogenerated docs for examples. Will be changed soon.

This commit is contained in:
Alex Root Junior 2018-09-08 02:14:14 +03:00
parent 06097fffa1
commit f9c1ce35bb
17 changed files with 216 additions and 0 deletions

View file

@ -0,0 +1,27 @@
.. Autogenerated file at 2018-09-08 02:07:37.572483
=========================
Adwanced executor example
=========================
!/usr/bin/env python3
In this example used ArgumentParser for configuring Your bot.
Provided to start bot with webhook:
python adwanced_executor_example.py \
--token TOKEN_HERE \
--host 0.0.0.0 \
--port 8084 \
--host-name example.com \
--webhook-port 443
Or long polling:
python adwanced_executor_example.py --token TOKEN_HERE
So... In this example found small trouble:
can't get bot instance in handlers.
If you want to automatic change getting updates method use executor utils (from aiogram.utils.executor)
TODO: Move token to environment variables.
.. literalinclude:: ../../../examples/adwanced_executor_example.py
:caption: adwanced_executor_example.py
:language: python
:linenos:
:lines: 24-

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.593501
=================
Broadcast example
=================
.. literalinclude:: ../../../examples/broadcast_example.py
:caption: broadcast_example.py
:language: python
:linenos:

View file

@ -0,0 +1,13 @@
.. Autogenerated file at 2018-09-08 02:07:37.558059
===================
Check user language
===================
Babel is required.
.. literalinclude:: ../../../examples/check_user_language.py
:caption: check_user_language.py
:language: python
:linenos:
:lines: 5-

View file

@ -1,6 +1,7 @@
Echo bot
========
Very simple example of the bot which will sent text of the received messages to the sender
.. literalinclude:: ../../../examples/echo_bot.py
:caption: echo_bot.py

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.595032
============================
Finite state machine example
============================
.. literalinclude:: ../../../examples/finite_state_machine_example.py
:caption: finite_state_machine_example.py
:language: python
:linenos:

View file

@ -0,0 +1,16 @@
.. Autogenerated file at 2018-09-08 02:07:37.580949
==============================
Finite state machine example 2
==============================
This example is equals with 'finite_state_machine_example.py' but with FSM Middleware
Note that FSM Middleware implements the more simple methods for working with storage.
With that middleware all data from storage will be loaded before event will be processed
and data will be stored after processing the event.
.. literalinclude:: ../../../examples/finite_state_machine_example_2.py
:caption: finite_state_machine_example_2.py
:language: python
:linenos:
:lines: 9-

View file

@ -0,0 +1,28 @@
.. Autogenerated file at 2018-09-08 02:07:37.591007
============
I18n example
============
Internalize your bot
Step 1: extract texts
# pybabel extract i18n_example.py -o locales/mybot.pot
Step 2: create *.po files. For e.g. create en, ru, uk locales.
# echo {en,ru,uk} | xargs -n1 pybabel init -i locales/mybot.pot -d locales -D mybot -l
Step 3: translate texts
Step 4: compile translations
# pybabel compile -d locales -D mybot
Step 5: When you change the code of your bot you need to update po & mo files.
Step 5.1: regenerate pot file:
command from step 1
Step 5.2: update po files
# pybabel update -d locales -D mybot -i locales/mybot.pot
Step 5.3: update your translations
Step 5.4: compile mo files
command from step 4
.. literalinclude:: ../../../examples/i18n_example.py
:caption: i18n_example.py
:language: python
:linenos:
:lines: 22-

View file

@ -1,5 +1,22 @@
========
Examples
========
.. toctree::
echo_bot
inline_bot
adwanced_executor_example
proxy_and_emojize
finite_state_machine_example
finite_state_machine_example_2
throtling_example
i18n_example
regexp_commands_filter_example
check_user_language
middleware_and_antiflood
webhook_example
webhook_example_2
payments
broadcast_example
media_group

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.561907
==========
Inline bot
==========
.. literalinclude:: ../../../examples/inline_bot.py
:caption: inline_bot.py
:language: python
:linenos:

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.566615
===========
Media group
===========
.. literalinclude:: ../../../examples/media_group.py
:caption: media_group.py
:language: python
:linenos:

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.560132
========================
Middleware and antiflood
========================
.. literalinclude:: ../../../examples/middleware_and_antiflood.py
:caption: middleware_and_antiflood.py
:language: python
:linenos:

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.579017
========
Payments
========
.. literalinclude:: ../../../examples/payments.py
:caption: payments.py
:language: python
:linenos:

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.555359
=================
Proxy and emojize
=================
.. literalinclude:: ../../../examples/proxy_and_emojize.py
:caption: proxy_and_emojize.py
:language: python
:linenos:

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.568530
==============================
Regexp commands filter example
==============================
.. literalinclude:: ../../../examples/regexp_commands_filter_example.py
:caption: regexp_commands_filter_example.py
:language: python
:linenos:

View file

@ -0,0 +1,14 @@
.. Autogenerated file at 2018-09-08 02:07:37.563878
=================
Throtling example
=================
Example for throttling manager.
You can use that for flood controlling.
.. literalinclude:: ../../../examples/throtling_example.py
:caption: throtling_example.py
:language: python
:linenos:
:lines: 7-

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.587860
===============
Webhook example
===============
.. literalinclude:: ../../../examples/webhook_example.py
:caption: webhook_example.py
:language: python
:linenos:

View file

@ -0,0 +1,10 @@
.. Autogenerated file at 2018-09-08 02:07:37.576034
=================
Webhook example 2
=================
.. literalinclude:: ../../../examples/webhook_example_2.py
:caption: webhook_example_2.py
:language: python
:linenos: