//! Minimal bot that listens on iroh and prints its endpoint id. //! //! ```bash //! cargo run --example bot -- --name scout --cookie secret //! ``` use clap::Parser; use erl_iroh::bot::Bot; use erl_iroh::powers::Powers; use tracing_subscriber::EnvFilter; #[derive(Parser, Debug)] #[command(name = "bot", about = "erl-iroh bot that listens for peers")] struct Args { /// Short node name (becomes name@iroh). #[arg(long, default_value = "scout")] name: String, /// Erlang distribution cookie. #[arg(long, default_value = "erl-iroh-cookie")] cookie: String, } #[tokio::main] async fn main() -> erl_iroh::Result<()> { tracing_subscriber::fmt() .with_env_filter(EnvFilter::from_default_env().add_directive("erl_iroh=info".parse().unwrap())) .init(); let args = Args::parse(); let bot = Bot::builder(args.name) .cookie(args.cookie) .powers(Powers::all()) .build() .await?; bot.listen_iroh().await?; println!("node: {}", bot.node_name()); println!("endpoint id: {}", bot.endpoint_id()); println!("powers: {}", bot.powers()); println!("waiting for peers (Ctrl-C to quit)…"); tokio::signal::ctrl_c().await?; println!("bye"); Ok(()) }