英文:
How to add both image and title while answering to an inline query?
问题
I understand your instructions. Here is the translated text:
我正在使用Telethon库制作我的Telegram机器人,但我在如何在内联查询处理程序中同时添加图像和标题方面遇到了困难。
我目前使用以下代码:
await event.answer([builder.photo(path_to_local_jpeg_file, text='文本', include_media=False)])
它可以正常使用我的jpeg文件,但当我进行内联查询时,它显示为“无标题”。一个看似合理的属性title
是无效的。
英文:
I am using the telethon library for my telegram bot, and I am struggling with how to add both image and title in an inline query handler.
Right now I am using the following code:
await event.answer([builder.photo(path_to_local_jpeg_file, text='text', include_media=False)])
It works fine with my jpeg file, but when I make the inline query it is marked as "Untitled". An attribute title
, which would seem logical, is invalid.
答案1
得分: 0
以下是翻译好的部分:
这是解决方案。JPEG 文件必须存储在外部。
photo = types.InputWebDocument(
url=url,
size=0,
mime_type="image/jpeg",
attributes=[],
)
title = "title"
await event.answer([
builder.article(title, text=title, thumb=photo, content=photo)
])
英文:
Here is the solution. The jpeg file has to stored externally.
photo = types.InputWebDocument(
url=url,
size=0,
mime_type="image/jpeg",
attributes=[],
)
title = "title"
await event.answer([
builder.article(title, text=title, thumb=photo, content=photo)
])
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论