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
Several ideas for changes and/or additions have been gathered in the v14 project, mentioned in the user group or issues or dwelled in the back of my head. So I'm writing this issue to keep track of them better.
The following list of ideas should be discussed before release of v14 because at least some of them are easier to implement if we do them non-backwards compatible. I'd like to emphasize that most of these are very rough first thoughts and I'm fully aware that we may scrape many of them.
Make CH.fallbacks optional. I've seen a lot of people (including me) setting at to an empty list for some use cases … Poolitzer already expressed support for this idea
ConverstanionHandler + run_async: Problem is that we can't persist futures/promises. But we should be able to guarantee that all futures are done on (clean) shutdown. One could add something like BasePersistence.resolve_conversation_promises that persistence classes can call before flushing on shutdown. This already get's handled on v20
add a "prefallbacks" list, i.e. the state-handlers only trigger, if the "prefallback" handlers don't trigger. The current alternative is to add those handlers to the fallbacks list, which requires to make all state handlers ignore updates that should be handled by the fallbacks. see also Added impementation of "prefallbacks" list. #2764#2764; Implemented "prefallbacks" feature #2960
Include entry_points, fallbacks (and eventual "prefallbacks") into the states dict. We already have special states for TIMEOUT and WAITING, so I think it would make the interface cleaner if we used special states (PRE)FALLBACK and END as keys for these lists rather than making them standalone kwargs of __init__
Rethink which parts of ConversationHandler we consider public.
e.g. the conversations is currently public, although undocumented and basically part of the internals. If we make it private, we can rework the setters of persistence and conversations to something like get_persisted_data(persistence) or initialize_persistence(persistence)
We also rather regularly get questions like "how do I access the current state of the conversation" and "how do I check if a user has an active conversation". Making the logic of how the keys are build and how conversations works public may help with some of these and also with the above context.conversation_data
One could take this one step further and let the user customize how the key is generated. This could be useful e.g. in situations where one wants to handle 3rd-party updates (e.g. login into an external service) within the conversation, which are not of type telegram.Update. see also ConversationHandler do not support per_message_thread_id conversations #4768 for a request to make the CH state per message thread ID
think about conversation_timeout:
Is it worth to allow timeout handlers to put the conversation in a non-end state?
it it worth to try & allow a different timeout duration per state?
Can we make them work for nested conversations?
Can we ensure that the timeout jobs can be persisted?
Check behavior of the WATING state, especially with nested conversations
Check behavior of async handlers with nested conversations
Once a child conversation has started one may want the next update to be processed exclusively by that child conversation, even if it's not the first handler in the state. Maybe this can be made possible. See also https://stackoverflow.com/questions/78143788
Think about a mechanism to lazy-load persisted conversation states to allow to reduce load on startup. would be especially useful for stateless server designs. See here for some initial discussion. Note also that in stateless setups, a refresh_conversation_data would be useful, see [QUESTION] How to work with persistent conversation data across multiple processes #4452.
When the conversation has ended, pass CH.END to persistence.update_conversation instead of None
We currently issue a warning for per_message=True, per_chat=False - this is not necessarily valid in case inline_message_ids are used
entry_points should be checked after the states are checked - that way, state handlers may trigger before any entry_points trigger via allow_reentry. See https://t.me/pythontelegrambotgroup/606782?thread=606781 for a question on that. Edit: On second thought, the allow_reentry may not be needed at all - the user can just repeat the entry_points in the fallbacks. If "prefallbacks" (see above) are added, that even allows the user to customize which of state handlers and entry_points are checked first
A commonly requested feature is to track a "conversation" between two (or more) users who each chat with the bot in the respective private chat. If we could make something like this feasible, that would be awesome.
Several ideas for changes and/or additions have been gathered in the v14 project, mentioned in the user group or issues or dwelled in the back of my head. So I'm writing this issue to keep track of them better.
The following list of ideas should be discussed before release of v14 because at least some of them are easier to implement if we do them non-backwards compatible. I'd like to emphasize that most of these are very rough first thoughts and I'm fully aware that we may scrape many of them.
Related: #2802
CH.fallbacksoptional. I've seen a lot of people (including me) setting at to an empty list for some use cases … Poolitzer already expressed support for this ideaConverstanionHandler + run_async: Problem is that we can't persist futures/promises. But we should be able to guarantee that all futures are done on (clean) shutdown. One could add something likeThis already get's handled on v20BasePersistence.resolve_conversation_promisesthat persistence classes can call before flushing on shutdown.fallbackslist, which requires to make all state handlers ignore updates that should be handled by thefallbacks. see also Added impementation of "prefallbacks" list. #2764 #2764; Implemented "prefallbacks" feature #2960entry_points,fallbacks(and eventual "prefallbacks") into thestatesdict. We already have special states forTIMEOUTandWAITING, so I think it would make the interface cleaner if we used special states(PRE)FALLBACKandENDas keys for these lists rather than making them standalone kwargs of__init__context.conversation_data. It should be an object unique per conversation key andConversationHandlerinstance. It may even be automatically deleted when the conversation ends . See also [FEATURE] Have per-conversation data (or at least an identifier) in ConversationHandler #4136ConversationHandlerwe consider public.conversationsis currently public, although undocumented and basically part of the internals. If we make it private, we can rework the setters ofpersistenceandconversationsto something likeget_persisted_data(persistence)orinitialize_persistence(persistence)conversationsworks public may help with some of these and also with the abovecontext.conversation_datatelegram.Update. see also ConversationHandler do not support per_message_thread_id conversations #4768 for a request to make the CH state per message thread IDconversation_timeout:WATINGstate, especially with nested conversationsrefresh_conversation_datawould be useful, see [QUESTION] How to work with persistent conversation data across multiple processes #4452.CH.ENDtopersistence.update_conversationinstead ofNoneper_message=True, per_chat=False- this is not necessarily valid in caseinline_message_idsare usedentry_pointsshould be checked after the states are checked - that way, state handlers may trigger before anyentry_pointstrigger viaallow_reentry. See https://t.me/pythontelegrambotgroup/606782?thread=606781 for a question on that. Edit: On second thought, theallow_reentrymay not be needed at all - the user can just repeat theentry_pointsin thefallbacks. If "prefallbacks" (see above) are added, that even allows the user to customize which of state handlers andentry_pointsare checked firstConversationHandler#3665 (closed only to track this here)ConversationHandler.stateshas a key -1 #3834