Merge pull request #74 from miedzinski/ctcp-ping

Ignore CTCP PINGs without timestamps
This commit is contained in:
Aaron Weiss 2017-03-15 12:33:37 -04:00 committed by GitHub
commit 3c3f175cc0

View file

@ -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)[..], "");
}
}