async-circe/src/main.rs
2021-12-27 19:45:53 +01:00

45 lines
1.2 KiB
Rust

use async_circe::{commands::Command, Client, Config};
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
//let config = Config::from_toml("config.toml")?;
let config = Default::default();
/*let config = Config::new(
&["#main"],
"karx.xyz",
Some("+B"),
Some("async-circe"),
6697,
"circe",
);*/
let mut client = Client::new(config).await.unwrap();
client.identify().await.unwrap();
client
.write_command(Command::PRIVMSG(
"".to_string(),
"#main".to_string(),
"Hello".to_string(),
))
.await?;
loop {
if let Ok(ref command) = client.read().await {
if let Command::OTHER(line) = command {
print!("{}", line);
}
if let Command::PRIVMSG(nick, channel, message) = command {
if message.contains("!quit") {
client.quit(None).await?;
break;
}
if message.contains("!close") {
client.part("#main").await?;
}
println!("PRIVMSG received from {}: {} {:#?}", nick, channel, message);
}
}
}
Ok(())
}