Проблема с WebApp telegram
Возникла такая проблема: отправляю пользователю WebApp через ReplyKeyboard - все окей, отправляю через InlineKeyboard - ответа не приходит.
Формально мне надо только Inline, просто изначально разбирался с Reply (ну брал готовый пример)
import asyncio
import logging
from aiogram import Bot, Dispatcher, types, Router, F
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode, ContentType
from aiogram.fsm.storage.memory import MemoryStorage
from aiogram.types import KeyboardButton, InlineKeyboardButton
from aiogram.utils.keyboard import ReplyKeyboardBuilder, InlineKeyboardBuilder
router = Router()
API_TOKEN = ''
@router.message(F.text == '/inline')
async def send_welcome(message: types.Message):
webAppInfo = types.WebAppInfo(url="https://yarik1811.github.io/test_page.github.io/")
builder = InlineKeyboardBuilder()
builder.add(InlineKeyboardButton(text='Отправить данные', web_app=webAppInfo))
await message.answer(text='Привет!', reply_markup=builder.as_markup())
@router.message(F.text == '/reply')
async def send_welcome(message: types.Message):
webAppInfo = types.WebAppInfo(url="https://yarik1811.github.io/test_page.github.io/")
builder = ReplyKeyboardBuilder()
builder.add(KeyboardButton(text='Отправить данные', web_app=webAppInfo))
await message.answer(text='Привет!', reply_markup=builder.as_markup())
@router.message(F.content_type == ContentType.WEB_APP_DATA)
async def handle_web_app(message: types.Message):
selected_date = message.web_app_data.data
await message.answer(f"Вы выбрали дату: {selected_date}")
@router.message(F.content_type == ContentType.WEB_APP_DATA)
async def handle_web_app(callback_query: types.CallbackQuery):
selected_date = callback_query.web_app_data.data
await callback_query.message.answer(f"Вы выбрали дату: {selected_date}")
async def main() -> None:
bot = Bot(token=API_TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
dp = Dispatcher(storage=MemoryStorage())
dp.include_router(router)
await dp.start_polling(bot)
if __name__ == "__main__":
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
asyncio.run(main())