rust-irc/examples/simple_ssl.rs

27 lines
714 B
Rust
Raw Normal View History

extern crate irc;
use std::default::Default;
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.mozilla.org".to_owned()),
channels: Some(vec!["#rust-spam".to_owned()]),
use_ssl: Some(true),
2017-06-19 19:59:26 +02:00
..Default::default()
};
let client = IrcClient::from_config(config).unwrap();
client.identify().unwrap();
client.for_each_incoming(|message| {
print!("{}", message);
2018-01-28 02:00:04 +01:00
if let Command::PRIVMSG(ref target, ref msg) = message.command {
if msg.contains("pickles") {
client.send_privmsg(target, "Hi!").unwrap();
2017-06-19 19:59:26 +02:00
}
}
2018-01-28 02:00:04 +01:00
}).unwrap();
}