I have the following ConversationHandler
conv_handler = ConversationHandler(
entry_points=[CommandHandler('entry' entry)],
states={
ONE: [MessageHandler(filters.TEXT, one)],
TWO: [MessageHandler(filters.TEXT, two)],
THREE: [CallbackQueryHandler(three)],
FOUR: [CallbackQueryHandler(four)]
},
fallbacks=[CommandHandler(Commands.CANCEL.value, cancel)],
)
I defined the states keys as follows: ONE, TWO, THREE, FOUR = range(4)
Entry function:
async def entry(update: Update, context: ContextTypes) -> int:
await update.message.reply_text("bla")
return ONE
ONE function:
async def one(update: Update, context: ContextTypes) -> int:
x = update.message.text
await update.message.reply_text("yes. bla.")
context.user_data["x"] = x
return TWO
TWO function:
async def two(update: Update, context: ContextTypes) -> int:
await update.message.reply_text("bla")
keyboard = [
['7', '8', '9'],
['4', '5', '6'],
['1', '2', '3'],
['0']
]
await update.message.reply_text("bla", reply_markup=InlineKeyboardMarkup(keyboard))
query = update.callback_query
await query.answer()
context.user_data["x"] = query.data
return THREE
The transition between the entry function to ONE works, but the next transition between ONE and TWO doesn't.
While debugging, when I am about to return ONE, the object self.map_to_parent
is None so I suppose there was somewhat of a parsing error (?) in the ConversationHandler but I can't find it.
Additional info:
- No errors displayed
- python-telegram-bot = "==20.0a1"
source https://stackoverflow.com/questions/73838709/conversationhandler-not-moving-to-the-next-state
Comments
Post a Comment