In Aiogram documentation section “Scenes Wizard” described how to register and handle scenes:
class QuizScene(Scene, state="quiz"):
"""
This class represents a scene for a quiz game.
It inherits from Scene class and is associated with the state "quiz".
It handles the logic and flow of the quiz game.
"""
quiz_router = Router(name=__name__)
# Add handler that initializes the scene
quiz_router.message.register(QuizScene.as_handler(), Command("quiz"))
The issue here is how to pass some data to the scene, for example I need to pass string variable to QuizScene class?
I’ve tried:
quiz_router = Router(name=__name__)
test = "TEST STRING"
# Add handler that initializes the scene
quiz_router.message.register(QuizScene(test).as_handler(), Command("quiz"))
Output error: AttributeError: ‘str’ object has no attribute ‘scene’
New contributor
user25239158 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.