首页 > 解决方案 > 使用 python 的电报机器人:嵌套对话中无法识别 map_to_parent 状态

问题描述

我的子 convo 不会转移到父 convo。似乎 map_to_parent 中的键没有被识别?它只是在子 convo 结束后停止。我在这里做错了什么?

我也收到此警告:

UserWarning: Handler returned state methodchoiceend which is unknown to the ConversationHandler.

这是一个 mwe:https ://pastebin.com/pnve9gke

标签: pythontelegram-botpython-telegram-bot

解决方案


我在您链接的示例中看到两个问题:

  1. 两者method_convo_handlercount_convo都用作另一个中的嵌套对话,ConversationHandler 通过dispatch.add_handler. 这必然会相互影响。
  2. return METHODCHOICEEND用于done_method,而后者又用于 count_convocount_convo没有map_to_parent

顺便说一句,如果你ConversationHandlers通过相应的参数给你的名字,你提到的警告将阅读

Handler returned state methodchoiceend which is unknown to the ConversationHandler <name>.

使它更容易调试:)


免责声明:我目前是python-telegram-bot


推荐阅读