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:
parent
ceb567ad9a
commit
925cf718e7
6 changed files with 207 additions and 42 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue