aboutsummaryrefslogtreecommitdiff
path: root/azalea/examples/echo.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea/examples/echo.rs')
-rwxr-xr-xazalea/examples/echo.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/azalea/examples/echo.rs b/azalea/examples/echo.rs
index 51896e53..5f6cf072 100755
--- a/azalea/examples/echo.rs
+++ b/azalea/examples/echo.rs
@@ -24,10 +24,12 @@ 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
+ if let (Some(sender), content) = m.split_sender_and_content() {
+ if sender == bot.game_profile.name {
+ return Ok(()); // ignore our own messages
+ }
+ bot.chat(&content).await?;
};
- bot.chat(m.content).await;
}
_ => {}
}