mirror of
https://github.com/flibusta-apps/telegram_files_server.git
synced 2026-03-03 23:20:54 +01:00
35
src/config.rs
Normal file
35
src/config.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
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 api_key: String,
|
||||
|
||||
pub telegram_api_url: String,
|
||||
pub telegram_chat_id: i64,
|
||||
pub telegram_temp_chat_id: i64,
|
||||
pub bot_tokens: Vec<String>,
|
||||
|
||||
pub sentry_dsn: String,
|
||||
}
|
||||
|
||||
|
||||
impl Config {
|
||||
pub fn load() -> Config {
|
||||
Config {
|
||||
api_key: get_env("API_KEY"),
|
||||
|
||||
telegram_api_url: get_env("API_URL"),
|
||||
telegram_chat_id: get_env("TELEGRAM_CHAT_ID").parse().unwrap(),
|
||||
telegram_temp_chat_id: get_env("TELEGRAM_TEMP_CHAT_ID").parse().unwrap(),
|
||||
|
||||
bot_tokens: serde_json::from_str(&get_env("BOT_TOKENS")).unwrap(),
|
||||
sentry_dsn: get_env("SENTRY_DSN"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub static CONFIG: Lazy<Config> = Lazy::new(Config::load);
|
||||
Reference in New Issue
Block a user