【问题标题】:Python Telegram Bot. Get message to which given message repliesPython电报机器人。获取给定消息回复的消息
【发布时间】:2020-08-01 22:29:44
【问题描述】:

我想开发一个 Telegram 机器人,用作书签系统。它应该处理回复其他消息的命令。实例:

我使用python-telegram-bot 进行开发,似乎无法看到/important 回复的消息。我找到了Update.message.reply_to_message 对象,该对象仅在用户回复来自机器人本身的消息时才有效。

def important_handler(update: Update, context: CallbackContext):
    reply_to_message = update.message.reply_to_message
    if reply_to_message is None:
        logger.error('reply_to_message is None. But it shouldn\'t.')
        update.message.reply_text('There is no message attached. Try again.')
        return
    # ... business logic

有没有办法为所有回复获取reply_to_message 属性(或替代方法)?感谢您的建议;)

【问题讨论】:

  • 这似乎不是真的。无论原始消息是否由机器人发送,reply_to_message 似乎都会触发。

标签: python bots telegram


【解决方案1】:

我遇到了同样的问题。它仅在用户回复机器人时才有效。我的问题是机器人启用了Privacy Mode。一旦我通过/setprivacy 使用Botfather 禁用它,然后它就起作用了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    • 2017-03-19
    • 2017-07-17
    • 2021-09-09
    • 2021-09-14
    相关资源
    最近更新 更多