diff --git a/crates/xmedia-bot/src/handlers/mod.rs b/crates/xmedia-bot/src/handlers/mod.rs index b2a834d..bc8a2d4 100644 --- a/crates/xmedia-bot/src/handlers/mod.rs +++ b/crates/xmedia-bot/src/handlers/mod.rs @@ -265,11 +265,10 @@ pub(crate) async fn handle_message( break; } } - } else if message.chat.is_group() - || message.chat.is_supergroup() - && extract_urls(&message) - .iter() - .any(|url| x_media::site::cache_key(url).is_some()) + } else if (message.chat.is_group() || message.chat.is_supergroup()) + && extract_urls(&message) + .iter() + .any(|url| x_media::site::cache_key(url).is_some()) { // A supported link in a group used to be dropped in silence, which // reads as a broken bot (the command menu is registered globally, so @@ -470,5 +469,24 @@ mod tests { vec!["EditMessageCaption", "SendMessage"], "a channel must not get the group hint" ); + + // And an *unsupported* link in a group stays silent too: the hint is + // for links a site adapter claims (the branch's own filter). + let unsupported: Message = serde_json::from_value(serde_json::json!({ + "message_id": 4, + "date": 0, + "chat": { "id": -100, "type": "group", "title": "g" }, + "text": "https://example.com/x", + "entities": [{ "type": "url", "offset": 0, "length": 19 }], + })) + .expect("a minimal group message deserializes"); + + handle_message(&ctx, &bot, unsupported).await.unwrap(); + + assert_eq!( + api.methods(), + vec!["EditMessageCaption", "SendMessage"], + "an unsupported link must not get the hint" + ); } }