26 lines
760 B
Rust
26 lines
760 B
Rust
extern crate irc;
|
|
|
|
use std::default::Default;
|
|
use irc::client::prelude::*;
|
|
|
|
fn main() {
|
|
let config = Config {
|
|
nickname: Some("pickles".to_owned()),
|
|
alt_nicks: Some(vec!["bananas".to_owned(), "apples".to_owned()]),
|
|
server: Some("irc.fyrechat.net".to_owned()),
|
|
channels: Some(vec!["#irc-crate".to_owned()]),
|
|
..Default::default()
|
|
};
|
|
|
|
let client = IrcClient::from_config(config).unwrap();
|
|
client.identify().unwrap();
|
|
|
|
client.for_each_incoming(|message| {
|
|
print!("{}", message);
|
|
if let Command::PRIVMSG(ref target, ref msg) = message.command {
|
|
if msg.contains("pickles") {
|
|
client.send_privmsg(target, "Hi!").unwrap();
|
|
}
|
|
}
|
|
}).unwrap();
|
|
}
|