2015-02-21 16:18:53 +01:00
|
|
|
#![feature(old_io, std_misc)]
|
2014-11-29 11:26:55 +01:00
|
|
|
extern crate irc;
|
|
|
|
|
2014-12-05 03:04:22 +01:00
|
|
|
use std::default::Default;
|
2015-01-28 18:19:02 +01:00
|
|
|
use std::old_io::timer::sleep;
|
2014-11-29 11:26:55 +01:00
|
|
|
use std::sync::Arc;
|
2015-02-21 16:18:53 +01:00
|
|
|
use std::thread::spawn;
|
2014-11-29 11:26:55 +01:00
|
|
|
use std::time::duration::Duration;
|
2015-02-23 03:22:33 +01:00
|
|
|
use irc::client::prelude::*;
|
2014-11-29 11:26:55 +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-12-02 01:27:30 +01:00
|
|
|
let irc_server = Arc::new(IrcServer::from_config(config).unwrap());
|
2014-11-29 11:26:55 +01:00
|
|
|
let irc_server2 = irc_server.clone();
|
|
|
|
// The wrapper provides us with methods like send_privmsg(...) and identify(...)
|
2014-12-11 06:06:12 +01:00
|
|
|
let server = Wrapper::new(&*irc_server2);
|
2014-11-29 11:26:55 +01:00
|
|
|
server.identify().unwrap();
|
2014-12-11 06:06:12 +01:00
|
|
|
// Let's set up a loop that just prints the messages.
|
2015-02-21 16:18:53 +01:00
|
|
|
spawn(move || {
|
2014-12-23 19:00:07 +01:00
|
|
|
irc_server.iter().map(|m| print!("{}", m.unwrap().into_string())).count();
|
2015-01-09 23:38:46 +01:00
|
|
|
});
|
2014-11-29 11:26:55 +01:00
|
|
|
loop {
|
|
|
|
server.send_privmsg("#vana", "TWEET TWEET").unwrap();
|
|
|
|
sleep(Duration::seconds(10))
|
|
|
|
}
|
|
|
|
}
|