You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been writing telegram bots on aiogram for quite some time.
I like everything, but I don’t really like working with states. You have to write a lot of typical code.
You must describe the state model, and then write handlers for each item.
I believe that this can be implemented a little more convenient for developers
Possible solution
I believe that it is possible to write a wrapper over the existing state system that can process a state in one line
Alternatives
I know about state scenes in 3.x, but I want something a little different
Code example
# For example:# We init model with data types and other additional information(custom validators for users answers and other)classForm(StatesGroup):
name: str=State(custom_validator) # custom validator is a link to a function that returns a validator of the user's responseage: int=State(custom_validator)
@form_router.message(CommandStart())asyncdefcommand_start(message: Message, state: FSMContext) ->None:
name=awaitForm.name.process_state()
awaitmessage.answer(f"Your name is {name}")
# After we work with user input value without typical code and boring work with states.
Additional information
If I'm wrong on some issues, please correct me, this is my first micro contribution to open source, sorry if something is wrong
The text was updated successfully, but these errors were encountered:
Oh, i see "alternative" section in your message, i dont think so this is a god idea (from the architecture side)
Yes, this may not be the best idea from the point of view of the architecture of the framework, but from the point of view of usability, there are many conveniences in this.
Can I try to develop this functionality and send it as a PR?
I can encapsulate this logic in a separate module, I think other core functionality will not suffer because of this
aiogram version
3.x
Problem
I've been writing telegram bots on aiogram for quite some time.
I like everything, but I don’t really like working with states. You have to write a lot of typical code.
You must describe the state model, and then write handlers for each item.
I believe that this can be implemented a little more convenient for developers
Possible solution
I believe that it is possible to write a wrapper over the existing state system that can process a state in one line
Alternatives
I know about state scenes in 3.x, but I want something a little different
Code example
Additional information
If I'm wrong on some issues, please correct me, this is my first micro contribution to open source, sorry if something is wrong
The text was updated successfully, but these errors were encountered: