telegramdesktop / tdesktop

Telegram Desktop messaging app
https://desktop.telegram.org/
Other
25.27k stars 5.02k forks source link

Telegram desktop not displaying InlineQueryResultPhoto correctly #4580

Open mbasaglia opened 6 years ago

mbasaglia commented 6 years ago

Summary

I think recently there has been a regression that prevents photo results from inline bots from displaying correctly if photo_width and photo_height aren't provided (which are marked as optional in the API docs -- see https://core.telegram.org/bots/api#inlinequeryresultphoto). This used to work fine, and it work fine on the Android client so I believe it's a bug with the desktop client, it appears it isn't even trying to send a request to photo_url when width/height aren't given.

Steps to reproduce

  1. send a query to an inline bot that returns InlineQueryResultPhoto without specifying photo_width / photo_height

Expected behaviour

Client should GET the photo_url from the results and display them

Actual behaviour

Doesn't fetch not display the result

Configuration

Operating system: Ubuntu, bug happens on different versions

Version of Telegram Desktop: 1.2.17 I think the issue was there before the latest update, but was working a couple month ago

john-preston commented 6 years ago

@mbasaglia Can you provide a bot and his query for testing this?

mbasaglia commented 6 years ago

With @SomeDragonsBot foo bar my bot sends back

{"results":[{"photo_url":"https:\/\/dragon.best\/api\/some_dragons.jpg?what=foo%20bar","type":"photo","thumb_url":"https:\/\/dragon.best\/api\/some_dragons.jpg?what=foo%20bar","id":"1030832774479917668-0"}],"inline_query_id":"1030832774479917668","is_personal":"false"}

Note that after looking it on my phone it works on desktop too for that query (I assume because of caching)

mbasaglia commented 6 years ago

Now I've updated my bots to include the size to make them work on desktop, but I think this still needs to be fixed on the client side otherwise it isn't conforming to the bot API documentation.

mbasaglia commented 6 years ago

Note that even when the size is being sent, the telegram desktop client still acts weirdly: the previews are shown, but when you click on a result to send the image, it looks much smaller than it should be (only for the person sending it).

Then it shows correctly if you restart the client.

mbasaglia commented 6 years ago

And I've also noticed the inline previews often looks weird if the image background is transparent

mbasaglia commented 5 years ago

I think there has been a regression on this, now even with width/height set the result aren't fetched/displayed on telegram desktop (only cached results are shown, even if the bot disabled caching). On the Android client it still works as expected.

john-preston commented 5 years ago

@mbasaglia Please provide once again a bot and a query that do not work in tdesktop. Right now "@SomeDragonsBot foo bar" works fine for me.

mbasaglia commented 5 years ago

depends on caching, try a unique string as input, for example "@SomeDragonsBot hello123456" doesn't work for me

zefrof commented 5 years ago

I'd like to note I've also had this issue with my own bot. The bot is "@mtgtutorbot." Query works fine on mobile, but won't work on desktop (Win 10) if tried there first. I'm guessing it works on desktop after trying on mobile due to caching? Here are some queries I've tried:

The 2nd will work every time, but the first won't work until it's been attempted on mobile.

mbasaglia commented 5 years ago

This issue still persists, even if the bot responses have the correct size and no transparency, telegram desktop shows "no results" on inline bots returning images (but works for images already queried from a different client).

SpangleLabs commented 5 years ago

An update, as I also ran into this lately:

Either way, this seems to be a bug in telegram desktop, not a bug in python-telegram-bot. I've reported it to volunteer support, hopefully they'll log it

Kyle2142 commented 5 years ago

I would just like to chime in. My bot https://t.me/inlinepixivbot has the same problem, where only "cached" images viewed on another client will show on tdesktop. You can try the query "evergarden" or "Dr Stone" probably 25h after this comment. I am not quite sure what I configured the cache time as, sorry. If that fails, you're welcome to try any random words, to be honest. Most of them will have no results on tdesktop until some other client tries it This has been happening for at least a year, up to and including the animated stickers update

Kwentar commented 4 years ago

I have the same problem, can help to reproduce if needed (only in windows desktop client)

ReinhardtJ commented 4 years ago

I can confirm this as well: I have implemented an alternative to the @gif-Bot which uses the Tenor API instead of the Giphy one. It will always fetch 30 gif images (or as many as possible) and display them in the inline query as result.

Once you type @JonasReinhardtBot gif abc on the Desktop App (in my case Windows V1.9.14), you are not able to see all gifs appearing in the inline query result.

I debugged far enough to be able to confirm that all InlineQueryResultGifs are correctly being POSTed to the answerInlineQuery endpoint. And it also works on Telegram Web or Telegram for Android (V5.15.0)

This is the LOC where the query result is sent https://github.com/ReinhardtJ/ReinhardtBot/blob/3a73395c0fcd559e09706b9a02255264b9ea6b85/bot/inline/gif/gif.py#L44

ghost commented 4 years ago

