async-circe/examples/debugging/src/main.rs
2022-01-05 11:53:57 +01:00

30 lines
880 B
Rust

use async_circe::{commands::Command, Client, Config};
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), tokio::io::Error> {
// This tells tracing to show the debug log when the binary is run with
// CIRCE_LOG="tracing"
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_env("CIRCE_LOG"))
.init();
let config = Config::new(
&["#main", "#no-normies"],
"karx.xyz",
Some("+B"),
Some("async-circe"),
6697,
"circe",
);
let mut client = Client::new(config).await.unwrap();
client.identify().await.unwrap();
loop {
if let Some(command) = client.read().await? {
if let Command::PRIVMSG(nick, channel, message) = command {
println!("{} in {}: {}", nick, channel, message);
}
}
}
}