How to delete queue updates in telegram api?
Asked Answered
V

2

10

I'm trying to delete messages from /getUpdates in telegram API but I didn't know how.. I tried to use /deleteMessage

https://api.telegram.org/bot<TOKEN>/deleteMessage?chat_id=blahblah&message_id=BlahBlah

But it didn't delete message from API database..

Voluminous answered 23/5, 2020 at 18:13 Comment(0)
H
12

TL;DR: Call getUpdates() with the offset parameter set to the last message's id, incremented by 1


We'll need to let Telegram know which message's we've processed. To do this, set the offset parameter to the update_id + 1 of the last message your script has processed.

  1. Call getUpdates() to get the update_id of the latest message

    https://api.telegram.org/<MY-TOKEN>/getUpdates
    
    {
        "ok": true,
            "result": [
                {
                    "update_id": 343126593,   # <-- Remember / Save this id
                    "message": {
                    ...
    
  2. Increment the update_id by 1

  3. On the next getUpdates() call, set the offset parameter to the id:

    https://api.telegram.org/<MY-TOKEN>/getUpdates?offset=343126594
    

enter image description here

Headless answered 23/5, 2020 at 23:15 Comment(1)
Yep !, thanks but actually in the next time it should be offset + 1Voluminous
J
4

To delete all messages find update id of last message of the queue..

enter image description here

here "836737487", so run on browser

"https://api.telegram.org/bot<token>/getupdates?offset=836737488"

[note: offset integer value will be higher than update_id of last message]

and if you want to delete specific message then set offset value as update_id of the next message of that specific message

Jive answered 2/1, 2022 at 15:40 Comment(1)
This helped me, while offsetting messageId didn't, thanks!Filtrate

© 2022 - 2024 — McMap. All rights reserved.