This commit is contained in:
1 parent
bc32432808
commit
12bedd5de7
11 files changed
+303
-4
No files matched your search
@@ -0,0 +1,22 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{path::Path, sync::OnceLock};
|
||||
|
||||
static CONFIG: OnceLock<Config> = OnceLock::new();
|
||||
pub fn get_config() -> &'static Config {
|
||||
CONFIG.get_or_init(|| {
|
||||
toml::from_str(&std::fs::read_to_string(Path::new("config.toml")).expect("无法读配置文件"))
|
||||
.expect("解析配置文件时发生错误")
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
pub matrix: Option<MatrixBot>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct MatrixBot {
|
||||
pub home_server: String,
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
}
|
||||
Reference in new issue
Block a user