blob: 8c11d6e7f672549089694ceaeae60ee5d6ccb744 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
//! A simple bot that repeats chat messages sent by other players.
use azalea::prelude::*;
#[tokio::main]
async fn main() {
let account = Account::offline("bot");
// or let account = Account::microsoft("email").await;
azalea::start(azalea::Options {
account,
address: "localhost",
state: State::default(),
plugins: vec![],
handle,
})
.await
.unwrap();
}
#[derive(Default, Clone)]
pub struct State {}
async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
match event {
Event::Chat(m) => {
if m.username == bot.username {
return Ok(()); // ignore our own messages
};
bot.chat(m.content).await;
}
_ => {}
}
Ok(())
}
|