aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Audron <me@audron.dev>2025-12-14 02:28:05 +0100
committerMax Audron <me@audron.dev>2025-12-14 02:28:05 +0100
commitb6a17af38a5aba43bb5767cb082fd46cdf34c0a0 (patch)
treea0fa5940bb7faf564d1ce5d9bc22a411e83ffc98 /src
parentfix readme badge links (diff)
fix non-sasl connection registration
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs24
-rw-r--r--src/main.rs5
2 files changed, 21 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 7a7cdda..905f220 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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();