Skip to content

Commit e2070ee

Browse files
committed
Merge branch 'main' into floatingmilkshake/dsp-command-migration
2 parents da3d4a2 + d7fbd0c commit e2070ee

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

Checks/ListChecks.cs

+38-8
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace Cliptok.Checks
44
{
55
public class ListChecks
66
{
7-
// Map of Cyrillic to Latin characters, to catch attempted bypasses using Cyrillic lookalikes
8-
// <string, string> is <Cyrillic, Latin>
9-
public static Dictionary<string, string> alphabetMap = new()
7+
// Map of lookalike to Latin characters, to catch attempted bypasses using different language lookalikes
8+
public static Dictionary<string, string> lookalikeAlphabetMap = new()
109
{
10+
// <string, string> is <Cyrillic, Latin>
1111
{ "А", "A" },
1212
{ "В", "B" },
1313
{ "С", "C" },
@@ -47,15 +47,45 @@ public class ListChecks
4747
{ "ѡ", "w" },
4848
{ "х", "x" },
4949
{ "у", "y" },
50-
{ "У", "y" }
51-
};
50+
{ "У", "y" },
5251

52+
// <string, string> is <Greek, Latin>
53+
{ "Α", "A" },
54+
{ "Β", "B" },
55+
{ "Ε", "E" },
56+
{ "Η", "H" },
57+
{ "Ι", "I" },
58+
{ "Κ", "K" },
59+
{ "Μ", "M" },
60+
{ "Ν", "N" },
61+
{ "Ο", "O" },
62+
{ "Ρ", "P" },
63+
{ "Τ", "T" },
64+
{ "Χ", "X" },
65+
{ "Υ", "Y" },
66+
{ "Ζ", "Z" },
67+
{ "α", "a" },
68+
{ "β", "b" },
69+
{ "ε", "e" },
70+
{ "η", "h" },
71+
{ "ι", "i" },
72+
{ "κ", "k" },
73+
{ "μ", "m" },
74+
{ "ν", "n" },
75+
{ "ο", "o" },
76+
{ "ρ", "p" },
77+
{ "τ", "t" },
78+
{ "χ", "x" },
79+
{ "υ", "y" },
80+
{ "ζ", "z" },
81+
};
82+
5383
public static (bool success, string? flaggedWord) CheckForNaughtyWords(string input, WordListJson naughtyWordList)
5484
{
55-
// Replace any Cyrillic letters found in message with Latin characters, if in the dictionary
56-
foreach (var letter in alphabetMap)
85+
// Replace any lookalike letters found in message with Latin characters, if in the dictionary
86+
foreach (var letter in lookalikeAlphabetMap)
5787
input = input.Replace(letter.Key, letter.Value);
58-
88+
5989
string[] naughtyWords = naughtyWordList.Words;
6090
input = input.Replace("\0", "");
6191
if (naughtyWordList.WholeWord)

Events/MessageEvent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
646646

647647
// attempted to ping @everyone/@here
648648
var msgContent = message.Content;
649-
foreach (var letter in Checks.ListChecks.alphabetMap)
649+
foreach (var letter in Checks.ListChecks.lookalikeAlphabetMap)
650650
msgContent = msgContent.Replace(letter.Key, letter.Value);
651651
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")))
652652
{

0 commit comments

Comments
 (0)