Clear “pending_update_count” in Telegram Bot

后端 未结 5 1766
渐次进展
渐次进展 2021-01-04 05:44

I want to clear all pending_update_count in my bot!

The output of below command :

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


        
相关标签:
5条回答
  • 2021-01-04 06:04

    I think you have two options:

    1. set webhook that do nothing, just say 200 OK to telegram's servers. Telegram wiil send all updates to this url and the queque will be cleared.
    2. disable webhook and after it get updates by using getUpdates method, after it, turn on webhook again

    Update:

    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"}
    

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

    0 讨论(0)
  • 2021-01-04 06:07

    I solved is like this

    POST tg.api/bottoken/setWebhook to emtpy "url"
    POST tg.api/bottoken/getUpdates
    POST tg.api/bottoken/getUpdates with "offset" last update_id appeared before
    

    doing this serveral times

    POST tg.api/bottoken/getWebhookInfo
    

    had a look if all away.

    POST tg.api/bottoken/setWebhook with filled "url"
    
    0 讨论(0)
  • 2021-01-04 06:09

    For anyone looking at this in 2020 and beyond, the Telegram API now supports clearing the pending messages via a drop_pending_updates parameter in both setWebhook and deleteWebhook, as per the API documentation.

    0 讨论(0)
  • 2021-01-04 06:11

    i solve it by Change file access permissions file - set permissions file to 755

    and second increase memory limit in php.ini file

    0 讨论(0)
  • 2021-01-04 06:13

    Just add return 1; at the end of your hook method.

    Update:

    Commonly this happens because of queries delay with the database.

    0 讨论(0)
提交回复
热议问题