34 lines
809 B
Rust
34 lines
809 B
Rust
use irsc::{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::new(
|
|
"test",
|
|
Some("test"),
|
|
Some("+B"),
|
|
Box::new(["#main", "#main2"]),
|
|
);
|
|
let mut client =
|
|
Client::new("192.168.178.100", 6667, config).expect("Unable to connect to IRC server");
|
|
client.identify()?;
|
|
|
|
loop {
|
|
if let Ok(ref command) = client.read() {
|
|
if let Command::PING(code) = command {
|
|
client.write_command(Command::PONG(code.to_string()))?;
|
|
}
|
|
if let Command::OTHER(line) = command {
|
|
print!("{}", line);
|
|
}
|
|
}
|
|
}
|
|
}
|