rust-irc/examples/tweeter.rs

29 lines
839 B
Rust
Raw Normal View History

2015-03-21 23:08:41 -04:00
#![feature(std_misc, thread_sleep)]
extern crate irc;
use std::default::Default;
use std::sync::Arc;
2015-03-21 23:08:41 -04:00
use std::thread::{sleep, spawn};
use std::time::duration::Duration;
2015-02-22 21:22:33 -05:00
use irc::client::prelude::*;
fn main() {
let config = Config {
nickname: Some(format!("pickles")),
server: Some(format!("irc.fyrechat.net")),
channels: Some(vec![format!("#vana")]),
.. Default::default()
};
let server = Arc::new(IrcServer::from_config(config).unwrap());
server.identify().unwrap();
let server2 = server.clone();
2014-12-11 00:06:12 -05:00
// Let's set up a loop that just prints the messages.
spawn(move || {
server2.iter().map(|m| print!("{}", m.unwrap().into_string())).count();
2015-01-09 17:38:46 -05:00
});
loop {
server.send_privmsg("#vana", "TWEET TWEET").unwrap();
sleep(Duration::seconds(10))
}
}