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()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let reactor = IrcReactor::new().unwrap();
|
let mut reactor = IrcReactor::new().unwrap();
|
||||||
let server = reactor.prepare_server_and_connect(&config).unwrap();
|
let server = reactor.prepare_server_and_connect(&config).unwrap();
|
||||||
server.identify().unwrap();
|
server.identify().unwrap();
|
||||||
|
|
||||||
reactor.register_server_with_handler(server, |message| {
|
reactor.register_server_with_handler(server, |server, message| {
|
||||||
print!("{}", message);
|
print!("{}", message);
|
||||||
match message.command {
|
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||||
Command::PRIVMSG(ref target, ref msg) => {
|
|
||||||
if msg.contains("pickles") {
|
if msg.contains("pickles") {
|
||||||
server.send_privmsg(target, "Hi!").unwrap();
|
server.send_privmsg(target, "Hi!")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -46,15 +46,12 @@ fn main() {
|
||||||
|
|
||||||
fn process_msg(server: &IrcServer, message: Message) -> error::Result<()> {
|
fn process_msg(server: &IrcServer, message: Message) -> error::Result<()> {
|
||||||
print!("{}", message);
|
print!("{}", message);
|
||||||
match message.command {
|
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||||
Command::PRIVMSG(ref target, ref msg) => {
|
|
||||||
if msg.contains("pickles") {
|
if msg.contains("pickles") {
|
||||||
server.send_privmsg(target, "Hi!")?;
|
server.send_privmsg(target, "Hi!")?;
|
||||||
} else if msg.contains("quit") {
|
} else if msg.contains("quit") {
|
||||||
server.send_quit("bye")?;
|
server.send_quit("bye")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,7 @@ fn main() {
|
||||||
|
|
||||||
server.for_each_incoming(|message| {
|
server.for_each_incoming(|message| {
|
||||||
print!("{}", message);
|
print!("{}", message);
|
||||||
match message.command {
|
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||||
Command::PRIVMSG(ref target, ref msg) => {
|
|
||||||
if msg.starts_with(server.current_nickname()) {
|
if msg.starts_with(server.current_nickname()) {
|
||||||
let tokens: Vec<_> = msg.split(' ').collect();
|
let tokens: Vec<_> = msg.split(' ').collect();
|
||||||
if tokens.len() > 2 {
|
if tokens.len() > 2 {
|
||||||
|
@ -37,7 +36,5 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}).unwrap()
|
}).unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,10 @@ fn main() {
|
||||||
|
|
||||||
server.for_each_incoming(|message| {
|
server.for_each_incoming(|message| {
|
||||||
print!("{}", message);
|
print!("{}", message);
|
||||||
match message.command {
|
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||||
Command::PRIVMSG(ref target, ref msg) => {
|
|
||||||
if msg.contains("pickles") {
|
if msg.contains("pickles") {
|
||||||
server.send_privmsg(target, "Hi!").unwrap();
|
server.send_privmsg(target, "Hi!").unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
}).unwrap();
|
||||||
}
|
|
||||||
}).unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,10 @@ fn main() {
|
||||||
|
|
||||||
server.for_each_incoming(|message| {
|
server.for_each_incoming(|message| {
|
||||||
print!("{}", message);
|
print!("{}", message);
|
||||||
match message.command {
|
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
||||||
Command::PRIVMSG(ref target, ref msg) => {
|
|
||||||
if msg.contains("pickles") {
|
if msg.contains("pickles") {
|
||||||
server.send_privmsg(target, "Hi!").unwrap();
|
server.send_privmsg(target, "Hi!").unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
}).unwrap();
|
||||||
}
|
|
||||||
}).unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue