Add region-based sanctions

pull/965/head
Oleksii Holub 2 years ago
parent 9639b6c550
commit 001ea7e495

@ -0,0 +1,49 @@
using System;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
namespace DiscordChatExporter.Cli;
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;
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine(
"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."
);
Console.ResetColor();
Environment.Exit(0xFACC);
}
}

@ -9,16 +9,16 @@ using System.Windows;
using System.Windows.Threading;
#endif
namespace DiscordChatExporter.Gui
namespace DiscordChatExporter.Gui;
public class Bootstrapper : Bootstrapper<RootViewModel>
{
public class Bootstrapper : Bootstrapper<RootViewModel>
{
protected override void OnStart()
{
base.OnStart();
// Set default theme
// (preferred theme will be chosen later, once the settings are loaded)
// (preferred theme will be set later, once the settings are loaded)
App.SetLightTheme();
}
@ -38,8 +38,12 @@ namespace DiscordChatExporter.Gui
{
base.OnUnhandledException(e);
MessageBox.Show(e.Exception.ToString(), "Error occured", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show(
e.Exception.ToString(),
"Error occured",
MessageBoxButton.OK,
MessageBoxImage.Error
);
}
#endif
}
}

@ -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);
}
}
Loading…
Cancel
Save