From 5710f4b157adeea94653d610bca7b69920b46c15 Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Mon, 26 Aug 2024 16:52:53 +1200 Subject: [PATCH] PreSendModeration: Fix filtering for real --- src/plugins/preSendModeration/filters.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/preSendModeration/filters.ts b/src/plugins/preSendModeration/filters.ts index a21802bab0..a58dc3d5d7 100644 --- a/src/plugins/preSendModeration/filters.ts +++ b/src/plugins/preSendModeration/filters.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { findByCodeLazy, findLazy } from "@webpack"; +import { find, findByCodeLazy } from "@webpack"; const splitWords = findByCodeLazy("/[\\p{Pd}\\p{Pc}\\p{Po}]/gu.test"); @@ -12,12 +12,11 @@ const splitWords = findByCodeLazy("/[\\p{Pd}\\p{Pc}\\p{Po}]/gu.test"); const Trie = findByCodeLazy("this.trie.suffix"); const makeTrieSearchFromWordListItem = (item: any) => { - let module: any[]; - const trie = new Trie(); + let trie: typeof Trie; return (search: string) => { - if (module === undefined) { - module = findLazy(m => Array.isArray(m) && m.includes(item)); - trie.addWords(module); + if (trie === undefined) { + trie = new Trie(); + trie.addWords(find(m => Array.isArray(m) && m.includes(item))); } return trie.search(splitWords(search)); }; @@ -27,4 +26,4 @@ export const Filters = { Profanity: makeTrieSearchFromWordListItem("fuck"), "Sexual Content": makeTrieSearchFromWordListItem("69ing"), Slurs: makeTrieSearchFromWordListItem("fags"), -}; +} as Record any>;