1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00
This commit is contained in:
Kumpelinus 2025-07-04 23:45:30 -07:00 committed by GitHub
commit f489eadc56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,39 @@
//! A simple bot that repeats chat messages sent by other players.
use azalea::prelude::*;
use azalea_protocol::packets::game::ClientboundGamePacket;
#[tokio::main]
async fn main() {
let account = Account::offline("bot");
// or let account = Account::microsoft("email").await.unwrap();
ClientBuilder::new()
.set_handler(handle)
.reconnect_after(None)
.start(account, "localhost")
.await
.unwrap();
}
#[derive(Default, Clone, Component)]
pub struct State {}
async fn handle(bot: Client, event: Event, _state: State) -> anyhow::Result<()> {
match event {
Event::Packet(packet) => {
if let ClientboundGamePacket::ResourcePackPush(push_pack) = packet.as_ref() {
println!("Resource Pack URL: {}", push_pack.url);
bot.disconnect();
}
}
Event::Disconnect(_) => {
std::process::exit(0);
}
_ => {}
}
Ok(())
}