rust-irc/examples/tweeter.rs

27 lines
763 B
Rust
Raw Normal View History

extern crate irc;
use std::default::Default;
use std::sync::Arc;
2015-04-03 06:56:42 +02:00
use std::thread::{sleep_ms, spawn};
2015-02-23 03:22:33 +01: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 06:06:12 +01: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 23:38:46 +01:00
});
loop {
server.send_privmsg("#vana", "TWEET TWEET").unwrap();
2015-04-03 06:56:42 +02:00
sleep_ms(10 * 1000);
}
}