Thanks to visit codestin.com
Credit goes to github.com

Skip to content

From error state to other state on a Conversational bot #2277

@paulthemagno

Description

@paulthemagno

I have a ConversationHandler with an error function like this:

def error(update, context):
    logger.print_log("got the error:" + str(context.error))

My bot is like this:

updater = Updater(token,use_context=True)
dp = updater.dispatcher
conv_handler = ConversationHandler(
        entry_points=[CommandHandler('start', start)],
        states={
            
            STATE1:    [...],
            STATE2:  [...],
            ...
        },
        fallbacks=[CommandHandler('cancel', cancel)]
    )
dp.add_handler(conv_handler)
dp.add_error_handler(error)
updater.start_polling()
updater.idle()

I'm trying to treat error function like all the other states, but it seems not working. After the error the program remains in the same state where the error has occurred, but I want to go always to STATE2. How can I do?

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