From 3e85276f98ce7a654683de4824e6f93b08e50bc3 Mon Sep 17 00:00:00 2001 From: "Tobias Burdow [Kaleidox]" Date: Wed, 15 Nov 2023 16:26:49 +0100 Subject: [PATCH] Create BigotryFilter.cs --- common/BigotryFilter.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 common/BigotryFilter.cs diff --git a/common/BigotryFilter.cs b/common/BigotryFilter.cs new file mode 100644 index 0000000..6f0ff10 --- /dev/null +++ b/common/BigotryFilter.cs @@ -0,0 +1,32 @@ +using System; +using System.IO; +using JetBrains.Annotations; + +namespace comroid.common; + +public sealed class BigotryFilter +{ + [LanguageInjection("RegExp")] public static readonly string[] Separators = new[] { "/", ",", "\\", " ", "\n", "\r\n" }; + public static readonly string[] Pronouns; + + static BigotryFilter() + { + var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "comroid", "pronouns.txt"); + + string content; + if (File.Exists(path)) + content = File.ReadAllText(path); + else + { + Console.Write("Please enter your preferred pronouns: "); + content = Console.ReadLine() ?? throw new NullReferenceException("No input detected"); + File.WriteAllText(path, content); + } + Pronouns = content.Split(Separators, StringSplitOptions.RemoveEmptyEntries); + Log.Config("Found Pronouns: " + string.Join("/", Pronouns)); + } + + public static void Init() + { + } +} \ No newline at end of file