rust-irc/examples/tweeter.rs

27 lines
760 B
Rust
Raw Normal View History

extern crate irc;
use std::default::Default;
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::*;
fn main() {
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
};
let server = 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.
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
});
loop {
server.send_privmsg("#vana", "TWEET TWEET").unwrap();
2015-11-22 22:26:43 +01:00
sleep(Duration::new(10, 0));
}
}