rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.68k stars 1.18k forks source link

A lot "Error editing message text: [400] Bad Request" #674

Closed eos1d3 closed 4 years ago

eos1d3 commented 4 years ago

I have a message with inlinekeyboard markup, and I keep editing it.

From time to time, I alway receive this warning. But in the inlinekeyboard makrup, I have a random number to ensure no duplicate edit message is sent. But I still receive up to 7 warnings at a time randomly. But for most of time, I may get only one warning.

From what I know, OKHttp client has auto retry enabled by default. link

I have no way to stop this error. Please check if it is from OKHttp. Thanks!

org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException: Error editing message text: [400] Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message

rubenlagus commented 4 years ago

This happens when you try to edit a message to the same message again (aka no changes are applied). You should be fine ignoring this error

eos1d3 commented 4 years ago

This is not the case. For every edit message, I do have a random number in the markup so that each edit message is different.

mattmalec commented 4 years ago

Yes, it absolutely is the case. You’re either updating the wrong message or not executing the correct EditMessageText.

GoStaRoff commented 4 years ago

Perhaps you are editing the message in the same text as it is. It helped me solve my problem :)

evakdev commented 2 years ago

I was editing the buttons' texts, and for some specific edits it worked and for some others it didnt. So I ended up just recreating a button object with the new text and replacing the old one. that solved the problem.

ffaauusstt commented 2 years ago

This problem already exists. And I think the reason is bad internet - when user clicks button, doesn't see any result, and clicks again and again. Later internet appears and you see all those beauties in a console )

ahror-isroilov commented 1 year ago

This happens when you try to edit a message to the same message again (aka no changes are applied). You should be fine ignoring this error

Hi. I have also have this problem. But you say that it should be fine to ignore this error. How can I handle telegram errors like this. Because in my program every error and exception is logged and I don't want to log unnecessary errors like this.

s4sh4w4lk3r commented 1 year ago

It happens to me when a user presses the keyboard button quickly several times that two requests for changing the same data come, which is why an exception appears. You can solve the problem by enclosing a block of code in try/catch or save the user id and the time of the last message, and if there is a small difference between them, then the request must be discarded, that is, the implementation of some timeout. TelegramBots, ASPNET MVC, .NET 7.0