29 lines
581 B
Rust
29 lines
581 B
Rust
use std::env;
|
|
use toml;
|
|
use std::fs;
|
|
use serde::Deserialize;
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
struct Config {
|
|
discord_webhook_url: String,
|
|
}
|
|
|
|
fn get_full_config() -> Option<Config> {
|
|
if let Ok(config) = fs::read_to_string("config.toml") {
|
|
return toml::from_str(&config).unwrap_or(None);
|
|
}
|
|
None
|
|
}
|
|
|
|
pub fn get_discord_webhook_url() -> Option<String> {
|
|
if let Ok(url) = env::var("DISCORD_WEBHOOK_URL") {
|
|
return Some(url);
|
|
}
|
|
|
|
if let Some(config) = get_full_config() {
|
|
return Some(config.discord_webhook_url);
|
|
}
|
|
|
|
return None;
|
|
}
|