use crate::Client;
use crate::errors::Result;
use crate::raw::functions;
use crate::types::{BotInfo, PeerRef};
#[must_use = "a request does nothing until it is awaited"]
pub struct GetBotInfo<'a> {
client: &'a Client,
bot_id: PeerRef,
language_code: String,
}
impl Client {
pub fn get_bot_info(&self, bot_id: impl Into<PeerRef>) -> GetBotInfo<'_> {
GetBotInfo { client: self, bot_id: bot_id.into(), language_code: String::new() }
}
}
impl GetBotInfo<'_> {
pub fn language_code(mut self, language_code: impl Into<String>) -> Self {
self.language_code = language_code.into();
self
}
async fn send(self) -> Result<BotInfo> {
let bot = Some(self.client.resolve_user(&self.bot_id).await?);
let request = functions::bots::GetBotInfo { bot, lang_code: self.language_code };
Ok(BotInfo::parse(self.client.invoke(&request).await?))
}
}
into_future!(GetBotInfo, BotInfo);