circe/src/main.rs

39 lines
1 KiB
Rust

use circe::{commands::Command, Client, 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 = Default::default();
let mut client = Client::new(config).unwrap();
client.identify().unwrap();
client.privmsg("#main", "Test")?;
loop {
if let Ok(ref command) = client.read() {
if let Command::OTHER(line) = command {
print!("{}", line);
}
if let Command::PRIVMSG(nick, channel, message) = command {
if message.contains("!quit") {
client.quit(None)?;
break;
}
if message.contains("!close") {
client.part("#main")?;
}
println!("PRIVMSG received from {}: {} {:#?}", nick, channel, message);
}
}
}
Ok(())
}