• TypeError: event_list() missing 1 required positional argument: 'call_data" aiogram при использовании CallbackFactory?

    @maximq
    QA Engineer
    Переименуйте позиционный аргумент в callback_data
    Пример из документации:
    class Action(str, Enum):
        ban = "ban"
        kick = "kick"
        warn = "warn"
    
    class AdminAction(CallbackData, prefix="adm"):
        action: Action
        chat_id: int
        user_id: int
    
    ...
    # Inside handler
    builder = InlineKeyboardBuilder()
    for action in Action:
        builder.button(
            text=action.value.title(),
            callback_data=AdminAction(action=action, chat_id=chat_id, user_id=user_id),
        )
    await bot.send_message(
        chat_id=admins_chat,
        text=f"What do you want to do with {html.quote(name)}",
        reply_markup=builder.as_markup(),
    )
    ...
    
    @router.callback_query(AdminAction.filter(F.action == Action.ban))
    async def ban_user(query: CallbackQuery, callback_data: AdminAction, bot: Bot):
        await bot.ban_chat_member(
            chat_id=callback_data.chat_id,
            user_id=callback_data.user_id,
            ...
        )
    Ответ написан
    Комментировать