2015-01-09 23:38:46 +01:00
|
|
|
#![allow(unstable)]
|
2014-11-29 09:19:14 +01:00
|
|
|
#![feature(slicing_syntax)]
|
|
|
|
extern crate irc;
|
|
|
|
|
2014-12-05 03:04:22 +01:00
|
|
|
use std::default::Default;
|
2014-11-29 09:19:14 +01:00
|
|
|
use std::sync::Arc;
|
2014-12-23 19:00:07 +01:00
|
|
|
use std::thread::Thread;
|
2014-11-29 09:19:14 +01:00
|
|
|
use irc::data::config::Config;
|
|
|
|
use irc::server::{IrcServer, Server};
|
|
|
|
use irc::server::utils::Wrapper;
|
|
|
|
|
|
|
|
fn main() {
|
2014-12-05 03:04:22 +01:00
|
|
|
let config = Config {
|
|
|
|
nickname: Some(format!("pickles")),
|
|
|
|
server: Some(format!("irc.fyrechat.net")),
|
|
|
|
channels: Some(vec![format!("#vana")]),
|
|
|
|
.. Default::default()
|
|
|
|
};
|
2014-11-29 09:19:14 +01:00
|
|
|
let irc_server = Arc::new(IrcServer::from_config(config).unwrap());
|
|
|
|
// The wrapper provides us with methods like send_privmsg(...) and identify(...)
|
|
|
|
let server = Wrapper::new(&*irc_server);
|
|
|
|
server.identify().unwrap();
|
|
|
|
let server = irc_server.clone();
|
|
|
|
// We won't use a wrapper here because we don't need the added functionality.
|
2015-01-09 23:38:46 +01:00
|
|
|
let _ = Thread::scoped(move || {
|
2014-11-29 09:19:14 +01:00
|
|
|
for msg in server.iter() {
|
2014-12-20 22:50:54 +01:00
|
|
|
print!("{}", msg.unwrap().into_string());
|
2014-11-29 09:19:14 +01:00
|
|
|
}
|
2014-12-23 19:00:07 +01:00
|
|
|
}).join(); // You might not want to join here for actual multi-threading.
|
2014-11-29 09:19:14 +01:00
|
|
|
}
|