diff --git a/Checks/ListChecks.cs b/Checks/ListChecks.cs index 6e75a749..dd07c9b1 100644 --- a/Checks/ListChecks.cs +++ b/Checks/ListChecks.cs @@ -4,10 +4,10 @@ namespace Cliptok.Checks { public class ListChecks { - // Map of Cyrillic to Latin characters, to catch attempted bypasses using Cyrillic lookalikes - // is - public static Dictionary alphabetMap = new() + // Map of lookalike to Latin characters, to catch attempted bypasses using different language lookalikes + public static Dictionary lookalikeAlphabetMap = new() { + // is { "А", "A" }, { "В", "B" }, { "С", "C" }, @@ -47,15 +47,45 @@ public class ListChecks { "ѡ", "w" }, { "х", "x" }, { "у", "y" }, - { "У", "y" } - }; + { "У", "y" }, + // is + { "Α", "A" }, + { "Β", "B" }, + { "Ε", "E" }, + { "Η", "H" }, + { "Ι", "I" }, + { "Κ", "K" }, + { "Μ", "M" }, + { "Ν", "N" }, + { "Ο", "O" }, + { "Ρ", "P" }, + { "Τ", "T" }, + { "Χ", "X" }, + { "Υ", "Y" }, + { "Ζ", "Z" }, + { "α", "a" }, + { "β", "b" }, + { "ε", "e" }, + { "η", "h" }, + { "ι", "i" }, + { "κ", "k" }, + { "μ", "m" }, + { "ν", "n" }, + { "ο", "o" }, + { "ρ", "p" }, + { "τ", "t" }, + { "χ", "x" }, + { "υ", "y" }, + { "ζ", "z" }, + }; + public static (bool success, string? flaggedWord) CheckForNaughtyWords(string input, WordListJson naughtyWordList) { - // Replace any Cyrillic letters found in message with Latin characters, if in the dictionary - foreach (var letter in alphabetMap) + // Replace any lookalike letters found in message with Latin characters, if in the dictionary + foreach (var letter in lookalikeAlphabetMap) input = input.Replace(letter.Key, letter.Value); - + string[] naughtyWords = naughtyWordList.Words; input = input.Replace("\0", ""); if (naughtyWordList.WholeWord) diff --git a/Events/MessageEvent.cs b/Events/MessageEvent.cs index 79ef460a..609d58be 100644 --- a/Events/MessageEvent.cs +++ b/Events/MessageEvent.cs @@ -646,7 +646,7 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe // attempted to ping @everyone/@here var msgContent = message.Content; - foreach (var letter in Checks.ListChecks.alphabetMap) + foreach (var letter in Checks.ListChecks.lookalikeAlphabetMap) msgContent = msgContent.Replace(letter.Key, letter.Value); if (Program.cfgjson.EveryoneFilter && !member.Roles.Any(role => Program.cfgjson.EveryoneExcludedRoles.Contains(role.Id)) && !Program.cfgjson.EveryoneExcludedChannels.Contains(channel.Id) && (msgContent.Contains("@everyone") || msgContent.Contains("@here"))) {