fix: now actually properly gets teh skynet server details

This commit is contained in:
silver 2023-09-17 21:02:41 +01:00
parent 69cb8e9a3f
commit 36e6bea543
2 changed files with 18 additions and 54 deletions

View file

@ -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 {

View file

@ -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::<u64>(&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::<u64>(&x));
}
if let Ok(x) = env::var("DISCORD_TIMING_UPDATE") {
config.timing_update = str_to_num::<u64>(&x);
}
if let Ok(x) = env::var("DISCORD_TIMING_FETCH") {
config.timing_fetch = str_to_num::<u64>(&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();
}