Respond to PINGs in the identify loop

This commit is contained in:
Yash Karandikar 2021-11-03 13:42:25 -05:00
parent c399d2569b
commit 077dfe3cb0
2 changed files with 5 additions and 4 deletions

View file

@ -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;

View file

@ -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);
}