I can also confirm this and it is very annoying. Only cached photos are shown on desktop, I have the same behavior as @joshcoales Setting the cache_time parameter to 0 or a different value does not change a thing. I'm running the windows client version 2.0.1

AlexMercier commented 4 years ago

Hello. Developer, please pay attention to this thread, coz I wrote special bot for demonstrating a bug InlineQueryResultPhoto from bot not show big images #7654 To reproduce a bug just type inline command @TestInlineMixedBot all it will show you 4 inline items but in Desktop App you can see only 3 items, photo item will be missing due bug. or type @TestInlineMixedBot test_url to see nothing instead of inline photo item. Note, all this command work as expected on mobile clients, bug only in Desktop

john-preston commented 4 years ago

@AlexMercier Thanks! I’ll look into that.

john-preston commented 4 years ago

@AlexMercier Right now I can't show photo results with unknown image sizes :( I receive this:

{ botInlineResult
  flags: 54 [INT],
  id: "item_2" [STRING],
  type: "photo" [STRING],
  title: "Wow" [STRING],
  description: "Test by url" [STRING],
  url: [ SKIPPED BY BIT 3 IN FIELD flags ],
  thumb: { webDocument
    url: "..." [STRING],
    access_hash: 8512069115367755530 [LONG],
    size: 0 [INT],
    mime_type: "image/jpeg" [STRING],
    attributes: [ vector<0x0> ],
  },
  content: { webDocument
    url: "..." [STRING],
    access_hash: 2751716971740100323 [LONG],
    size: 0 [INT],
    mime_type: "image/jpeg" [STRING],
    attributes: [ vector<0x0> ],
  },
  send_message: { botInlineMessageMediaAuto
    flags: 0 [INT],
    message: "" [STRING],
    entities: [ SKIPPED BY BIT 1 IN FIELD flags ],
    reply_markup: [ SKIPPED BY BIT 2 IN FIELD flags ],
  },
},

And I look for image size attributes in those webDocument-s, I don't find them and I ignore those results :(

mbasaglia commented 4 years ago

is that size attribute the file size or the image dimensions?

john-preston commented 4 years ago

