mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 10:27:38 +00:00
fix: harden discord audio preflight mention detection (#32136) (thanks @jnMetaCode)
This commit is contained in:
@@ -504,11 +504,13 @@ export async function preflightDiscordMessage(
|
||||
const hasAudioAttachment = message.attachments?.some((att: { content_type?: string }) =>
|
||||
att.content_type?.startsWith("audio/"),
|
||||
);
|
||||
const hasTypedText = Boolean(message.content?.trim());
|
||||
const needsPreflightTranscription =
|
||||
!isDirectMessage &&
|
||||
shouldRequireMention &&
|
||||
hasAudioAttachment &&
|
||||
!baseText &&
|
||||
// `baseText` includes media placeholders; gate on typed text only.
|
||||
!hasTypedText &&
|
||||
mentionRegexes.length > 0;
|
||||
|
||||
if (needsPreflightTranscription) {
|
||||
@@ -541,10 +543,11 @@ export async function preflightDiscordMessage(
|
||||
}
|
||||
}
|
||||
|
||||
const mentionText = hasTypedText ? baseText : "";
|
||||
const wasMentioned =
|
||||
!isDirectMessage &&
|
||||
matchesMentionWithExplicit({
|
||||
text: baseText,
|
||||
text: mentionText,
|
||||
mentionRegexes,
|
||||
explicit: {
|
||||
hasAnyMention,
|
||||
|
||||
Reference in New Issue
Block a user