1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::fs;
use std::path::Path;
use failure::Error;
use irc::client::data::Config as IrcConfig;
use serde::Deserialize;
#[derive(Deserialize)]
pub struct Config {
#[serde(flatten)]
pub irc_config: IrcConfig,
#[serde(flatten)]
pub bot_settings: NestorSettings,
}
#[derive(Deserialize)]
pub struct NestorSettings {
pub blacklisted_users: Vec<String>,
pub command_indicator: Vec<String>,
pub alias_depth: u32,
}
impl Config {
pub fn load(path: impl AsRef<Path>) -> Result<Self, Error> {
let conf = fs::read_to_string(path.as_ref())?;
let conf: Config = toml::de::from_str(&conf)?;
Ok(conf)
}
}