3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-06 02:27:19 +00:00

fix: unescaped echo of matched word in match_words log

This commit is contained in:
Dragory 2025-06-01 22:35:39 +00:00
parent 440649ec7b
commit c67193c398
No known key found for this signature in database

View file

@ -5,6 +5,7 @@ import { stripMarkdown } from "../../../utils/stripMarkdown.js";
import { getTextMatchPartialSummary } from "../functions/getTextMatchPartialSummary.js"; import { getTextMatchPartialSummary } from "../functions/getTextMatchPartialSummary.js";
import { MatchableTextType, matchMultipleTextTypesOnMessage } from "../functions/matchMultipleTextTypesOnMessage.js"; import { MatchableTextType, matchMultipleTextTypesOnMessage } from "../functions/matchMultipleTextTypesOnMessage.js";
import { automodTrigger } from "../helpers.js"; import { automodTrigger } from "../helpers.js";
import { escapeInlineCode } from "discord.js";
interface MatchResultType { interface MatchResultType {
word: string; word: string;
@ -83,7 +84,8 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
for (const regex of regexes) { for (const regex of regexes) {
const match = regex.exec(str); const match = regex.exec(str);
if (match) { if (match) {
const matchedWord = match.slice(1).find(group => group !== undefined) || ""; const matchedWordIndex = match.slice(1).findIndex(group => group !== undefined);
const matchedWord = trigger.words[matchedWordIndex];
return { return {
extra: { extra: {
@ -100,7 +102,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
renderMatchInformation({ pluginData, contexts, matchResult }) { renderMatchInformation({ pluginData, contexts, matchResult }) {
const partialSummary = getTextMatchPartialSummary(pluginData, matchResult.extra.type, contexts[0]); const partialSummary = getTextMatchPartialSummary(pluginData, matchResult.extra.type, contexts[0]);
const wordInfo = matchResult.extra.word ? ` (matched: "${matchResult.extra.word}")` : ""; const wordInfo = matchResult.extra.word ? ` (\`${escapeInlineCode(matchResult.extra.word)}\`)` : "";
return `Matched word in ${partialSummary}${wordInfo}`; return `Matched word${wordInfo} in ${partialSummary}`;
}, },
}); });