mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 18:01:04 +00:00
[3.x] Bot API 6.0 (#890)
* Base implementation * Bump license * Revert re-generated tests * Fix tests, improved docs * Remove TODO * Removed unreachable code * Changed type of `last_synchronization_error_date` * Fixed wrongly cleaned code
This commit is contained in:
parent
286cf39c8a
commit
497436595d
81 changed files with 1942 additions and 147 deletions
48
examples/web_app/handlers.py
Normal file
48
examples/web_app/handlers.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
from aiogram import Bot, F, Router
|
||||
from aiogram.dispatcher.filters import Command
|
||||
from aiogram.types import (
|
||||
InlineKeyboardButton,
|
||||
InlineKeyboardMarkup,
|
||||
MenuButtonWebApp,
|
||||
Message,
|
||||
WebAppInfo,
|
||||
)
|
||||
|
||||
my_router = Router()
|
||||
|
||||
|
||||
@my_router.message(Command(commands=["start"]))
|
||||
async def command_start(message: Message, bot: Bot, base_url: str):
|
||||
await bot.set_chat_menu_button(
|
||||
chat_id=message.chat.id,
|
||||
menu_button=MenuButtonWebApp(text="Open Menu", web_app=WebAppInfo(url=f"{base_url}/demo")),
|
||||
)
|
||||
await message.answer("""Hi!\nSend me any type of message to start.\nOr just send /webview""")
|
||||
|
||||
|
||||
@my_router.message(Command(commands=["webview"]))
|
||||
async def command_webview(message: Message, base_url: str):
|
||||
await message.answer(
|
||||
"Good. Now you can try to send it via Webview",
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="Open Webview", web_app=WebAppInfo(url=f"{base_url}/demo")
|
||||
)
|
||||
]
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@my_router.message(~F.message.via_bot) # Echo to all messages except messages via bot
|
||||
async def echo_all(message: Message, base_url: str):
|
||||
await message.answer(
|
||||
"Test webview",
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[InlineKeyboardButton(text="Open", web_app=WebAppInfo(url=f"{base_url}/demo"))]
|
||||
]
|
||||
),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue