2014-11-29 11:26:55 +01:00
|
|
|
extern crate irc;
|
|
|
|
|
2014-12-05 03:04:22 +01:00
|
|
|
use std::default::Default;
|
2014-11-29 11:26:55 +01:00
|
|
|
use std::sync::Arc;
|
2015-11-22 22:26:43 +01:00
|
|
|
use std::thread::{sleep, spawn};
|
|
|
|
use std::time::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()
|
2015-06-22 18:03:57 +02:00
|
|
|
};
|
2015-02-24 16:14:44 +01:00
|
|
|
let server = Arc::new(IrcServer::from_config(config).unwrap());
|
2014-11-29 11:26:55 +01:00
|
|
|
server.identify().unwrap();
|
2015-02-24 16:14:44 +01:00
|
|
|
let server2 = server.clone();
|
2014-12-11 06:06:12 +01:00
|
|
|
// Let's set up a loop that just prints the messages.
|
2015-06-22 18:03:57 +02:00
|
|
|
spawn(move || {
|
|
|
|
server2.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();
|
2015-11-22 22:26:43 +01:00
|
|
|
sleep(Duration::new(10, 0));
|
2014-11-29 11:26:55 +01:00
|
|
|
}
|
|
|
|
}
|