tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
2.94k stars 569 forks source link

InlineQueryResultArticle has broken link_preview_options #559

Open Sarisan opened 3 months ago

Sarisan commented 3 months ago

I have configured it to show preview above the text, but when I send the result in my telegram client (on any platform) it shows it below the text, and when I open the same chat on any device or client it shows it above the text.

When I pass a url of photo that has time tokens inside and when time expires the photo becomes unavailable and the url redirects to the image with text "expired", in InlineQueryResultArticle it always shows me the "expired" image. When I pass the exact url to link preview options of usual message (sendMessage) it shows me the correct photo.

levlam commented 3 months ago

There are no bugs with link_preview_options in Bot API. show_above_text works correctly in InlineQueryResultArticle. TDLib-based apps like Unigram or Telegram X immediately show the message correctly for the sender. Android app shows it correctly after the message is sent and the chat is reopened. Telegram Desktop shows it correctly after app restart. You can create an issue for specific app at https://bugs.telegram.org/.

in InlineQueryResultArticle it always shows me the "expired" image.

This is intended behavior. Content of URLs is cached for a long time. You can't expect Telegram to redownload all files sent by URLs all the time.

Sarisan commented 2 months ago

This is intended behavior. Content of URLs is cached for a long time. You can't expect Telegram to redownload all files sent by URLs all the time.

It seems you didn't get it right.

Static URL without "&expires=xxx"

https://github.com/tdlib/telegram-bot-api/assets/63128024/65b20b62-67b2-4ff9-b355-118a35e6c50a

Dynamic URL with "&expires=xxx" that changes each request

https://github.com/tdlib/telegram-bot-api/assets/63128024/537e8063-865a-479e-a4ee-0771d05c6b8c

Sankaku Channel refuses to show an image and redirects to "expired" if you change anything in the URL or if you have a bad User-Agent.

levlam commented 2 months ago

The photo is shown as received by Telegram from the specified URL.

Sarisan commented 2 months ago

So this is Telegram servers issue?

levlam commented 2 months ago

All photos are fetched from the specified URL by Telegram servers. But if the site returns "Expired link" to any request with Telegram's User-Agent, then there is no issue.

Sarisan commented 2 months ago

May there be a chance that telegram-bot-api edits link_preview_options URL when it's used in InlineQueryResult?

levlam commented 2 months ago

No, URL is passed exactly as provided to the server.