diff options
| author | Max Audron <me@audron.dev> | 2025-12-14 02:28:05 +0100 |
|---|---|---|
| committer | Max Audron <me@audron.dev> | 2025-12-14 02:28:05 +0100 |
| commit | b6a17af38a5aba43bb5767cb082fd46cdf34c0a0 (patch) | |
| tree | a0fa5940bb7faf564d1ce5d9bc22a411e83ffc98 /src | |
| parent | fix readme badge links (diff) | |
fix non-sasl connection registration
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 24 | ||||
| -rw-r--r-- | src/main.rs | 5 |
2 files changed, 21 insertions, 8 deletions
@@ -74,7 +74,11 @@ impl Bot { if bot.config.server.sasl && bot.config.user.password.is_some() { tracing::info!("initializing sasl"); - bot.sasl_init().await.unwrap() + bot.sasl_init().unwrap() + } else if let Some(password) = bot.config.server.password.as_ref() { + tracing::info!("sending server password"); + bot.irc_client.send(Command::PASS(password.clone()))?; + bot.register_connection()?; } Ok(bot) @@ -86,18 +90,24 @@ impl Bot { &self.figment } - /// Initialize a sasl connection, you usually don't need - /// to run this yourself as it is done during [Bot::new]. - pub async fn sasl_init(&self) -> Result<()> { - self.irc_client - .send_cap_req(&vec![irc::client::prelude::Capability::Sasl])?; + pub fn register_connection(&self) -> Result<()> { self.irc_client .send(Command::NICK(self.config.user.nickname.clone()))?; self.irc_client.send(Command::USER( - self.config.user.nickname.clone(), + self.config.user.username.clone(), "0".to_owned(), self.config.user.realname.clone(), ))?; + + Ok(()) + } + + /// Initialize a sasl connection, you usually don't need + /// to run this yourself as it is done during [Bot::new]. + pub fn sasl_init(&self) -> Result<()> { + self.irc_client + .send_cap_req(&[irc::client::prelude::Capability::Sasl])?; + self.register_connection()?; self.irc_client.send_sasl_plain()?; Ok(()) diff --git a/src/main.rs b/src/main.rs index ef32078..e4c65d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,10 @@ async fn main() { use catinator::catinator; - tracing_subscriber::fmt::init(); + tracing_subscriber::fmt() + .with_max_level(tracing::Level::TRACE) + // .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .init(); rustls::crypto::CryptoProvider::install_default(rustls::crypto::aws_lc_rs::default_provider()) .unwrap(); |
