Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FEATURE] add ConversationHandler state to CallbackContext #2331

@MrTsepa

Description

@MrTsepa

Is your feature request related to a problem? Please describe.

While usingConversationHandler there is no possibility to check which state a callback was triggered from.

In my case I have a bot for a group game and I have commands like/add_me,/remove_me which every user may trigger at any time during the game. I would like to update my internal state differently depending on which state the conversation is currently in.

Describe the solution you'd like

As a solution I'd like to see an additional field inCallbackContext, e.g.{"conversation_data": {"current_state": <MY_STATE>}}. This can be easily done by implementingcollect_additional_context method inConversationHandler class.

Describe alternatives you've considered

There are two ways to achieve what I need using current code:

  1. assuming I only has oneConversationHandler and it was added to dispatcher first, I can run

    context.dispatcher.handlers[0][0].conversations[(update.effective_chat.id,)]

    however this method is error-prone if i have many conversation handlers or I have nested ones.

  2. I can manually update context withconversation_data field, however this would require editing all of my callbacks and therefore also error-prone.

Additional context

N/A

I will be happy to make a PR if you find this useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp