2020-08-26 21:09:50 +00:00
|
|
|
use chronicle_dicebot::bot::run_bot;
|
|
|
|
use chronicle_dicebot::bot::Config;
|
|
|
|
use std::fs;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
fn read_config<P: Into<PathBuf>>(config_path: P) -> Result<Config, Box<dyn std::error::Error>> {
|
|
|
|
let config_path = config_path.into();
|
|
|
|
let config = {
|
|
|
|
let contents = fs::read_to_string(&config_path)?;
|
|
|
|
toml::from_str(&contents)?
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(config)
|
|
|
|
}
|
2020-04-17 05:20:54 +00:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
2020-04-17 22:53:27 +00:00
|
|
|
let config_path = std::env::args()
|
2020-04-17 05:25:13 +00:00
|
|
|
.skip(1)
|
|
|
|
.next()
|
2020-04-17 22:53:27 +00:00
|
|
|
.expect("Need a config as an argument");
|
2020-04-17 05:20:54 +00:00
|
|
|
|
2020-08-26 21:09:50 +00:00
|
|
|
let cfg = read_config(config_path)?;
|
2020-04-17 05:20:54 +00:00
|
|
|
|
2020-08-26 21:09:50 +00:00
|
|
|
run_bot(cfg.matrix).await?;
|
|
|
|
Ok(())
|
2020-04-17 05:20:54 +00:00
|
|
|
}
|