From 163e24b18861a05523237e41d603d17348fbb389 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 12 Aug 2025 04:23:36 -0400 Subject: improved whisper regex and autofill microsoft code on login --- azalea-auth/src/auth.rs | 5 +++-- azalea-client/src/plugins/chat/mod.rs | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/azalea-auth/src/auth.rs b/azalea-auth/src/auth.rs index 51e44a70..f079f2c8 100644 --- a/azalea-auth/src/auth.rs +++ b/azalea-auth/src/auth.rs @@ -402,9 +402,10 @@ pub async fn interactive_get_ms_auth_token( ) -> Result, GetMicrosoftAuthTokenError> { let res = get_ms_link_code(client, client_id, scope).await?; trace!("Device code response: {:?}", res); + let verification_uri = &res.verification_uri; + let user_code = &res.user_code; println!( - "Go to \x1b[1m{}\x1b[m and enter the code \x1b[1m{}\x1b[m for \x1b[1m{}\x1b[m", - res.verification_uri, res.user_code, email + "Go to \x1b[1m{verification_uri}?otc={user_code}\x1b[m and enter the code \x1b[1m{user_code}\x1b[m for \x1b[1m{email}\x1b[m", ); get_ms_auth_token(client, res, client_id).await diff --git a/azalea-client/src/plugins/chat/mod.rs b/azalea-client/src/plugins/chat/mod.rs index 2e98fdf8..856184cc 100644 --- a/azalea-client/src/plugins/chat/mod.rs +++ b/azalea-client/src/plugins/chat/mod.rs @@ -63,14 +63,21 @@ impl ChatPacket { match self { ChatPacket::System(p) => { let message = p.content.to_string(); - - // Overlay messages aren't in chat + // overlay messages aren't in chat if p.overlay { return (None, message); } - // It's a system message, so we'll have to match the content with regex - if let Some(m) = regex!("^<([a-zA-Z_0-9]{1,16})> (?:-> me)?(.+)$").captures(&message) { + // it's a system message, so we'll have to match the content with regex + + if let Some(m) = + regex!("^<([a-zA-Z_0-9]{1,16})> (?:-> me)?(.+)$").captures(&message) + { + return (Some(m[1].to_string()), m[2].to_string()); + } + // 2b2t whispers + if let Some(m) = regex!("^([a-zA-Z_0-9]{1,16}) whispers: (.+)$").captures(&message) + { return (Some(m[1].to_string()), m[2].to_string()); } @@ -132,15 +139,11 @@ impl ChatPacket { match self { ChatPacket::System(p) => { let message = p.content.to_string(); - - // Overlay messages aren't in chat if p.overlay { return false; } - - // It's a system message, so we'll have to match the content with regex - if let Some(m) = regex!("^(-> me)?(?:.+)$").captures(&message) { - return m.get(1).is_some(); + if regex!("^(-> me|[a-zA-Z_0-9]{1,16} whispers: )").is_match(&message) { + return true; } false -- cgit v1.2.3