Cleaned up a bunch of the examples.
This commit is contained in:
parent
d6786936fa
commit
af72e57c5f
5 changed files with 29 additions and 44 deletions
|
@ -13,20 +13,17 @@ fn main() {
|
|||
..Default::default()
|
||||
};
|
||||
|
||||
let reactor = IrcReactor::new().unwrap();
|
||||
let mut reactor = IrcReactor::new().unwrap();
|
||||
let server = reactor.prepare_server_and_connect(&config).unwrap();
|
||||
server.identify().unwrap();
|
||||
|
||||
reactor.register_server_with_handler(server, |message| {
|
||||
reactor.register_server_with_handler(server, |server, message| {
|
||||
print!("{}", message);
|
||||
match message.command {
|
||||
Command::PRIVMSG(ref target, ref msg) => {
|
||||
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||
if msg.contains("pickles") {
|
||||
server.send_privmsg(target, "Hi!").unwrap();
|
||||
server.send_privmsg(target, "Hi!")?;
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
|
||||
|
|
|
@ -46,15 +46,12 @@ fn main() {
|
|||
|
||||
fn process_msg(server: &IrcServer, message: Message) -> error::Result<()> {
|
||||
print!("{}", message);
|
||||
match message.command {
|
||||
Command::PRIVMSG(ref target, ref msg) => {
|
||||
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||
if msg.contains("pickles") {
|
||||
server.send_privmsg(target, "Hi!")?;
|
||||
} else if msg.contains("quit") {
|
||||
server.send_quit("bye")?;
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ fn main() {
|
|||
|
||||
server.for_each_incoming(|message| {
|
||||
print!("{}", message);
|
||||
match message.command {
|
||||
Command::PRIVMSG(ref target, ref msg) => {
|
||||
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||
if msg.starts_with(server.current_nickname()) {
|
||||
let tokens: Vec<_> = msg.split(' ').collect();
|
||||
if tokens.len() > 2 {
|
||||
|
@ -37,7 +36,5 @@ fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}).unwrap()
|
||||
}
|
||||
|
|
|
@ -17,13 +17,10 @@ fn main() {
|
|||
|
||||
server.for_each_incoming(|message| {
|
||||
print!("{}", message);
|
||||
match message.command {
|
||||
Command::PRIVMSG(ref target, ref msg) => {
|
||||
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||
if msg.contains("pickles") {
|
||||
server.send_privmsg(target, "Hi!").unwrap();
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}).unwrap()
|
||||
}).unwrap();
|
||||
}
|
||||
|
|
|
@ -17,13 +17,10 @@ fn main() {
|
|||
|
||||
server.for_each_incoming(|message| {
|
||||
print!("{}", message);
|
||||
match message.command {
|
||||
Command::PRIVMSG(ref target, ref msg) => {
|
||||
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||
if msg.contains("pickles") {
|
||||
server.send_privmsg(target, "Hi!").unwrap();
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}).unwrap()
|
||||
}).unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue