19

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"
}
anatol
  • 1,680
  • 2
  • 24
  • 47
  • You should provide more details e.g.sample API call and respond. – Alireza Mohamadi Jan 02 '17 at 16:12
  • Not sure if it will work, but try to provide message_id without chat_id. – Vladimir Jan 05 '17 at 10:30
  • @Vladimir message_id is unique in chat area only I think – anatol Jan 05 '17 at 10:45
  • 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. – Vladimir Jan 05 '17 at 10:50
  • 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... – Vladimir Jan 05 '17 at 11:17
  • 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. – Charles Okwuagwu Jan 06 '17 at 12:04
  • 2
    @CharlesOkwuagwu thanks for your investigation but message has been exactly sent and sent exactly by bot. And it's happened not once. – anatol Jan 06 '17 at 12:22

3 Answers3

13

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.

Arad Alvand
  • 8,607
  • 10
  • 51
  • 71
Naser.Sadeghi
  • 1,341
  • 1
  • 12
  • 35
  • is there anyway to edit all messages from all admins? – Ebrahim Karimi Mar 15 '18 at 16:49
  • 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. – Naser.Sadeghi Mar 17 '18 at 17:35
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.

Lenny Markus
  • 3,398
  • 2
  • 24
  • 30
1

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

Lightman
  • 11
  • 1