From 36e6bea54318300bb8329b48bbefa2d843327475 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sun, 17 Sep 2023 21:02:41 +0100 Subject: [PATCH] fix: now actually properly gets teh skynet server details --- flake.nix | 37 +++++-------------------------------- src/lib.rs | 35 +++++++++++++---------------------- 2 files changed, 18 insertions(+), 54 deletions(-) diff --git a/flake.nix b/flake.nix index 82a15db..f47e23f 100644 --- a/flake.nix +++ b/flake.nix @@ -46,16 +46,11 @@ cfg = config.services."${package_name}"; # secret options are in the env file(s) loaded separately environment_config = { - DISCORD_SERVER = cfg.discord.server; - DISCORD_ROLE_CURRENT = cfg.discord.role.current; - DISCORD_ROLE_PAST = cfg.discord.role.past; - LDAP_API = cfg.ldap; - DISCORD_TIMING_UPDATE = cfg.discord.timing.update; - DISCORD_TIMING_FETCH = cfg.discord.timing.fetch; - - # local details - HOME = cfg.home; - DATABASE = "database.db"; + LDAP_API = cfg.ldap; + SKYNET_SERVER = cfg.discord.server; + HOME = cfg.home; + DATABASE = "database.db"; + CSV = "wolves.csv"; }; service_name = script: lib.strings.sanitizeDerivationName("${cfg.user}@${script}"); @@ -125,28 +120,6 @@ type = types.str; description = "ID of the server the bot runs on"; }; - role = { - past = mkOption rec { - type = types.str; - description = "ID of the role to apply to all members"; - }; - current = mkOption rec { - type = types.str; - description = "ID of the role to applt to only current members"; - }; - }; - timing = { - update = mkOption rec { - type = types.str; - default = "600"; - description = "Time in seconds to update member roles"; - }; - fetch = mkOption rec { - type = types.str; - default = "300"; - description = "Time in seconds to get current users"; - }; - }; }; ldap = mkOption rec { diff --git a/src/lib.rs b/src/lib.rs index 21ce390..54c2174 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,15 +20,13 @@ use tokio::sync::RwLock; pub struct Config { pub skynet_server: GuildId, pub ldap_api: String, - pub auth: String, - pub timing_update: u64, - pub timing_fetch: u64, - pub discord_token: String, - pub home: String, pub database: String, pub csv: String, + pub auth: String, + pub discord_token: String, + pub mail_smtp: String, pub mail_user: String, pub mail_pass: String, @@ -50,8 +48,6 @@ pub fn get_config() -> Config { skynet_server: Default::default(), ldap_api: "https://api.account.skynet.ie".to_string(), auth: "".to_string(), - timing_update: 0, - timing_fetch: 0, discord_token: "".to_string(), home: ".".to_string(), @@ -63,25 +59,12 @@ pub fn get_config() -> Config { mail_pass: "".to_string(), }; - if let Ok(x) = env::var("SKYNET_SERVER") { - config.skynet_server = GuildId::from(str_to_num::(&x)); - } if let Ok(x) = env::var("LDAP_API") { config.ldap_api = x.trim().to_string(); } - if let Ok(x) = env::var("LDAP_DISCORD_AUTH") { - config.auth = x.trim().to_string(); + if let Ok(x) = env::var("SKYNET_SERVER") { + config.skynet_server = GuildId::from(str_to_num::(&x)); } - if let Ok(x) = env::var("DISCORD_TIMING_UPDATE") { - config.timing_update = str_to_num::(&x); - } - if let Ok(x) = env::var("DISCORD_TIMING_FETCH") { - config.timing_fetch = str_to_num::(&x); - } - if let Ok(x) = env::var("DISCORD_TOKEN") { - config.discord_token = x.trim().to_string(); - } - if let Ok(x) = env::var("HOME") { config.home = x.trim().to_string(); } @@ -92,6 +75,14 @@ pub fn get_config() -> Config { config.csv = x.trim().to_string(); } + if let Ok(x) = env::var("LDAP_DISCORD_AUTH") { + config.auth = x.trim().to_string(); + } + + if let Ok(x) = env::var("DISCORD_TOKEN") { + config.discord_token = x.trim().to_string(); + } + if let Ok(x) = env::var("EMAIL_SMTP") { config.mail_smtp = x.trim().to_string(); }