3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

automod: add strip_markdown option to match_words trigger

This commit is contained in:
Dragory 2020-09-15 01:07:28 +03:00
parent a5c40a58bf
commit cb5723db7c
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -5,6 +5,7 @@ import { disableInlineCode, verboseChannelMention } from "../../../utils";
import { MatchableTextType, matchMultipleTextTypesOnMessage } from "../functions/matchMultipleTextTypesOnMessage";
import { getTextMatchPartialSummary } from "../functions/getTextMatchPartialSummary";
import { normalizeText } from "../../../utils/normalizeText";
import { stripMarkdown } from "../../../utils/stripMarkdown";
interface MatchResultType {
word: string;
@ -19,6 +20,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
normalize: t.boolean,
loose_matching: t.boolean,
loose_matching_threshold: t.number,
strip_markdown: t.boolean,
match_messages: t.boolean,
match_embeds: t.boolean,
match_visible_names: t.boolean,
@ -33,6 +35,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
normalize: false,
loose_matching: false,
loose_matching_threshold: 4,
strip_markdown: false,
match_messages: true,
match_embeds: true,
match_visible_names: false,
@ -47,6 +50,10 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
}
for await (let [type, str] of matchMultipleTextTypesOnMessage(pluginData, trigger, context.message)) {
if (trigger.strip_markdown) {
str = stripMarkdown(str);
}
if (trigger.normalize) {
str = normalizeText(str);
}