Merge pull request #992 from Lymkwi/document-sendmediagroup-captions

Document the behavior of captions for media groups
This commit is contained in:
Waffle Maybe 2024-01-11 19:31:45 +00:00 committed by GitHub
commit d7f530bd6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Documentation regarding the way captions work for the official clients on `SendMediaGroup` ([PR 992](https://github.com/teloxide/teloxide/pull/992))
- Add `MessageToCopyNotFound` error to `teloxide::errors::ApiError` ([PR 917](https://github.com/teloxide/teloxide/pull/917))
- `Dispatcher::try_dispatch_with_listener` ([PR 913](https://github.com/teloxide/teloxide/pull/913))
- Missing Message::filter_* functions ([PR 982](https://github.com/teloxide/teloxide/pull/982)):

View file

@ -1118,8 +1118,8 @@ Schema(
names: ("sendMediaGroup", "SendMediaGroup", "send_media_group"),
return_ty: ArrayOf(RawTy("Message")),
doc: Doc(
md: "Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [Message]s that were sent is returned.",
md_links: {"Message": "https://core.telegram.org/bots/api#message"},
md: "Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [Message]s that were sent is returned.\n\n## Captions\n\nYou may want to set a \"global\" caption which renders in the message, underneath the set of media. However, global captions for a media group are not part of the Telegram API. They result from how the official clients (at least) render a media group where only one [InputMedia] has a caption set. That captioned [InputMedia] may be in any position of the group.\n\nIn order to set a \"global\" caption of a media group, set a caption for a single [InputMedia] in the group with the contents you wish to display underneath all media.\n\nIf multiple [InputMedia] have captions, including identical ones, the official clients will not render a global caption underneath the group. Each individual media will keep its own caption however, which can be shown by the client when viewing the media individually, or by separating the media in its own message (for example by forwarding a single media from the media group).",
md_links: {"Message": "https://core.telegram.org/bots/api#message", "InputMedia": "https://core.telegram.org/bots/api#input_media"},
),
tg_doc: "https://core.telegram.org/bots/api#sendmediagroup",
tg_category: "Available methods",

View file

@ -7,7 +7,16 @@ use crate::types::{InputMedia, Message, MessageId, Recipient, ThreadId};
impl_payload! {
/// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [`Message`]s that were sent is returned.
///
/// ## Captions
///
/// You may want to set a "global" caption which renders in the message, underneath the set of media. However, global captions for a media group are not part of the Telegram API. They result from how the official clients (at least) render a media group where only one [`InputMedia`] has a caption set. That captioned [`InputMedia`] may be in any position of the group.
///
/// In order to set a "global" caption of a media group, set a caption for a single [`InputMedia`] in the group with the contents you wish to display underneath all media.
///
/// If multiple [`InputMedia`] have captions, including identical ones, the official clients will not render a global caption underneath the group. Each individual media will keep its own caption however, which can be shown by the client when viewing the media individually, or by separating the media in its own message (for example by forwarding a single media from the media group).
///
/// [`Message`]: crate::types::Message
/// [`InputMedia`]: crate::types::InputMedia
#[derive(Debug, Clone, Serialize)]
pub SendMediaGroup (SendMediaGroupSetters) => Vec<Message> {
required {