From 5db1aefcbbb662e81bf843b160fa94b35367d65f Mon Sep 17 00:00:00 2001 From: jetsparrow Date: Mon, 19 Aug 2019 21:37:01 +0300 Subject: [PATCH] moved minimum word lengths to config --- AntiAntiSwearingBot/Config.cs | 2 ++ AntiAntiSwearingBot/Unbleeper.cs | 4 ++-- AntiAntiSwearingBot/aasb.cfg.json | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/AntiAntiSwearingBot/Config.cs b/AntiAntiSwearingBot/Config.cs index c8f4f03..b8ce4c1 100644 --- a/AntiAntiSwearingBot/Config.cs +++ b/AntiAntiSwearingBot/Config.cs @@ -11,6 +11,8 @@ public struct UnbleeperSettings { public string BleepedSwearsRegex { get; private set; } + public int MinAmbiguousWordLength { get; private set; } + public int MinWordLength { get; private set; } } public struct SearchDictionarySettings diff --git a/AntiAntiSwearingBot/Unbleeper.cs b/AntiAntiSwearingBot/Unbleeper.cs index 239e53e..2ffb392 100644 --- a/AntiAntiSwearingBot/Unbleeper.cs +++ b/AntiAntiSwearingBot/Unbleeper.cs @@ -36,8 +36,8 @@ namespace AntiAntiSwearingBot !Language.IsTelegramMention(w) && Language.HasNonWordChars(w) && !Language.IsHashTag(w) - && (Language.HasWordChars(w) || w.Length > 5) - && w.Length > 2 + && (Language.HasWordChars(w) || w.Length >= Cfg.MinAmbiguousWordLength) + && w.Length >= Cfg.MinWordLength && BleepedSwearsRegex.IsMatch(w) ) .ToArray(); diff --git a/AntiAntiSwearingBot/aasb.cfg.json b/AntiAntiSwearingBot/aasb.cfg.json index d07d182..5060a9b 100644 --- a/AntiAntiSwearingBot/aasb.cfg.json +++ b/AntiAntiSwearingBot/aasb.cfg.json @@ -1,6 +1,8 @@ { "Unbleeper": { - "BleepedSwearsRegex": "[а-яА-Я@\\*#]+" + "BleepedSwearsRegex": "[а-яА-Я@\\*#]+", + "MinWordLength": 3, + "MinAmbiguousWordLength": 5 }, "SearchDictionary": { "DictionaryPath": "dict/ObsceneDictionaryRu.txt",