mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Bump examples, docs and executor (nothing)
This commit is contained in:
parent
21908739e9
commit
9f13e11e6b
9 changed files with 57 additions and 21 deletions
|
|
@ -1,10 +1,11 @@
|
|||
.. Autogenerated file at 2018-09-08 02:07:37.572483
|
||||
.. Autogenerated file at 2018-10-28 19:31:48.335963
|
||||
|
||||
=========================
|
||||
Adwanced executor example
|
||||
=========================
|
||||
|
||||
!/usr/bin/env python3
|
||||
**This example is outdated**
|
||||
In this example used ArgumentParser for configuring Your bot.
|
||||
Provided to start bot with webhook:
|
||||
python adwanced_executor_example.py \
|
||||
|
|
@ -18,10 +19,10 @@ 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.
|
||||
TODO: Move token to environment variables.
|
||||
|
||||
.. literalinclude:: ../../../examples/adwanced_executor_example.py
|
||||
:caption: adwanced_executor_example.py
|
||||
:language: python
|
||||
:linenos:
|
||||
:lines: 24-
|
||||
:lines: 25-
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
.. Autogenerated file at 2018-09-08 02:07:37.587860
|
||||
.. Autogenerated file at 2018-10-28 19:31:48.341172
|
||||
|
||||
===============
|
||||
Webhook example
|
||||
===============
|
||||
|
||||
Example outdated
|
||||
|
||||
.. literalinclude:: ../../../examples/webhook_example.py
|
||||
:caption: webhook_example.py
|
||||
:language: python
|
||||
:linenos:
|
||||
:lines: 5-
|
||||
|
|
|
|||
|
|
@ -23,10 +23,7 @@ Changelog
|
|||
- Used `aiohttp_socks` instead of `aiosocksy` for Socks4/5 proxy;
|
||||
- `types.ContentType` was divided to `types.ContentType` and `types.ContentTypes`;
|
||||
- Allowed to use rapidjson instead of ujson/json;
|
||||
- (**in process**) Implemented utils for Telegram Passport;
|
||||
- (**in process**) Webhook security improvements;
|
||||
- (**in process**) Updated examples.
|
||||
|
||||
- `.current()` method in bot and dispatcher objects was renamed to `get_current()`;
|
||||
|
||||
Instructions
|
||||
============
|
||||
|
|
@ -58,6 +55,7 @@ Now `func` keyword argument can't be used for passing filters to the list of fil
|
|||
@dp.message_handler(types.ChatType.is_private, my_filter)
|
||||
async def ...
|
||||
|
||||
(func filter is still available until v2.1)
|
||||
|
||||
Filters factory
|
||||
~~~~~~~~~~~~~~~
|
||||
|
|
@ -97,6 +95,24 @@ Passing data from filters as keyword arguments to the handlers
|
|||
You can pass any data from any filter to the handler by returning :obj:`dict`
|
||||
If any key from the received dictionary not in the handler specification the key will be skipped and and will be unavailable from the handler
|
||||
|
||||
Before (<=v1.4)
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
async def my_filter(message: types.Message):
|
||||
# do something here
|
||||
message.conf['foo'] = 'foo'
|
||||
message.conf['bar'] = 42
|
||||
return True
|
||||
|
||||
@dp.message_handler(func=my_filter)
|
||||
async def my_message_handler(message: types.Message):
|
||||
bar = message.conf["bar"]
|
||||
await message.reply(f'bar = {bar}')
|
||||
|
||||
|
||||
Now (v2.0)
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
async def my_filter(message: types.Message):
|
||||
|
|
@ -107,6 +123,7 @@ If any key from the received dictionary not in the handler specification the key
|
|||
async def my_message_handler(message: types.Message, bar: int):
|
||||
await message.reply(f'bar = {bar}')
|
||||
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
Filters can also be used as logical expressions:
|
||||
|
|
@ -156,6 +173,9 @@ Usage:
|
|||
return await message.reply(f"Counter: {proxy['counter']}")
|
||||
|
||||
|
||||
This method is not recommended in high-load solutions in reason named "race-condition".
|
||||
|
||||
|
||||
File uploading mechanism
|
||||
------------------------
|
||||
Fixed uploading files. Removed `BaseBot.send_file` method. This allowed to send the `thumb` field.
|
||||
|
|
@ -183,6 +203,8 @@ I18n Middleware
|
|||
---------------
|
||||
You can internalize your bot by following next steps:
|
||||
|
||||
(Code snippets in this example related with `examples/i18n_example.py`)
|
||||
|
||||
First usage
|
||||
~~~~~~~~~~~
|
||||
1. Extract texts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue