rust-irc/examples/tweeter.rs

27 lines
761 B
Rust
Raw Normal View History

extern crate irc;
use std::default::Default;
use std::thread;
2015-11-22 22:26:43 +01:00
use std::time::Duration;
2015-02-23 03:22:33 +01:00
use irc::client::prelude::*;
fn main() {
let config = Config {
2017-06-19 19:46:01 +02:00
nickname: Some("pickles".to_owned()),
server: Some("irc.fyrechat.net".to_owned()),
channels: Some(vec!["#irc-crate".to_owned()]),
2017-06-19 19:59:26 +02:00
..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.
thread::spawn(move || {
server2.stream().map(|m| print!("{}", m)).wait().count();
2015-01-09 23:38:46 +01:00
});
loop {
server.send_privmsg("#irc-crate", "TWEET TWEET").unwrap();
thread::sleep(Duration::new(10, 0));
}
}