rust-irc/examples/tweeter.rs

28 lines
857 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::*;
// NOTE: you can find an asynchronous version of this example with `IrcReactor` in `tooter.rs`.
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 client = IrcClient::from_config(config).unwrap();
client.identify().unwrap();
let client2 = client.clone();
2014-12-11 06:06:12 +01: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 23:38:46 +01:00
});
loop {
client.send_privmsg("#irc-crate", "TWEET TWEET").unwrap();
thread::sleep(Duration::new(10, 0));
}
}