[英]How to implement countdown timer with PyTelegrambotAPI?
I'm trying to implement something "looks like" animated countdown in my telegram bot:我正在尝试在我的电报机器人中实现一些“看起来像”动画倒计时:
sent=bot.send_message(message.chat.id,'5')
time.sleep(1)
bot.edit_message_text('4',message.chat.id,sent.message_id)
time.sleep(1)
bot.edit_message_text('3',message.chat.id,sent.message_id)
time.sleep(1)
bot.edit_message_text('2',message.chat.id,sent.message_id)
time.sleep(1)
bot.edit_message_text('1',message.chat.id,sent.message_id)
time.sleep(1)
bot.edit_message_text('0',message.chat.id,sent.message_id)
Sometimes it works well, but sometimes I get the error:有时它运行良好,但有时我收到错误:
A request to the Telegram API was unsuccessful.
对 Telegram API 的请求未成功。 The server returned HTTP 400 Bad Request.
服务器返回 HTTP 400 错误请求。 Response body:error_code:400,description:"Bad Request: message is not modified
响应正文:error_code:400,描述:“错误请求:消息未修改
I personally don't recommend you to send requests to telegram so often in a small timespan.我个人不建议您在短时间内如此频繁地向电报发送请求。 You might end up with a time out for too many requests.
您可能会因请求过多而超时。 My two suggestions for you here:
我在这里给你的两个建议:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.