vaegram 0.2.0

Telegram MTProto client library for users and bots
Documentation
use super::send_options::{SendOptions, send_builder, send_media};
use crate::Client;
use crate::session::transfer::Report;
use crate::types::messages_and_media::media_setters;
use crate::types::{FileSource, InputMedia, PeerRef};

/// Request built by [`Client::send_document`].
#[must_use = "a request does nothing until it is awaited"]
pub struct SendDocument<'a> {
    client: &'a Client,
    chat_id: PeerRef,
    media: InputMedia<'a>,
    options: SendOptions,
    progress: Option<Report<'a>>,
}

impl Client {
    /// Sends a file as a document.
    ///
    /// Call [`disable_content_type_detection`](SendDocument::disable_content_type_detection) to stop Telegram from
    /// detecting the content type. Awaiting the request uploads the file if needed and returns the sent
    /// [`crate::types::Message`].
    pub fn send_document<'a>(
        &'a self,
        chat_id: impl Into<PeerRef>,
        document: impl Into<FileSource<'a>>,
    ) -> SendDocument<'a> {
        let media = InputMedia::document(document);
        SendDocument { client: self, chat_id: chat_id.into(), media, options: SendOptions::default(), progress: None }
    }
}

media_setters!(SendDocument.media: caption thumb disable_content_type_detection file_name progress);
send_media!(SendDocument);