Distributed Erlang over iroh P2P + TLS, with a bot powers SDK
0

Configure Feed

Select the types of activity you want to include in your feed.

erl-iroh / examples / bot.rs
1.3 kB 48 lines
1//! Minimal bot that listens on iroh and prints its endpoint id. 2//! 3//! ```bash 4//! cargo run --example bot -- --name scout --cookie secret 5//! ``` 6 7use clap::Parser; 8use erl_iroh::bot::Bot; 9use erl_iroh::powers::Powers; 10use tracing_subscriber::EnvFilter; 11 12#[derive(Parser, Debug)] 13#[command(name = "bot", about = "erl-iroh bot that listens for peers")] 14struct Args { 15 /// Short node name (becomes name@iroh). 16 #[arg(long, default_value = "scout")] 17 name: String, 18 19 /// Erlang distribution cookie. 20 #[arg(long, default_value = "erl-iroh-cookie")] 21 cookie: String, 22} 23 24#[tokio::main] 25async fn main() -> erl_iroh::Result<()> { 26 tracing_subscriber::fmt() 27 .with_env_filter(EnvFilter::from_default_env().add_directive("erl_iroh=info".parse().unwrap())) 28 .init(); 29 30 let args = Args::parse(); 31 32 let bot = Bot::builder(args.name) 33 .cookie(args.cookie) 34 .powers(Powers::all()) 35 .build() 36 .await?; 37 38 bot.listen_iroh().await?; 39 40 println!("node: {}", bot.node_name()); 41 println!("endpoint id: {}", bot.endpoint_id()); 42 println!("powers: {}", bot.powers()); 43 println!("waiting for peers (Ctrl-C to quit)…"); 44 45 tokio::signal::ctrl_c().await?; 46 println!("bye"); 47 Ok(()) 48}