如何在回答内联查询时同时添加图像和标题?

huangapple go评论69阅读模式
英文:

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)
    ])

huangapple
  • 本文由 发表于 2023年5月21日 08:55:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76297883.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定