微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从 Telegramm bot 发送带有照片的文本

如何解决如何从 Telegramm bot 发送带有照片的文本

我需要机器人在按下内嵌按钮时发送一条消息,其中包含指向照片和文本的链接。 此外,我需要在消息中显示标题、照片后以及消息末尾的文本。但结果现在,文本显示在消息中,并且照片在消息的末尾。 我需要做什么才能获得帖子开头的照片? 发送时,我使用send_message方法,解析模式为“HTML”。

@dp.callback_query_handler(lambda callback_query: True)
async def some_callback_handler(callback_query: types.CallbackQuery):
    if callback_query['data'] == 'info':
              text = '''One night,an armed man and woman break into his house,and his son,Blake,tackles one of them. Hutch is reluctant to intervene and allows the thieves to 
                        leave. The incident causes everyone to think he is a failure. Hutch contacts his 
                        half-brother Harry on a hidden radio in his office and explains that he held back 
                        because the burglars were desperate,scared,and using an unloaded gun.'''
              img_link = 'https://upload.wikimedia.org/wikipedia/en/c/c7/Nobody_2021_Film_Poster.jpeg'
              text = '<a href="' + img_link + '">poster</a>\n' + text
              await bot.send_message(chat_id=callback_query.message.chat.id,text=text)
   

我不能对标题字段中的文本使用 send_photo 方法,因为文本字段将超过 1024 个字符。

解决方法

只有你有那个sendPhoto方法,其他选项是同时发送照片和消息。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。