Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot update photo using local file and editMessageMedia #226

Open
trupizzza opened this issue Oct 19, 2021 · 2 comments
Open

Cannot update photo using local file and editMessageMedia #226

trupizzza opened this issue Oct 19, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@trupizzza
Copy link

trupizzza commented Oct 19, 2021

Expected behavior
I can replace existing message photo (sent by sendPhoto, using URL as path to media) with new photo from local source by using editMessageMedia function.

Actual behavior
I can add photo from local source using sendPhoto function.
Hovewer, when I try to reaplce photo using editMessageMedia function, I've got following error message:

{"ok":false,"error_code":400,"description":"Bad Request: can't parse InputMedia: media not found"}

The same function with photo from URL works well.

To Reproduce
Send any photo using sendPhoto, then try to use editMessageMedia with media paarameter points to local picture, ex:

bot.editMessageMedia(
            chatId = ChatId.fromId(chatId),
            messageId = messageId,
            media = InputMediaPhoto(TelegramFile.ByFile(File("somepic.jpg"))),
            replyMarkup = replyMarkup
        )
@trupizzza trupizzza added the bug Something isn't working label Oct 19, 2021
@trupizzza trupizzza changed the title Cannot update photo using local file and editMessageMEdia Cannot update photo using local file and editMessageMedia Oct 19, 2021
@shumkinn
Copy link

val photoForSend: TelegramFile = TelegramFile.ByUrl("url_example.jpg")
val inputPhoto = InputMediaPhoto(media = photoForSend)

               bot.editMessageMedia(
                    chatId = update.message?.chat?.id,
                    messageId = saveMsg,
                    media = inputPhoto,
                    replyMarkup = InlineKeyboardMarkup(listOf(listInlineButtons))
                )

Such a case also does not work for me, it gives the same error(

@a8t3r
Copy link

a8t3r commented Nov 30, 2023

Works with TelegramFile.ByFileId:

val photo = TelegramFile.ByFileId(imageFileId)
bot.editMessageMedia(
  media = InputMediaPhoto(photo, caption, MARKDOWN_V2.modeName)
  ...
)

UPD: https://core.telegram.org/bots/api#editmessagemedia

When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants