vaegram 0.2.0

Telegram MTProto client library for users and bots
Documentation
use crate::Client;
use crate::errors::Result;
use crate::raw::{base, functions};

/// Request built by [`Client::get_bot_description`].
#[must_use = "a request does nothing until it is awaited"]
pub struct GetBotDescription<'a> {
    client: &'a Client,
    language_code: String,
}

impl Client {
    /// Returns this bot's default description, the one users of a language without its own see.
    ///
    /// [`language_code`](GetBotDescription::language_code) returns the one for a language instead.
    pub fn get_bot_description(&self) -> GetBotDescription<'_> {
        GetBotDescription { client: self, language_code: String::new() }
    }
}

impl GetBotDescription<'_> {
    /// Returns the description set for users with this two-letter language code.
    pub fn language_code(mut self, language_code: impl Into<String>) -> Self {
        self.language_code = language_code.into();
        self
    }

    async fn send(self) -> Result<String> {
        let request = functions::bots::GetBotInfo { bot: None, lang_code: self.language_code };
        let base::bots::BotInfo::BotInfo(info) = self.client.invoke(&request).await?;
        Ok(info.description)
    }
}

into_future!(GetBotDescription, String);