如何发送带有标题/文本的电报媒体组 [英] How to send telegram mediaGroup with caption/text

查看:38
本文介绍了如何发送带有标题/文本的电报媒体组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用

因此该消息包含 2 张以上的照片/视频,下方带有文本消息.

我已经尝试过的:

  1. 使用发送消息send_message 方法,并包括照片 URL,但它只显示文本下方的 1 张图片

  2. 使用 send_media_group但是这个方法没有 caption 参数作为 send_photo.

解决方案

你应该使用 sendMediaGroup,您可以在其中使用 photomedia 字段a>/video 对象,但诀窍是设置 caption属性仅用于数组的第一个元素.在这种情况下,电报将在媒体内容下方显示该标题.

如果您为多个元素指定标题,则电报将仅在您分别单击每张照片的照片预览时显示.

I'm currently using python-telegram-bot and basically what I want to achieve with it is to send telegram messages like this:

So the message consists of 2+ photos/videos with text message underneath.

What I've already tried:

  1. sending message with send_message method, and including photo URLs, but it only shows 1 picture which is under the text

  2. sending media group using send_media_group, but this method has no caption parameter as send_photo.

解决方案

You should use sendMediaGroup, where you can specify media field with an array of photo/video objects but the trick is to set caption property only for the first element of an array. In this case telegram will show that caption below the media content.

If you'll specify captions for more than one element telegram will show them only when you click on photo preview for each photo separately.

这篇关于如何发送带有标题/文本的电报媒体组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