3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Replace transliteration package use with a custom normalizer function

Huge thanks to Nobody#6075 for doing most of the work for it!
This commit is contained in:
Dragory 2020-08-05 03:38:14 +03:00
parent ceb567ad9a
commit 925cf718e7
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
6 changed files with 207 additions and 42 deletions

View file

@ -1,11 +1,11 @@
import * as t from "io-ts";
import { transliterate } from "transliteration";
import { automodTrigger } from "../helpers";
import { disableInlineCode, verboseChannelMention } from "../../../utils";
import { MatchableTextType, matchMultipleTextTypesOnMessage } from "../functions/matchMultipleTextTypesOnMessage";
import { getTextMatchPartialSummary } from "../functions/getTextMatchPartialSummary";
import { allowTimeout } from "../../../RegExpRunner";
import { TRegex } from "../../../validatorUtils";
import { normalizeText } from "../../../utils/normalizeText";
interface MatchResultType {
pattern: string;
@ -43,7 +43,7 @@ export const MatchRegexTrigger = automodTrigger<MatchResultType>()({
for await (let [type, str] of matchMultipleTextTypesOnMessage(pluginData, trigger, context.message)) {
if (trigger.normalize) {
str = transliterate(str);
str = normalizeText(str);
}
for (const sourceRegex of trigger.patterns) {

View file

@ -1,10 +1,10 @@
import * as t from "io-ts";
import { transliterate } from "transliteration";
import escapeStringRegexp from "escape-string-regexp";
import { automodTrigger } from "../helpers";
import { disableInlineCode, verboseChannelMention } from "../../../utils";
import { MatchableTextType, matchMultipleTextTypesOnMessage } from "../functions/matchMultipleTextTypesOnMessage";
import { getTextMatchPartialSummary } from "../functions/getTextMatchPartialSummary";
import { normalizeText } from "../../../utils/normalizeText";
interface MatchResultType {
word: string;
@ -48,7 +48,7 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
for await (let [type, str] of matchMultipleTextTypesOnMessage(pluginData, trigger, context.message)) {
if (trigger.normalize) {
str = transliterate(str);
str = normalizeText(str);
}
const looseMatchingThreshold = Math.min(Math.max(trigger.loose_matching_threshold, 1), 64);