2014-11-29 09:19:14 +01:00
|
|
|
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;
|
2015-02-21 16:18:53 +01:00
|
|
|
use std::thread::spawn;
|
2015-01-13 08:39:59 +01:00
|
|
|
use irc::client::data::config::Config;
|
|
|
|
use irc::client::server::{IrcServer, Server};
|
|
|
|
use irc::client::server::utils::Wrapper;
|
2014-11-29 09:19:14 +01:00
|
|
|
|
|
|
|
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-02-21 16:18:53 +01:00
|
|
|
let _ = spawn(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
|
|
|
}
|