我有一个对话处理程序,当我调用入口点 /practiceflashcard 时确实会触发该对话处理程序
但是当我写一条消息时,什么也没有发生,我希望进入 MessageHandler“guessing_word”
但是,奇怪的属性:当我再次调用 /practiceflashcard 时,我确实转到...消息处理程序
application.add_handler(ConversationHandler(
entry_points=[CommandHandler('practiceflashcard', practiceflashcard)],
states={
0: [MessageHandler(filters.TEXT, guessing_word)],
},
fallbacks=[]
))
以下是功能:
async def practiceflashcard(update, context):
async def send(m):
await context.bot.send_message(text=m, chat_id=update.effective_chat.id)
sample = [('Bonjour', 'Hello'), ('Ça va?', 'You good?')]
sentences = (x[0] for x in sample)
await send('\n'.join(map("- {}".format, sentences)))
context.user_data['sample'] = sample
return 0
async def guessing_word(update, context):
sample = context.user_data['sample']
async def send(m):
await context.bot.send_message(text=m, chat_id=update.effective_chat.id)
answers = [x[1] for x in sample]
await send('\n'.join(map("- {}".format, answers)))
context.user_data.clear()
return ConversationHandler.END
我的文本处理程序没有被调用,因为我的处理程序列表中有另一个之前添加的文本处理程序。因此只调用了这个。
有人建议我使用“add_handler”方法的“group”参数,以便将这些处理程序分为不同的组。