rust-irc/examples/tweeter.rs

28 lines
856 B
Rust
Raw Normal View History

extern crate irc;
use std::default::Default;
use std::thread;
2015-11-22 16:26:43 -05:00
use std::time::Duration;
2015-02-22 21:22:33 -05:00
use irc::client::prelude::*;
// NOTE: you can find an asynchronous version of this example with `IrcReactor` in `tooter.rs`.
fn main() {
let config = Config {
2017-06-19 13:46:01 -04:00
nickname: Some("pickles".to_owned()),
server: Some("irc.mozilla.org".to_owned()),
channels: Some(vec!["#rust-spam".to_owned()]),
2017-06-19 13:59:26 -04:00
..Default::default()
2015-06-22 12:03:57 -04:00
};
let client = IrcClient::from_config(config).unwrap();
client.identify().unwrap();
let client2 = client.clone();
2014-12-11 00:06:12 -05:00
// Let's set up a loop that just prints the messages.
thread::spawn(move || {
client2.stream().map(|m| print!("{}", m)).wait().count();
2015-01-09 17:38:46 -05:00
});
loop {
client.send_privmsg("#rust-spam", "TWEET TWEET").unwrap();
thread::sleep(Duration::new(10, 0));
}
}