Troubles sending image in inline mode.
Please answer these questions before submitting your issue. Thanks!
- What version of pyTelegramBotAPI are you using? 4.6.0
- What OS are you using? Mac Os
- What version of python are you using? 3.7.11
Hello, I'm using inline bot and trying to print a photo, which is already on a telegram server. But when I pass it's file id
id = 'AgACAgIAAxkBAAIkc2LB6mYy0GnZBzKTXuxG_2qCaQAB2wACkr4xG8AuEEqrRCYAAUPEFEMBAAMCAANzAAMpBA'
to either InlineQueryResultCachedPhoto like
types.InlineQueryResultCachedPhoto('2', photo_file_id=id, title='title', description='description', caption='caption')
or InlineQueryResultPhoto like
types.InlineQueryResultPhoto('2', photo_url=id, thumb_url=id, title='title', description='description', caption='caption')
I get "Untitled" instead of the description

But when I pass a random url from the web everything works as expected:
What should I do to fix this?
Can you please provide whole code to reproduce this issue?
@tb.inline_handler(lambda query: query.query)
async def query_text(inline_query):
r1 = types.InlineQueryResultArticle('1', 'Result', types.InputTextMessageContent('Result message.'))
r2 = types.InlineQueryResultArticle('2', 'Result2', types.InputTextMessageContent('Result message2.'))
id='AgACAgIAAxkBAAIkc2LB6mYy0GnZBzKTXuxG_2qCaQAB2wACkr4xG8AuEEqrRCYAAUPEFEMBAAMCAANzAAMpBA'
r3 = types.InlineQueryResultCachedPhoto('3', photo_file_id=id,
title='title', description='description', caption='caption')
await tb.answer_inline_query(inline_query.id, [r1, r3, r2], cache_time=0)
You should pass a title for InlineQueryResultArticle objects. https://core.telegram.org/bots/api#inlinequeryresultarticle
@coder2020official But if I pass a title to InlineQueryResultPhoto and a random url from the web everything works fine
@tb.inline_handler(lambda query: query.query)
async def query_text(inline_query):
r1 = types.InlineQueryResultArticle('1', 'Result', types.InputTextMessageContent('Result message.'))
r2 = types.InlineQueryResultArticle('2', 'Result2', types.InputTextMessageContent('Result message2.'))
url = 'https://kudago.com/media/images/event/1a/f1/1af1f99cdcfe824ddd8e9ffb14afde8b.jpg'
r3 = types.InlineQueryResultPhoto('3', photo_url=url, thumb_url=url,
title='title', description='description', caption='caption')
await tb.answer_inline_query(inline_query.id, [r1, r3, r2], cache_time=0)
I didn't get your issue. You should always pass title cuz it is not optional.
-You should always pass title cuz it is not optional. Yes, sure. -I didn't get your issue Don't you have "Untitled" passing id of a photo stored on the Telegram servers (not a random url from the web) to InlineQueryResultCachedPhoto? Do you get your title? Could you please show screens/code snippets with the photo id.
So you are having untitled title for random image from internet?
So you are having untitled title for random image from internet?
No. For a random image from internet everything is ok. I have untitled only for an image stored on the Telegram servers
Here is the output when i run your code. The title isn't displayed, only image is displayed.
Still struggling?
No, thanks a lot.
Here is the output when i run your code. The title isn't displayed, only image is displayed.
I'm faced the very same issue.
So in this particular example why the phot doesn't have neither title nor description regardless they were provided?
Why the behavior is not consistent among ResultPhoto and ResultCachedPhoto regardless the similar call attributes set
Can someone clarify the behavior please?
@BigDanTheOne What was your resolution on the subject?
Solution?