46 lines
1.1 KiB
Rust
46 lines
1.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 = Config::new(
|
|
vec!["#main", "#no-normies"],
|
|
"karx.xyz",
|
|
Some("+B"),
|
|
Some("circe"),
|
|
6697,
|
|
true,
|
|
"circe",
|
|
);
|
|
let mut client = Client::new(config).unwrap();
|
|
client.identify().unwrap();
|
|
|
|
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(())
|
|
}
|