mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-22 05:57:30 +00:00
Add region-based sanctions
This commit is contained in:
50
DiscordChatExporter.Gui/Sanctions.cs
Normal file
50
DiscordChatExporter.Gui/Sanctions.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
|
||||
namespace DiscordChatExporter.Gui;
|
||||
|
||||
public static class Sanctions
|
||||
{
|
||||
[ModuleInitializer]
|
||||
internal static void Verify()
|
||||
{
|
||||
var isSkipped = string.Equals(
|
||||
Environment.GetEnvironmentVariable("RUSNI"),
|
||||
"PYZDA",
|
||||
StringComparison.OrdinalIgnoreCase
|
||||
);
|
||||
|
||||
if (isSkipped)
|
||||
return;
|
||||
|
||||
var isSanctioned = new[]
|
||||
{
|
||||
CultureInfo.CurrentCulture,
|
||||
CultureInfo.CurrentUICulture,
|
||||
CultureInfo.InstalledUICulture,
|
||||
CultureInfo.DefaultThreadCurrentCulture,
|
||||
CultureInfo.DefaultThreadCurrentUICulture
|
||||
}.Any(c =>
|
||||
c is not null && (
|
||||
c.Name.Contains("-ru", StringComparison.OrdinalIgnoreCase) ||
|
||||
c.Name.Contains("-by", StringComparison.OrdinalIgnoreCase)
|
||||
)
|
||||
);
|
||||
|
||||
if (!isSanctioned)
|
||||
return;
|
||||
|
||||
MessageBox.Show(
|
||||
"You cannot use this software on the territory of a terrorist state. " +
|
||||
"Set the environment variable `RUSNI=PYZDA` if you wish to override this check.",
|
||||
"Sanctioned region",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error
|
||||
);
|
||||
|
||||
Environment.Exit(0xFACC);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user