0

I'm developing a Telegram bot that will send a text message, and then after a while will change it by adding an image to it. I use Pyrogram, here's the small snippet:

@app.on_message(filters.command(["start"]))
async def start(client, message):
    test_message = await message.reply_text("Hello World")
    await test_message.edit_media(
        InputMediaPhoto(media="./img/1.png")
    )

But it throws an error:

pyrogram.errors.exceptions.bad_request_400.MessageEmpty: Telegram says: [400 MESSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused by "messages.EditMessage")

Any help is greatly appreciated

UPD: I found out that it's impossible to add a picture to existing text-only message, but is there a workaround?

Denking
  • 31
  • 1
  • 4

1 Answers1

2

You cannot make a text message an image with a caption. That's a Telegram limitation. You could edit your message to add a link to an image to embed it.

Alternatively you could also delete the text message and then send an image as an entirely new message.

ColinShark
  • 1,047
  • 2
  • 10
  • 18