pub struct InputMedia { /* private fields */ }
Expand description
Construct and send albums.
Implementations§
Source§impl InputMedia
impl InputMedia
Sourcepub fn fmt_entities(self, entities: Vec<MessageEntity>) -> Self
pub fn fmt_entities(self, entities: Vec<MessageEntity>) -> Self
The formatting entities within the caption (such as bold, italics, etc.).
Sourcepub fn reply_to(self, reply_to: Option<i32>) -> Self
pub fn reply_to(self, reply_to: Option<i32>) -> Self
The album identifier to which this album should reply to, if any.
Otherwise, this album will not be a reply to any other.
Only the reply_to from the first media is used.
Sourcepub fn photo(self, file: Uploaded) -> Self
pub fn photo(self, file: Uploaded) -> Self
Include the uploaded file as a photo in the album.
The Telegram server will compress the image and convert it to JPEG format if necessary.
The text will be the caption of the photo, which may be empty for no caption.
Sourcepub fn photo_url(self, url: impl Into<String>) -> Self
pub fn photo_url(self, url: impl Into<String>) -> Self
Include an external photo in the album.
The Telegram server will download and compress the image and convert it to JPEG format if necessary.
The text will be the caption of the photo, which may be empty for no caption.
Sourcepub fn document(self, file: Uploaded) -> Self
pub fn document(self, file: Uploaded) -> Self
Include the uploaded file as a document in the album.
You can use this to send videos, stickers, audios, or uncompressed photos.
The text will be the caption of the document, which may be empty for no caption.
Sourcepub fn thumbnail(self, thumb: Uploaded) -> Self
pub fn thumbnail(self, thumb: Uploaded) -> Self
Include the video file with thumb in the album.
The text will be the caption of the document, which may be empty for no caption.
§Examples
async fn f(client: &mut grammers_client::Client) -> Result<(), Box<dyn std::error::Error>> {
use grammers_client::{InputMedia};
let video = client.upload_file("video.mp4").await?;
let thumb = client.upload_file("thumb.png").await?;
let media = InputMedia::caption("").document(video).thumbnail(thumb);
Ok(())
}
Sourcepub fn document_url(self, url: impl Into<String>) -> Self
pub fn document_url(self, url: impl Into<String>) -> Self
Include an external file as a document in the album.
You can use this to send videos, stickers, audios, or uncompressed photos.
The Telegram server will be the one that downloads and includes the document as media.
The text will be the caption of the document, which may be empty for no caption.
Sourcepub fn attribute(self, attr: Attribute) -> Self
pub fn attribute(self, attr: Attribute) -> Self
Add additional attributes to the media.
This must be called after setting a file.
§Examples
use std::time::Duration;
use grammers_client::{types::Attribute, InputMedia};
let media = InputMedia::caption("").document(audio).attribute(
Attribute::Audio {
duration: Duration::new(123, 0),
title: Some("Hello".to_string()),
performer: Some("World".to_string()),
}
);
Sourcepub fn copy_media(self, media: &Media) -> Self
pub fn copy_media(self, media: &Media) -> Self
Copy media from an existing message.
You can use this to send media from another message without re-uploading it.
Sourcepub fn file(self, file: Uploaded) -> Self
pub fn file(self, file: Uploaded) -> Self
Include the uploaded file as a document file in the album.
You can use this to send any type of media as a simple document file.
The text will be the caption of the file, which may be empty for no caption.
Sourcepub fn media_ttl(self, seconds: i32) -> Self
pub fn media_ttl(self, seconds: i32) -> Self
Change the media’s Time To Live (TTL).
For example, this enables you to send a photo
that can only be viewed for a certain
amount of seconds before it expires.
Not all media supports this feature.
This method should be called before setting any media, else it won’t have any effect.
Sourcepub fn mime_type(self, mime_type: &str) -> Self
pub fn mime_type(self, mime_type: &str) -> Self
Change the media’s mime type.
This method will override the mime type that would otherwise be automatically inferred from the extension of the used file
If no mime type is set and it cannot be inferred, the mime type will be “application/octet-stream”.
This method should be called before setting any media, else it won’t have any effect.