Python电报机器人-如何更新我的机器人发送的最后一条消息的文本
我正在使用python电报机器人(python telegram bot.org)与来自Python3的电报进行通信 我想更新我上次发送的回复。 目前,下面的代码发送消息,然后发送 5秒后,另一条消息Python电报机器人-如何更新我的机器人发送的最后一条消息的文本,python,python-telegram-bot,Python,Python Telegram Bot,我正在使用python电报机器人(python telegram bot.org)与来自Python3的电报进行通信 我想更新我上次发送的回复。 目前,下面的代码发送消息,然后发送 5秒后,另一条消息 def echo(bot, update): update.message.reply_text("Sorry, you're on your own, kiddo.") time.sleep(5) update.message.reply_text("Seriously,
def echo(bot, update):
update.message.reply_text("Sorry, you're on your own, kiddo.")
time.sleep(5)
update.message.reply_text("Seriously, you're on your own, kiddo.")
我想更新最后一条消息
我试过了
bot.editMessageText("Seriously, you're on your own, kiddo.",
chat_id=update.message.chat_id,
message_id=update.message.message_id)
在示例中,它可以用消息更新或替换内联键盘,但会崩溃(并且不会更新我作为bot发送的最后一条消息)。我认为
edit\u message\u text()
中的参数顺序是错误的。检查一下:
def echo(bot, update):
# Any send_* methods return the sent message object
msg = update.message.reply_text("Sorry, you're on your own, kiddo.")
time.sleep(5)
# you can explicitly enter the details
bot.edit_message_text(chat_id=update.message.chat_id,
message_id=msg.message_id,
text="Seriously, you're on your own, kiddo.")
# or use the shortcut (which pre-enters the chat_id and message_id behind)
msg.edit_text("Seriously, you're on your own, kiddo.")
快捷方式
消息的文档。编辑文本()
是。谢谢。我会试试这个并评论成功。你成功了吗@576i