Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

router.message(F.web_app_data) doesn't work #1414

Open
2 tasks done
iQiexie opened this issue Feb 13, 2024 · 0 comments
Open
2 tasks done

router.message(F.web_app_data) doesn't work #1414

iQiexie opened this issue Feb 13, 2024 · 0 comments
Labels
bug Something is wrong with the framework

Comments

@iQiexie
Copy link

iQiexie commented Feb 13, 2024

Checklist

  • I am sure the error is coming from aiogram code
  • I have searched in the issue tracker for similar bug reports, including closed ones

Operating system

Macos

Python version

3.10.3

aiogram version

3.3.0

Expected behavior

When i send data from webapp, telegram bot must answer "Test"

@router.message(F.web_app_data)
async def enter_date(message: Message) -> None:
    message.answer("Test")

It worked with the previous version (2.x)

@dp.message_handler(content_types="web_app_data")
async def enter_date(message: Message) -> None:
    message.answer("Test")

Current behavior

It doesn't answer "Test"

Steps to reproduce

  1. Send this keyboard to user
def get_calendar_keyboard() -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()
    builder.row(
        InlineKeyboardButton(
            text="Calender",
            web_app=WebAppInfo(
                url="https://shitposting.su/",
            ),
        )
    )

    return builder.as_markup(
        is_persistent=True,
        resize_keyboard=True,
    )
  1. Register the router
create_token_router = Router()

@router.message(F.web_app_data)
async def enter_date(message: Message) -> None:
    message.answer("Test")

Code example

import asyncio

from aiogram import Bot
from aiogram import Dispatcher
from aiogram import F
from aiogram import Router
from aiogram.filters import Command
from aiogram.types import InlineKeyboardButton
from aiogram.types import InlineKeyboardMarkup
from aiogram.types import Message
from aiogram.types import WebAppInfo
from aiogram.utils.keyboard import InlineKeyboardBuilder

router = Router()


def get_calendar_keyboard() -> InlineKeyboardMarkup:
    builder = InlineKeyboardBuilder()
    builder.row(
        InlineKeyboardButton(
            text="Calender",
            web_app=WebAppInfo(
                url="https://shitposting.su/",
            ),
        )
    )

    return builder.as_markup(
        is_persistent=True,
        resize_keyboard=True,
    )


@router.message(Command("start"))
async def enter_date(message: Message) -> None:
    await message.answer(
        text="Calendar",
        reply_markup=get_calendar_keyboard(),
    )


@router.message(F.web_app_data)
async def enter_date(message: Message) -> None:
    await message.answer("Test")


async def main():
    dispatcher = Dispatcher()
    dispatcher.include_router(router)
    await dispatcher.start_polling(
        Bot(token="enter token here"),
        allowed_updates=dispatcher.resolve_used_update_types(),
    )

asyncio.run(main())


### Logs

_No response_

### Additional information

_No response_
@iQiexie iQiexie added the bug Something is wrong with the framework label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is wrong with the framework
Projects
None yet
Development

No branches or pull requests

1 participant