diff --git a/src/client/server/utils.rs b/src/client/server/utils.rs index 6ef5307..041b926 100644 --- a/src/client/server/utils.rs +++ b/src/client/server/utils.rs @@ -3,7 +3,7 @@ use std::io::Result; use std::borrow::ToOwned; use client::data::{Capability, NegotiationVersion}; use client::data::Command::{AUTHENTICATE, CAP, INVITE, JOIN, KICK, KILL, MODE, NICK, NOTICE}; -use client::data::Command::{OPER, PASS, PONG, PRIVMSG, QUIT, SAMODE, SANICK, TOPIC, USER}; +use client::data::Command::{OPER, PART, PASS, PONG, PRIVMSG, QUIT, SAMODE, SANICK, TOPIC, USER}; use client::data::command::CapSubCommand::{END, LS, REQ}; #[cfg(feature = "ctcp")] use time::get_time; use client::server::Server; @@ -76,6 +76,11 @@ pub trait ServerExt: Server { self.send(JOIN(chanlist.to_owned(), Some(keylist.to_owned()), None)) } + /// Parts the specified channel or chanlist. + fn send_part(&self, chanlist: &str) -> Result<()> where Self: Sized { + self.send(PART(chanlist.to_owned(), None)) + } + /// Attempts to oper up using the specified username and password. fn send_oper(&self, username: &str, password: &str) -> Result<()> where Self: Sized { self.send(OPER(username.to_owned(), password.to_owned())) @@ -268,6 +273,13 @@ mod test { assert_eq!(&get_server_value(server)[..], "JOIN #test,#test2,#test3\r\n"); } + #[test] + fn send_part() { + let server = IrcServer::from_connection(test_config(), MockConnection::empty()); + server.send_part("#test").unwrap(); + assert_eq!(&get_server_value(server)[..], "PART #test\r\n"); + } + #[test] fn send_oper() { let server = IrcServer::from_connection(test_config(), MockConnection::empty());