Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"
}
like image 417
anatol Avatar asked Dec 29 '16 05:12

anatol


People also ask

Why is a bot not working on my Telegram?

Suggestions: Ensure the Bot is in the group and as an admin. Try adding a new access token (revoke existing API key and create a new one then replace in plugin settings) If you edited the bot with @BotFather, make sure to restore it to the default settings.

Can Telegram bots edit messages?

Only the inline bot can edit message.

How can I get telegram Bot API key?

Obtaining api_id Sign up for Telegram using any application. Log in to your Telegram core: https://my.telegram.org. Go to "API development tools" and fill out the form. You will get basic addresses as well as the api_id and api_hash parameters required for user authorization.

What is Error #400 in Telegram?

400 BAD_REQUESTThe query contains errors. In the event that a request was created using a form and contains user generated data, the user should be notified that the data must be corrected before the query is repeated.


2 Answers

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.

like image 136
Naser.Sadeghi Avatar answered Sep 22 '22 14:09

Naser.Sadeghi


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.

like image 35
Lenny Markus Avatar answered Sep 19 '22 14:09

Lenny Markus