const silentExactRegexByToken = new Map<string, RegExp>(); const silentTrailingRegexByToken = new Map<string, RegExp>(); const silentLeadingAttachedRegexByToken = new Map<string, RegExp>();
function getSilentExactRegex(token: string): RegExp { const cached = silentExactRegexByToken.get(token); if (cached) { return cached;
} const escaped = escapeRegExp(token); const regex = new RegExp(`^\\s*${escaped}\\s*$`, "i");
silentExactRegexByToken.set(token, regex); return regex;
}
function getSilentTrailingRegex(token: string): RegExp { const cached = silentTrailingRegexByToken.get(token); if (cached) { return cached;
} const escaped = escapeRegExp(token); const regex = new RegExp(`(?:^|\\s+|\\*+)${escaped}\\s*$`, "i");
silentTrailingRegexByToken.set(token, regex); return regex;
}
export function isSilentReplyText(
text: string | undefined,
token: string = SILENT_REPLY_TOKEN,
): boolean { if (!text) { returnfalse;
} // Match only the exact silent token with optional surrounding whitespace. // This prevents substantive replies ending with NO_REPLY from being suppressed (#19537). return getSilentExactRegex(token).test(text);
}
type SilentReplyActionEnvelope = { action?: unknown };
const silentLeadingRegexByToken = new Map<string, RegExp>();
function getSilentLeadingAttachedRegex(token: string): RegExp { const cached = silentLeadingAttachedRegexByToken.get(token); if (cached) { return cached;
} const escaped = escapeRegExp(token); // Match one or more leading occurrences of the token where the final token // is glued directly to visible word-start content (for example // `NO_REPLYhello`), without treating punctuation-start text like // `NO_REPLY: explanation` as a silent prefix. const regex = new RegExp(`^\\s*(?:${escaped}\\s+)*${escaped}(?=[\\p{L}\\p{N}])`, "iu");
silentLeadingAttachedRegexByToken.set(token, regex); return regex;
}
function getSilentLeadingRegex(token: string): RegExp { const cached = silentLeadingRegexByToken.get(token); if (cached) { return cached;
} const escaped = escapeRegExp(token); // Match one or more leading occurrences of the token, each optionally followed by whitespace const regex = new RegExp(`^(?:\\s*${escaped})+\\s*`, "i");
silentLeadingRegexByToken.set(token, regex); return regex;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.