Added send_part to ServerExt.

This commit is contained in:
Aaron Weiss 2016-12-18 16:23:45 -05:00
parent bd79f90d96
commit d13a28ff98
No known key found for this signature in database
GPG key ID: 0237035D9BF03AE2

View file

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