From d0f3137b621561df95b0168a94c08ba8715117e7 Mon Sep 17 00:00:00 2001 From: famfo Date: Tue, 28 Dec 2021 13:38:50 +0100 Subject: [PATCH] Put client config into one struct --- async-circe | 2 +- src/main.rs | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/async-circe b/async-circe index da4ed5b..d07b899 160000 --- a/async-circe +++ b/async-circe @@ -1 +1 @@ -Subproject commit da4ed5b4861d960ded7da66167f970aec3ef1656 +Subproject commit d07b899811c20e74db1969fa6ec0c6f166abbc8a diff --git a/src/main.rs b/src/main.rs index bdc4072..f9c5a29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,13 @@ struct AppState { } #[derive(Deserialize)] -struct SpotifyConf { +struct ClientConf { + channels: Vec, + host: String, + mode: Option, + nickname: Option, + port: u16, + username: String, spotify_client_id: String, spotify_client_secret: String, } @@ -55,16 +61,22 @@ async fn main() -> anyhow::Result<()> { .with_env_filter(EnvFilter::from_env("UBERBOT_LOG")) .init(); - let mut file = File::open("uberbot_spotify.toml").unwrap(); - let mut spotify_conf = String::new(); - file.read_to_string(&mut spotify_conf).unwrap(); + let mut file = File::open("uberbot.toml").unwrap(); + let mut client_conf = String::new(); + file.read_to_string(&mut client_conf).unwrap(); - let spotify: SpotifyConf = toml::from_str(&spotify_conf).unwrap(); + let config: ClientConf = toml::from_str(&client_conf).unwrap(); - let spotify_creds = - Credentials::new(&spotify.spotify_client_id, &spotify.spotify_client_secret); + let spotify_creds = Credentials::new(&config.spotify_client_id, &config.spotify_client_secret); - let config = Config::from_toml("uberbot_irc.toml")?; + let config = Config::runtime_config( + config.channels, + config.host, + config.mode, + config.nickname, + config.port, + config.username, + ); let mut client = Client::new(config).await?; client.identify().await?;