rust-irc/examples/tweeter.rs
Aaron Weiss e4495940fc Made a whole lot of linting changes to improve code.
Small API changes:
  1. Message::into_string -> Message:to_string
  2. NetStream::UnsecuredTcpStream -> NetStream::Unsecured
  3. NetStream::SslTcpStream -> NetStream::Ssl
2016-03-17 21:35:35 -04:00

26 lines
758 B
Rust

extern crate irc;
use std::default::Default;
use std::thread::{sleep, spawn};
use std::time::Duration;
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 = IrcServer::from_config(config).unwrap();
server.identify().unwrap();
let server2 = server.clone();
// Let's set up a loop that just prints the messages.
spawn(move || {
server2.iter().map(|m| print!("{}", m.unwrap().to_string())).count();
});
loop {
server.send_privmsg("#vana", "TWEET TWEET").unwrap();
sleep(Duration::new(10, 0));
}
}