use crate::dispatcher::DispatcherBuilder;
use crate::error::BotResult;
use rustigram_api::{BotClient, ClientConfig};
pub struct Bot {
pub client: BotClient,
}
impl Bot {
pub fn new(token: impl Into<String>) -> BotResult<Self> {
let client = BotClient::from_token(token).map_err(crate::error::BotError::Api)?;
Ok(Self { client })
}
pub fn from_config(config: ClientConfig) -> BotResult<Self> {
let client = BotClient::new(config).map_err(crate::error::BotError::Api)?;
Ok(Self { client })
}
pub fn dispatcher(&self) -> DispatcherBuilder {
crate::dispatcher::Dispatcher::builder(self.client.clone())
}
}