@mbasaglia The image dimension. It is marked as optional in API :( Please check if everything works fine with the valid dimensions passed to the bot api. I'll try to fix the case without dimensions, although it won't work very well in my case :(

AlexMercier commented 4 years ago

Please check if everything works fine with the valid dimensions passed to the bot api.

I checked. it work fine with heigth and width passed

AlexMercier commented 4 years ago

it won't work very well in my case

But preview image work well if bot send item with type article and thumb_url field without sizes . you can test it @TestInlineMixedBot article_thumb 2020-04-22_162438

mbasaglia commented 4 years ago

For me it doesn't work even if I'm sending the size

AlexMercier commented 4 years ago

@mbasaglia you pass photo_widthand photo_heightfields? also when you sending sizes you must pass thumb_url parameter

mbasaglia commented 4 years ago

This is the kind of response I give back:

{
   "results":[
      {
         "photo_url":"https:\/\/dragon.best\/api\/some_dragons.jpg?what=this%20is%20broken",
         "type":"photo",
         "thumb_url":"https:\/\/dragon.best\/api\/some_dragons.jpg?what=this%20is%20broken",
         "photo_width":512,
         "photo_height":512,
         "id":"(result id)"
      }
   ],
   "inline_query_id":"(query id)",
   "cache_time":0,
   "is_personal":false
}

but it doesn't work

asundukov commented 3 years ago

adding width and height to InlineQueryResultPhoto helps me. Now it works correctly.

Aokromes commented 3 years ago

so, it's 3rd party bug and not telegram bug?

asundukov commented 3 years ago

it depends. Because these paramteres marked in documentation https://core.telegram.org/bots/api#inlinequeryresultphoto as Optional , but without them tdesktop cannot show these items. So need to change documentation or fix bug in tdesktop

stale[bot] commented 3 years ago

Hey there!

This issue will be automatically closed in 7 days if there would be no activity. We therefore assume that the user has lost interest or resolved the problem on their own.

Don't worry though; if this is an error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

mbasaglia commented 3 years ago

I don't think it has been fixed

SpangleLabs commented 3 years ago

So, apparently this problem doesn't happen if you use mtproto for the bot giving inline responses. So it's purely an interaction between the bot/web api and the telegram desktop client. Handy context to know, and a good way to avoid the issue for bot writers

Kyle2142 commented 3 years ago

So, apparently this problem doesn't happen if you use mtproto for the bot giving inline responses. So it's purely an interaction between the bot/web api and the telegram desktop client. Handy context to know, and a good way to avoid the issue for bot writers

https://github.com/telegramdesktop/tdesktop/issues/4580#issuecomment-508954213 My bot uses mtproto

EDIT: it seems to work now. Definitely didn't a few months ago EDIT 2: does NOT always work. :(

stale[bot] commented 3 years ago

Hey there!

This issue was inactive for a long time and will be automatically closed in 30 days if there isn't any further activity. We therefore assume that the user has lost interest or resolved the problem on their own.

Don't worry though; if this is an error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

Kyle2142 commented 3 years ago

Bump

On May 4, 2021 12:33:44 AM GMT+02:00, "stale[bot]" @.***> wrote:

Hey there!

This issue was inactive for a long time and will be automatically closed in 30 days if there isn't any further activity. We therefore assume that the user has lost interest or resolved the problem on their own.

Don't worry though; if this is an error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/telegramdesktop/tdesktop/issues/4580#issuecomment-831577050

MasterLogick commented 3 years ago

Reproduced this bug on Ubuntu 20.04. Telegram version 2.7.4

stale[bot] commented 2 years ago

Hey there!

This issue was inactive for a long time and will be automatically closed in 30 days if there isn't any further activity. We therefore assume that the user has lost interest or resolved the problem on their own.

Don't worry though; if this is an error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

Kyle2142 commented 2 years ago

Bump

RobinJ1995 commented 2 years ago

Seeing the same thing. Very annoying. Amazed this is still present after almost 4 years.

polisadov commented 2 years ago

Same issue on my plate! :(

Lukasss93 commented 2 years ago

Same issue here! Found the reason: telegram desktop doesn't support query strings. Your image url MUST end with .jpg 😥

Example: https://via.placeholder.com/300.jpg immagine

https://via.placeholder.com/300.jpg?text=hello immagine

Aokromes commented 2 years ago

soo. not telegram desktop bug?

Kyle2142 commented 2 years ago

It most definitely is a tdesktop bug/regression. As I mentioned further above/2 , you'll get this problem even if you bypass the bot API completely. It's hard to give exact reproduction steps because as soon as someone views those images on another client, they'll work on tdesktop

Lukasss93 commented 2 years ago

Ops, my bad, it's a telegram desktop bug. Tried on Telegram Android:

https://via.placeholder.com/300.jpg?text=hello immagine

john-preston commented 2 years ago

@Lukasss93 perhaps you can share your test bot with me (here or at https://t.me/preston) so I could debug this the same way myself.

john-preston commented 2 years ago

@Lukasss93 But I'm afraid this is not related to the GET query in the URL, just about unknown image size. Do you provide (optional by docs) image size to the bot API?

Lukasss93 commented 2 years ago

@Lukasss93 perhaps you can share your test bot with me (here or at https://t.me/preston) so I could debug this the same way myself.

I can't do it. This is a non-production test bot. It runs on my computer right now.

@Lukasss93 But I'm afraid this is not related to the GET query in the URL, just about unknown image size. Do you provide (optional by docs) image size to the bot API?

OMG, it works by providing the image size! https://via.placeholder.com/300.jpg?text=hello immagine

Anyway, this is still a problem because I want to use another image generator and I cannot predict the image size 😥 If I try to force the image size with random values, telegram show me a non-clickable gray square... https://example.anotherimage.generator/random-size.jpg?text=flow immagine

EDIT: ✅ Found the "real" problem:

Kyle2142 commented 2 years ago

It's neat and all that people are finding possible causes and/or workarounds but the fact of the matter is that the same query result loads perfectly on any other client.

Laiteux commented 1 year ago

I can confirm the bug (only on tdesktop), and can also confirm that setting both photo_width and photo_height fixes it.

RobinJ1995 commented 1 year ago

Nice find! I'd say that's definitely a bug though (as opposed to "not supported by the API") as this is a valid URL, and the mobile app supports this without any problem.

On Sun 12 Jun 2022, 12:15 AM Luca Patera, @.***> wrote:

Same issue here! Found the reason: the telegram bot API doesn't support query strings. Your image url MUST end with .jpg 😥

Example: https://via.placeholder.com/300.jpg [image: immagine] https://user-images.githubusercontent.com/4071613/173207862-c44a9718-ad09-4194-916b-532d423bcbef.png

https://via.placeholder.com/300.jpg?text=hello [image: immagine] https://user-images.githubusercontent.com/4071613/173207896-c06479d0-176e-4763-a523-05c2f8dd188e.png

— Reply to this email directly, view it on GitHub https://github.com/telegramdesktop/tdesktop/issues/4580#issuecomment-1153017009, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXSJF7XKROBEL4E55SK233VOUM2VANCNFSM4EZQZNEA . You are receiving this because you commented.Message ID: @.***>

ShingenPizza commented 1 year ago

hello, i have also encountered this bug recently, and only today i realized that the bot will show me the photo results only if i have cached the specific images beforehand by linking those images directly. i can also confirm also that the workaround method of supplying some alleged resolution also makes the images show up - even those uncached. just as others have mentioned, the same query/result works just fine on the web and android versions. of course if you attempt it there, it will start working on desktop too, because of the images having been cached.

it's clearly a bug. please fix. (not that i believe it will be done any time soon...)