【发布时间】:2021-07-13 16:32:27
【问题描述】:
我正在尝试使用python-telegram-bot 开发一个聊天机器人。
假设它的功能之一包括提取发送消息的用户的用户名和已使用命令回复消息的用户的用户名。
根据文档,一旦我们的应用收到Update 对象,它应该包含属性reply_to_message,这将使任务像下面的sn-p 一样简单:
# The callback which will handle the command
def extract(self, update, context):
if update.message.reply_to_message.from_user.username == 'bot_username':
update.message.reply_text("Something")
else:
target = update.message.reply_to_message.from_user.username
user= update.message.from_user.username
如果我没有被误导,如果我们从 Bot Father 关闭了 \setprivacy 设置,这应该可以工作,但如果我回复由bot 而不是回复普通用户。
我哪里错了?任何帮助是极大的赞赏。谢谢。
P.S - 这是我在社区中的第一个问题。我希望我清楚地解释了这个问题。
这个问题已经在Python Telegram Bot. Get message to which given message replies 提出,但解决方案没有解决问题,我没有必要的声誉在线程中进一步评论。
【问题讨论】:
标签: python telegram-bot