This commit is contained in:
2025-02-27 23:20:25 +01:00
commit 6339336135
8 changed files with 3296 additions and 0 deletions

48
src/config.rs Normal file
View File

@@ -0,0 +1,48 @@
use once_cell::sync::Lazy;
pub struct Config {
pub bot_token: String,
pub telegram_webhook_url: String,
pub telegram_webhook_port: u16,
pub twitch_client_id: String,
pub twitch_client_secret: String,
pub twitch_signing_secret: String,
pub twitch_webhook_url: String,
pub twitch_webhook_port: u16,
}
impl Config {
fn load() -> Self {
Self {
bot_token: std::env::var("BOT_TOKEN").expect("BOT_TOKEN is not set"),
telegram_webhook_url: std::env::var("TELEGRAM_WEBHOOK_URL")
.expect("TELEGRAM_WEBHOOK_URL is not set"),
telegram_webhook_port: std::env::var("TELEGRAM_WEBHOOK_PORT")
.expect("TELEGRAM_WEBHOOK_PORT is not set")
.parse()
.expect("TELEGRAM_WEBHOOK_PORT is not a valid u16"),
twitch_client_id: std::env::var("TWITCH_CLIENT_ID")
.expect("TWITCH_CLIENT_ID is not set"),
twitch_client_secret: std::env::var("TWITCH_CLIENT_SECRET")
.expect("TWITCH_CLIENT_SECRET is not set"),
twitch_signing_secret: std::env::var("TWITCH_SIGNING_SECRET")
.expect("TWITCH_SIGNING_SECRET is not set"),
twitch_webhook_url: std::env::var("TWITCH_WEBHOOK_URL")
.expect("TWITCH_WEBHOOK_URL is not set"),
twitch_webhook_port: std::env::var("TWITCH_WEBHOOK_PORT")
.expect("TWITCH_WEBHOOK_PORT is not set")
.parse()
.expect("TWITCH_WEBHOOK_PORT is not a valid u16"),
}
}
}
pub static CONFIG: Lazy<Config> = Lazy::new(Config::load);