Added send_notice(...) to Wrappers.
This commit is contained in:
parent
b1a29523cd
commit
2ab1f65e1f
1 changed files with 22 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
use std::io::IoResult;
|
||||
use data::{Command, Config, User};
|
||||
use data::command::Command::{INVITE, JOIN, KILL, MODE, NICK, KICK};
|
||||
use data::command::Command::{INVITE, JOIN, KILL, MODE, NICK, NOTICE, KICK};
|
||||
use data::command::Command::{OPER, PONG, PRIVMSG, SAMODE, SANICK, TOPIC, USER};
|
||||
use data::kinds::IrcStream;
|
||||
use server::{Server, ServerIterator};
|
||||
|
@ -74,6 +74,15 @@ impl<'a, T> Wrapper<'a, T> where T: IrcStream {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Sends a notice to the specified target.
|
||||
#[experimental]
|
||||
pub fn send_notice(&self, target: &str, message: &str) -> IoResult<()> {
|
||||
for line in message.split_str("\r\n") {
|
||||
try!(self.server.send(NOTICE(target, line)))
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the topic of a channel or requests the current one.
|
||||
/// If `topic` is an empty string, it won't be included in the message.
|
||||
#[experimental]
|
||||
|
@ -206,6 +215,18 @@ mod test {
|
|||
"PRIVMSG #test :Hi, everybody!\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_notice() {
|
||||
let server = IrcServer::from_connection(test_config(),
|
||||
Connection::new(IoStream::new(MemWriter::new(), NullReader)));
|
||||
{
|
||||
let wrapper = Wrapper::new(&server);
|
||||
wrapper.send_notice("#test", "Hi, everybody!").unwrap();
|
||||
}
|
||||
assert_eq!(get_server_value(server)[],
|
||||
"NOTICE #test :Hi, everybody!\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_topic_no_topic() {
|
||||
let server = IrcServer::from_connection(test_config(),
|
||||
|
|
Loading…
Reference in a new issue