TelegramBots icon indicating copy to clipboard operation
TelegramBots copied to clipboard

[BUG] #editMediaMessage does not work properly with "file_id" specified

Open link1107 opened this issue 2 years ago • 2 comments

Describe the bug Every time when I try to send an editMessageMedia I get "Error editing message text: [400] Bad Request: MEDIA_EMPTY)"

To Reproduce Steps to reproduce the behavior:

This error occures when I try to change photo in a photoMessage already sent by a bot previously:

InputMediaPhoto inputMediaPhoto = new InputMediaPhoto();
inputMediaPhoto.setMedia("AgACAgIAAxkBAAIlaWOZGQvBn2uHvqfTwVYHGD-ezlU5AAJgxzEbSojJSMNUFLrahKyaAQADAgADeAADLAQ");

EditMessageMedia editMessageMedia = new EditMessageMedia();
editMessageMedia.setMedia(inputMediaPhoto);
editMessageMedia.setReplyMarkup(null);
editMessageMedia.setMessageId(messageId);
editMessageMedia.setChatId(chatId);

try {
    telegramLongPollingBot.execute(editMessageMedia);
} catch (TelegramApiException e) {
    log.warn("Error while editing media of a message! (bot-username: " +
        telegramLongPollingBot.getBotUsername() + ", reason: " + e.getMessage() + ")") ;
}

Expected behavior Changes message's media (in my case - photo) to the one specified in inputMediaPhoto. Note: file_id is 100% correct.

link1107 avatar Dec 14 '22 00:12 link1107

Ok, the bug is that serMedia for some reason does not work properly with file_id of photos, uploaded to Telegram. #setMedia(String media) works properly only with a photo given by URL-string, however method description and API documentation says that specifying file_id is also permitted.

link1107 avatar Dec 17 '22 18:12 link1107

Hi, I had problem like this. Did you try get instance with constructor? I mean EditMessageMedia obj = new EditMessageMedia(arg1, agr2, . . .); or with builder EditMessageMedia obj = EditMessageMedia.builder().build();

thesardorbroo avatar Dec 26 '22 06:12 thesardorbroo