diff --git a/src/bot.rs b/src/bot.rs index 96ec5fb..c77a627 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -42,6 +42,10 @@ impl<'a, T, U> Bot for IrcBot<'a, T, U> where T: IrcWriter, U: IrcReader { self.conn.send(Message::new(None, "MODE", [chan[], mode[]])) } + fn send_oper(&self, name: &str, password: &str) -> IoResult<()> { + self.conn.send(Message::new(None, "OPER", [name[], password[]])) + } + fn send_topic(&self, chan: &str, topic: &str) -> IoResult<()> { self.conn.send(Message::new(None, "TOPIC", [chan[], topic[]])) } @@ -203,6 +207,14 @@ mod test { assert_eq!(data(b.conn), format!("MODE #test :+i\r\n")); } + #[test] + fn send_oper() { + let c = Connection::new(MemWriter::new(), NullReader).unwrap(); + let b = IrcBot::from_connection(c, |_, _, _, _| { Ok(()) }).unwrap(); + b.send_oper("test", "test").unwrap(); + assert_eq!(data(b.conn), format!("OPER test :test\r\n")); + } + #[test] fn send_topic() { let c = Connection::new(MemWriter::new(), NullReader).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 40ce6bb..5479d58 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,7 @@ pub trait Bot { fn send_user(&self, username: &str, real_name: &str) -> IoResult<()>; fn send_join(&self, chan: &str) -> IoResult<()>; fn send_mode(&self, chan: &str, mode: &str) -> IoResult<()>; + fn send_oper(&self, name: &str, password: &str) -> IoResult<()>; fn send_topic(&self, chan: &str, topic: &str) -> IoResult<()>; fn send_invite(&self, person: &str, chan: &str) -> IoResult<()>; fn send_privmsg(&self, chan: &str, msg: &str) -> IoResult<()>;