- Notifications
You must be signed in to change notification settings - Fork5.7k
Description
What kind of feature are you missing? Where do you notice a shortcoming of PTB?
I opened a similar issue some time ago, but it got closed because of my inactivity. I'm gonna try to open it up for discussion again, this time hoping to provide more details :)
In the current function-based way of making bots (which is the default way in the examples provided), it can get very complex and messy to make nested conversations.
Imagine a menu with a nested conversation for each button, and sometimes another nested conversation inside one of those. It gets quite confusing to find where each function is, and its hard to organize things in different files without running to circular import issues.
Describe the solution you'd like
I believe having a class calledConversation could help. It would basically be some kind of wrapper for all the functions of the conversation, plus its ConversationHandler.
Possible features and benefits:
- It could just get the arguments to ConversationHandler, and create the handler itself. So more concise and readable code.
- It could include a place to keep all the state keys for that specific conversation, so you dont have to have a million keys for different convos jumbled up. they would be both organized and easy to find.
- It could have a name or id attribute, and could add that to the beginning of every state key, making all the keys unique and less prone to mixups.
- it could have predefined state keys, which would remove the hassle of thinking about state key names.(e.g key1,key2, etc) Because its in a class, they would be organized. and if you use the name/id idea above, they would also be unique.
- it would provide a structure for nested conversations.
- With some more work, it could be a blackbox for creating nested conversations with ease, just by defining the functions, the handlers and being done.
I think this could potentially be time-consuming (depending on how big one would go for it) and might need some things to change in the library, because it's kinda different from how ptb is currently set up. But if implemented, it could help a lot for making nested conversations.
Describe alternatives you've considered
No response
Additional context
Maybe people are already using ptb conversations within classes, I dont know. but if that's the way everyone does it, then the examples should reflect that. In any case, I think ptb could benefit from being more class-friendly in nested conversations :)