From fae414790463621ed015197d075143b8eaaaf6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Wed, 12 Mar 2025 19:23:40 +0900 Subject: [PATCH] wip --- packages/backend/src/core/AntennaService.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/AntennaService.ts b/packages/backend/src/core/AntennaService.ts index fec0c8f1b8..da02a75beb 100644 --- a/packages/backend/src/core/AntennaService.ts +++ b/packages/backend/src/core/AntennaService.ts @@ -96,8 +96,12 @@ export function createAntennaFilter(antenna: MiAntenna): AntennaFilter { if (antenna.useRegex) { // 元々はAND検索を行うために2次元配列としてもっていた歴史的経緯がある. // 正規表現の時は1行に付き1パターンとするため、[n][0]にパターンの内容すべてが格納されているものとして扱う. - const keywordsPatterns = keywords.map(line => new RE2(line[0])); - const excludeKeywordsPatterns = excludeKeywords.map(line => new RE2(line[0])); + const createRE2 = (pattern: string): RE2 => { + const regexp = pattern.match(/^\/(.+)\/(.*)$/) ?? []; + return new RE2(regexp[1], regexp[2]); + }; + const keywordsPatterns = keywords.map(line => createRE2(line[0])); + const excludeKeywordsPatterns = excludeKeywords.map(line => createRE2(line[0])); if (keywords.length > 0 && excludeKeywords.length > 0) { return (target: string) => antennaFilters.regex.includeAndExclude(target, keywordsPatterns, excludeKeywordsPatterns); @@ -262,6 +266,7 @@ export class AntennaService implements OnApplicationShutdown { caseSensitive: ps.caseSensitive, localOnly: ps.localOnly, excludeBots: ps.excludeBots, + useRegex: ps.useRegex, withReplies: ps.withReplies, withFile: ps.withFile, }); @@ -317,6 +322,7 @@ export class AntennaService implements OnApplicationShutdown { caseSensitive: ps.caseSensitive, localOnly: ps.localOnly, excludeBots: ps.excludeBots, + useRegex: ps.useRegex, withReplies: ps.withReplies, withFile: ps.withFile, isActive: true,