This commit is contained in:
:NoBody: committed 2026-03-21 23:32:01 +08:00
1 parent bc32432808
commit 12bedd5de7
11 files changed
+303 -4

No files matched your search

+22
View File
@@ -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,
}