diff --git a/src/commands.rs b/src/commands.rs index a4fb73e..2912c3f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -216,6 +216,8 @@ pub enum Command { TOPIC_BY(String, String), #[doc(hidden)] USER(String, String, String, String), + #[doc(hidden)] + WELCOME(), } impl Command { @@ -268,6 +270,9 @@ impl Command { let server = parts[3]; Self::PONG(parts[2].to_string(), (server[1..]).to_string()) } + Some(&"001") => { + Self::WELCOME() + } _ => Self::OTHER(new.to_string()), } } diff --git a/src/lib.rs b/src/lib.rs index 42718aa..ad08ae2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -145,11 +145,8 @@ impl Client { commands::Command::PING(code) => { self.pong(&code).await?; } - commands::Command::OTHER(line) => { - tracing::trace!("{}", line); - if line.contains("001") { - break; - } + commands::Command::WELCOME() => { + break; } _ => {} } @@ -219,8 +216,9 @@ impl Client { let command = commands::Command::command_from_str(string).await; if let commands::Command::PING(command) = command { - if let Err(_e) = self.pong(&command).await { - return Ok(None); + if let Err(e) = self.pong(&command).await { + tracing::error!("{}", e); + return Err(e); } return Ok(Some(commands::Command::PING("".to_string()))); }