This commit is contained in:
2024-03-09 03:42:11 +01:00
commit 3190049fd4
7 changed files with 2260 additions and 0 deletions

29
src/config.rs Normal file
View File

@@ -0,0 +1,29 @@
use once_cell::sync::Lazy;
fn get_env(env: &'static str) -> String {
std::env::var(env).unwrap_or_else(|_| panic!("Cannot get the {} env variable", env))
}
pub struct Config {
pub discord_bot_token: String,
pub discord_channel_id: u64,
pub telegram_bot_token: String,
pub telgram_channel_id: i128,
}
impl Config {
pub fn load() -> Config {
Config {
discord_bot_token: get_env("DISCORD_BOT_TOKEN"),
discord_channel_id: get_env("DISCORD_CHANNEL_ID").parse().unwrap(),
telegram_bot_token: get_env("TELEGRAM_BOT_TOKEN"),
telgram_channel_id: get_env("TELEGRAM_CHANNEL_ID").parse().unwrap(),
}
}
}
pub static CONFIG: Lazy<Config> = Lazy::new(Config::load);