From 7724231ac4511ae3b7c737b51166dbb9e8d8a62c Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 16 Oct 2021 13:48:56 +0200 Subject: move bot initialization out of macro --- src/lib.rs | 7 +++++++ src/main.rs | 2 ++ 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 59898e6..82bdad5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,16 +42,23 @@ impl Bot { let config_str = fs::read_to_string(config_path)?; let mut config: config::Config = toml::from_str(&config_str)?; + let bot = Bot { irc_client, config, figment }; if let Some(v) = get_env_var("CATINATOR_PASSWORD") { config.user.password = v }; + if bot.config.server.sasl && bot.config.user.password.is_some() { + tracing::info!("initializing sasl"); + bot.sasl_init().await.unwrap() + } if let Some(v) = get_env_var("CATINATOR_WA_API_KEY") { config.settings.wa_api_key = v }; let irc_client = Client::from_config(config.clone().into()).await?; + Ok(bot) + } Ok(Bot { irc_client, config }) } diff --git a/src/main.rs b/src/main.rs index fd2d3b2..100af91 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,8 @@ async fn main() { .with_thread_ids(true) .init(); + let mut bot = Bot::new().await.unwrap(); + let mut sed = catinator::hooks::sed::Sed::new(); catinator![ -- cgit v1.2.3