fix(auto-reply): land #31080 from @scoootscooob

Co-authored-by: scoootscooob <zhentongfan@gmail.com>
This commit is contained in:
Peter Steinberger
2026-03-02 01:17:35 +00:00
parent e7cd4bf1bd
commit a6a742f3d0
5 changed files with 101 additions and 2 deletions

View File

@@ -17,6 +17,16 @@ export function isSilentReplyText(
return new RegExp(`^\\s*${escaped}\\s*$`).test(text);
}
/**
* Strip a trailing silent reply token from mixed-content text.
* Returns the remaining text with the token removed (trimmed).
* If the result is empty, the entire message should be treated as silent.
*/
export function stripSilentToken(text: string, token: string = SILENT_REPLY_TOKEN): string {
const escaped = escapeRegExp(token);
return text.replace(new RegExp(`(?:^|\\s+)${escaped}\\s*$`), "").trim();
}
export function isSilentReplyPrefixText(
text: string | undefined,
token: string = SILENT_REPLY_TOKEN,