diff --git a/src/client/server/mod.rs b/src/client/server/mod.rs index b48d7b8..c53f86e 100644 --- a/src/client/server/mod.rs +++ b/src/client/server/mod.rs @@ -469,7 +469,9 @@ impl IrcServer { try!(self.send_ctcp_internal(resp, "SOURCE https://github.com/aatxe/irc")); self.send_ctcp_internal(resp, "SOURCE") }, - "PING" => self.send_ctcp_internal(resp, &format!("PING {}", tokens[1])), + "PING" if tokens.len() > 1 => { + self.send_ctcp_internal(resp, &format!("PING {}", tokens[1])) + }, "TIME" => self.send_ctcp_internal(resp, &format!( "TIME :{}", now().rfc822z() )), @@ -860,4 +862,15 @@ mod test { assert_eq!(&get_server_value(server)[..], "NOTICE test :\u{001}USERINFO :Testing.\u{001}\ \r\n"); } + + #[test] + #[cfg(feature = "ctcp")] + fn ctcp_ping_no_timestamp() { + let value = ":test!test@test PRIVMSG test :\u{001}PING\u{001}\r\n"; + let server = IrcServer::from_connection(test_config(), MockConnection::new(value)); + for message in server.iter() { + println!("{:?}", message); + } + assert_eq!(&get_server_value(server)[..], ""); + } }