清除“pending_update_count"在电报机器人中 [英] Clear "pending_update_count" in Telegram Bot

查看:56
本文介绍了清除“pending_update_count"在电报机器人中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想清除我的机器人中的所有 pending_update_count

I want to clear all pending_update_count in my bot!

以下命令的输出:

https://api.telegram.org/botxxxxxxxxxxxxxxxx/getWebhookInfo

显然我用xxx替换了真实的API令牌

这是:

{
 "ok":true,"result":
    {
     "url":"",
     "has_custom_certificate":false,
     "pending_update_count":5154
    }
}

如你所见,我有 5154 个未读更新,直到现在!!(我很确定这个待处理的更新是错误的!因为没有人使用这个机器人!它只是一个测试机器人)

As you can see, I have 5154 unread updates til now!! ( I'm pretty sure this pending updates are errors! Because no one uses this Bot! It's just a test Bot)

顺便说一下,这个pending_update_count 数字增加的太快了!现在我写这篇文章的人数增加了 51 并达到了 5205 !

By the way, this pending_update_count number are increasing so fast! Now that I'm writing this post the number increased 51 and reached to 5205 !

我只想清除这个待处理的更新.我很确定这个 Bot 陷入了无限循环!

I just want to clear this pending updates. I'm pretty sure this Bot have been stuck in an infinite loop!

有什么办法可以摆脱它吗?

Is there any way to get rid of it?

附:

我也清除了 webhook url.但一切都没有改变!

I also cleared the webhook url. But nothing changed!

更新:

getWebhookInfo 的输出是这样的:

{
   "ok":true,
   "result":{
      "url":"https://somewhere.com/telegram/webhook",
      "has_custom_certificate":false,
      "pending_update_count":23,
      "last_error_date":1482910173,
      "last_error_message":"Wrong response from the webhook: 500 Internal Server Error",
      "max_connections":40
   }
}

为什么我收到 Webhook 的错误响应:500 Internal Server Error ?

推荐答案

我认为你有两个选择:

  1. 设置什么都不做的 webhook,只需对 Telegram 的服务器说 200 OK.Telegram 将向此 url 发送所有更新,队列将被清除.
  2. 禁用 webhook 并在使用 getUpdates 方法获取更新后,再次打开 webhook

更新:

您这边的 webhook 有问题.您可以尝试在您的 URL 上模拟电报的 POST 查询.它可以是这样的:

Problem with webhook on your side. You can try to emulate telegram's POST query on your URL. It can be something like this:

{"message_id":1,"from":{"id":1,"first_name":"FirstName","last_name":"LastName","username":"username"},"chat":{"id":1,"first_name":"FirstName","last_name":"LastName","username":"username","type":"private"},"date":1460957457,"text":"test message"}

例如,您可以使用 PostMan 将此文本作为 POST 查询正文发送,然后尝试调试您的后端.

You can send this text as a POST query body with PostMan for example, and after it try to debug your backend.

这篇关于清除“pending_update_count"在电报机器人中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