From 06068377bd17f95bdafe86ff14bab1d0d852aa53 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sun, 2 Oct 2022 14:58:42 -0500 Subject: New example (#24) the example isn't finished but it's finished enough --- examples/echo.rs | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 examples/echo.rs (limited to 'examples/echo.rs') diff --git a/examples/echo.rs b/examples/echo.rs deleted file mode 100644 index c9e46a09..00000000 --- a/examples/echo.rs +++ /dev/null @@ -1,38 +0,0 @@ -use azalea::{Account, Event}; - -let account = Account::offline("bot"); -// or let account = azalea::Account::microsoft("access token").await; - -let bot = account.join("localhost".try_into().unwrap()).await.unwrap(); - -loop { - match bot.next().await { - Event::Message(m) { - if m.username == bot.username { return }; - bot.chat(m.message).await; - }, - Event::Kicked(m) { - println!(m); - bot.reconnect().await.unwrap(); - }, - Event::Hunger(h) { - if !h.using_held_item() && h.hunger <= 17 { - match bot.hold(azalea::ItemGroup::Food).await { - Ok(_) => {}, - Err(e) => { - println!("{}", e); - break; - } - } - match bot.use_held_item().await { - Ok(_) => {}, - Err(e) => { - println!("{}", e); - break; - } - } - } - } - _ => {} - } -} -- cgit v1.2.3