diff --git a/src/lib.rs b/src/lib.rs index 0c477ce..34e725a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,6 +64,10 @@ impl Client { loop { if let Ok(ref command) = self.read() { + if let Command::PING(code) = command { + self.write_command(Command::PONG(code.to_string()))?; + continue; + } if let Command::OTHER(line) = command { if line.contains("001") { break; diff --git a/src/main.rs b/src/main.rs index 3b00c52..3aa1d1c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,14 +17,11 @@ fn main() -> Result<(), std::io::Error> { Box::new(["#main", "#main2"]), ); let mut client = - Client::new("192.168.178.100", 6667, config).expect("Unable to connect to IRC server"); + Client::new("192.168.1.28", 6667, config).expect("Unable to connect to IRC server"); client.identify()?; loop { if let Ok(ref command) = client.read() { - if let Command::PING(code) = command { - client.write_command(Command::PONG(code.to_string()))?; - } if let Command::OTHER(line) = command { print!("{}", line); }