Telegram Bot API error when try to edit message: "Bad Request: message not found"
Asked Answered
H

3

20

I've tried to edit bot's message which was sended about 2 hours ago and got this error and supposed that this message so old for editing that it is unable. Then I've tried to edit another message which was sended a little later and it was successful. But after this I've tried to edit one of recently sended messages an got this error one more time. Now it seems like request's results is random.

What does it mean?

Here an example of my POST query:

https://api.telegram.org/bot{token}/editMessageText?chat_id=12345&message_id=370&text=New text

And here result:

{
  "ok": false,
  "error_code": 400,
  "description": "Bad Request: message not found"
}
Heliacal answered 29/12, 2016 at 5:42 Comment(7)
You should provide more details e.g.sample API call and respond.Lueck
Not sure if it will work, but try to provide message_id without chat_id.Hezekiah
@Hezekiah message_id is unique in chat area only I thinkHeliacal
You will know for sure only after try. Or I can try to analyze all my telegram bot logs, but it will take a while. Just make a try and let me know.Hezekiah
Had checked by my own: chat_id + message_id is needed. But message_id increments the same counter even in different chats. Also tried several times to edit message with no issues...Hezekiah
From Telegram Bot Support: "That error is usually raised when your bot didn't send the message you are trying to edit" That's the feedback I got on this question, I can't find any other reason why this would happen.Canon
@CharlesOkwuagwu thanks for your investigation but message has been exactly sent and sent exactly by bot. And it's happened not once.Heliacal
M
15

That's because the message you are trying to edit is not send by the bot.

I had this problem too. In my case I was trying to edit some posts on a channel which were sent by three admins; two human admins and a bot.

The bot can only edit its own messages.

The time limit for edit is only for human users.

bots can edit their own messages anytime.

Melissa answered 3/3, 2017 at 12:45 Comment(2)
is there anyway to edit all messages from all admins?Agathy
As far as I know, you cannot edit other admins' messages. Also human admins cannot edit other human admins' messages. This was my own problem when I tried to delete other admins' messages using bot and I found an API that supports this. I suggest you to search online and see whether there is an API that supports editing or not. But I think it's not possible.Melissa
F
4

The time limit is 48 hours source

You will get this error code under either a deleted message, or one that has gone past the expiration time.

I haven't played with the Telegraph API in a while, but I did remember seeing some inconsistent behavior as you mentioned. I had to end up implementing retry logic on my API calls to get around it.

You could experiment manually first, to see if it's something that would help you. I don't know if they've addressed the issues I encountered in the past, but retrying did help me.

Fleur answered 6/1, 2017 at 6:35 Comment(2)
please note that one message has different results of edit action time to time, mentioned this in the questionHeliacal
Edit message time limit is only valid for normal users. Bots aren't affected by such a limit.Fecund
U
2

The editMessageText method throws an error if reply_markup was defined in the message

Unfix answered 17/1, 2023 at 23:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.