From c2f9868746a6be4b4f115cfe465b2d091e20a58e Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Tue, 15 Nov 2022 12:43:07 +0200 Subject: [PATCH] More checks --- DiscordChatExporter.Cli/Sanctions.cs | 17 +++++++++++++++-- DiscordChatExporter.Gui/Sanctions.cs | 13 +++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/DiscordChatExporter.Cli/Sanctions.cs b/DiscordChatExporter.Cli/Sanctions.cs index 104f786..c76d18a 100644 --- a/DiscordChatExporter.Cli/Sanctions.cs +++ b/DiscordChatExporter.Cli/Sanctions.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Microsoft.Win32; namespace DiscordChatExporter.Cli; @@ -18,9 +20,20 @@ public static class Sanctions if (isSkipped) return; + var locale = CultureInfo.CurrentCulture.Name; + + var region = + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? Registry.CurrentUser + .OpenSubKey(@"Control Panel\International\Geo", false)? + .GetValue("Name") as string + : null; + var isSanctioned = - CultureInfo.CurrentCulture.Name.EndsWith("-ru", StringComparison.OrdinalIgnoreCase) || - CultureInfo.CurrentCulture.Name.EndsWith("-by", StringComparison.OrdinalIgnoreCase); + locale.EndsWith("-ru", StringComparison.OrdinalIgnoreCase) || + locale.EndsWith("-by", StringComparison.OrdinalIgnoreCase) || + string.Equals(region, "ru", StringComparison.OrdinalIgnoreCase) || + string.Equals(region, "by", StringComparison.OrdinalIgnoreCase); if (!isSanctioned) return; diff --git a/DiscordChatExporter.Gui/Sanctions.cs b/DiscordChatExporter.Gui/Sanctions.cs index 89ae9ae..251a713 100644 --- a/DiscordChatExporter.Gui/Sanctions.cs +++ b/DiscordChatExporter.Gui/Sanctions.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Runtime.CompilerServices; using System.Windows; +using Microsoft.Win32; namespace DiscordChatExporter.Gui; @@ -19,9 +20,17 @@ public static class Sanctions if (isSkipped) return; + var locale = CultureInfo.CurrentCulture.Name; + + var region = Registry.CurrentUser + .OpenSubKey(@"Control Panel\International\Geo", false)? + .GetValue("Name") as string; + var isSanctioned = - CultureInfo.CurrentCulture.Name.EndsWith("-ru", StringComparison.OrdinalIgnoreCase) || - CultureInfo.CurrentCulture.Name.EndsWith("-by", StringComparison.OrdinalIgnoreCase); + locale.EndsWith("-ru", StringComparison.OrdinalIgnoreCase) || + locale.EndsWith("-by", StringComparison.OrdinalIgnoreCase) || + string.Equals(region, "ru", StringComparison.OrdinalIgnoreCase) || + string.Equals(region, "by", StringComparison.OrdinalIgnoreCase); if (!isSanctioned) return;