mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-06 07:50:32 +00:00
Update deep_linking basic examples (#1151)
This commit is contained in:
parent
6efef7137c
commit
99cf7028ec
1 changed files with 9 additions and 7 deletions
|
|
@ -15,8 +15,9 @@ Basic link example:
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.utils.deep_linking import get_start_link
|
||||
link = await get_start_link('foo')
|
||||
from aiogram.utils.deep_linking import create_start_link
|
||||
|
||||
link = await create_start_link(bot, 'foo')
|
||||
|
||||
# result: 'https://t.me/MyBot?start=foo'
|
||||
|
||||
|
|
@ -24,20 +25,21 @@ Encoded link example:
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.utils.deep_linking import get_start_link
|
||||
from aiogram.utils.deep_linking import create_start_link
|
||||
|
||||
link = await get_start_link('foo', encode=True)
|
||||
link = await create_start_link(bot, 'foo', encode=True)
|
||||
# result: 'https://t.me/MyBot?start=Zm9v'
|
||||
|
||||
Decode it back example:
|
||||
.. code-block:: python
|
||||
|
||||
from aiogram.utils.deep_linking import decode_payload
|
||||
from aiogram.filters import CommandStart, CommandObject
|
||||
from aiogram.types import Message
|
||||
|
||||
@dp.message_handler(commands=["start"])
|
||||
async def handler(message: Message):
|
||||
args = message.get_args()
|
||||
@router.message(CommandStart(deep_link=True))
|
||||
async def handler(message: Message, command: CommandObject):
|
||||
args = command.args
|
||||
payload = decode_payload(args)
|
||||
await message.answer(f"Your payload: {payload}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue