circe/src/main.rs
2021-11-07 20:12:00 -06:00

45 lines
1.1 KiB
Rust

use circe::{Client, Command, Config};
#[allow(unused_macros)]
macro_rules! loop_n {
($n:expr, $c:expr) => {{
for _ in 0..$n {
$c
}
}};
}
fn main() -> Result<(), std::io::Error> {
//let config = Config::from_toml("config.toml")?;
let config = Config::new(
vec!["#main", "#circe"],
"192.168.178.100",
Some("+B"),
Some("circe"),
6667,
"circe",
);
let mut client = Client::new(config)?;
client.identify()?;
loop {
if let Ok(ref command) = client.read() {
if let Command::OTHER(line) = command {
print!("{}", line);
}
if let Command::PRIVMSG(channel, message) = command {
if message.contains("!quit") {
client.send_quit(None)?;
break;
}
if message.contains("!close") {
client.send_part("#main")?;
}
println!("PRIVMSG received: {} {}", channel, message);
}
}
}
Ok(())
}