2014-11-03 09:50:28 +01:00
|
|
|
#![feature(if_let)]
|
2014-11-03 08:11:51 +01:00
|
|
|
#![feature(slicing_syntax)]
|
|
|
|
extern crate irc;
|
|
|
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use irc::data::config::Config;
|
|
|
|
use irc::server::{IrcServer, Server};
|
2014-11-03 10:15:03 +01:00
|
|
|
use irc::server::utils::Wrapper;
|
2014-11-03 08:11:51 +01:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let config = Config {
|
|
|
|
owners: vec!("awe".into_string()),
|
|
|
|
nickname: "pickles".into_string(),
|
|
|
|
username: "pickles".into_string(),
|
|
|
|
realname: "pickles".into_string(),
|
|
|
|
password: "".into_string(),
|
|
|
|
server: "irc.fyrechat.net".into_string(),
|
|
|
|
port: 6667,
|
2014-11-08 23:35:19 +01:00
|
|
|
use_ssl: false,
|
2014-11-03 08:11:51 +01:00
|
|
|
channels: vec!("#vana".into_string()),
|
|
|
|
options: HashMap::new(),
|
|
|
|
};
|
2014-11-03 10:19:12 +01:00
|
|
|
let irc_server = IrcServer::from_config(config).unwrap();
|
|
|
|
let server = Wrapper::new(&irc_server);
|
2014-11-03 10:15:03 +01:00
|
|
|
server.identify().unwrap();
|
2014-11-03 08:11:51 +01:00
|
|
|
for message in server.iter() {
|
2014-11-03 09:11:14 +01:00
|
|
|
print!("{}", message.into_string());
|
2014-11-03 09:50:28 +01:00
|
|
|
if message.command[] == "PRIVMSG" {
|
|
|
|
if let Some(msg) = message.suffix {
|
|
|
|
if msg.contains("pickles") {
|
2014-11-03 10:15:03 +01:00
|
|
|
server.send_privmsg(message.args[0][], "Hi!").unwrap();
|
2014-11-03 09:50:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-03 08:11:51 +01:00
|
|
|
}
|
|
|
|
}
|