LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!

Home Page:https://docs.telethon.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

edit_message removes preview after url content removed from message, while official client doesn't.

NotExist opened this issue · comments

Code that causes the issue

(part including corrosponding components is omitted)

Step 1. I send the message with Full API because I need to enable invert_media but handy function (send_message) seems not supporting that (yet, right?).

msg = client(SendMessageRequest(client.get_input_entity(20******31), "https://a.long.and.meanless.cdn.domain/with/image_file_name.jpg\n[Check this awsome proj](https://github.com/LonamiWebs/Telethon)\nItsAmazing", reply_to=InputReplyToMessage(2), invert_media='True'))

Which will send the expected message, a "Large enough" preview from the image url I provide, and following content, message with link(created in markdown style) included.

Step 2. Get the last message I sent with

client.get_messages(20******31)[0]

since I have no idea how to deal with <telethon.tl.types.Updates object at 0x7f1fdd5123f0> instead of <telethon.tl.patched.Message object at 0x7f1fdd511b80> currently, and it does works in most case.
And edit the message with

client.edit_message(client.get_messages(20******31)[0], "[Check this awsome proj](https://github.com/LonamiWebs/Telethon)\nItsAmazing")    

Expected behavior

A big enough picture shown before the content in link preview style, source provided in url format. Followed by markdown content
message, *** With no url information *** in final version of content message.

Actual behavior

Check with desktop client and found the preview had been removed, only modified message left.

Traceback

No response

Telethon version

1.34.0

Python version

3.12.2

Operating system (including distribution name and version)

python3 docker image

Other details

I think it should be emphasized that it does work with similiar operation with desktop version client. I create preview with image url provided first and remove image url with edit, the preview is still there.
I assume it's because some data not passed between editing, but I can't figure out how and where it should happen.

If API should not work this way, please let me know, pointing a proper way is also more than welcome.
So if there's alternative way to achieve similiar result, like modding media/entities before send.

Checklist

  • The error is in the library's code, and not in my own.
  • I have searched for this issue before posting it and there isn't an open duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.

It used to be an error to pass the web media back to edit. Perhaps things are differemt now.

I would prefer to keep the current behaviour. You can use the raw API if you need something else.