45 lines
1.1 KiB
Rust
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(())
|
|
}
|