mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-25 04:04:22 -04:00
Add region-based sanctions
This commit is contained in:
parent
9639b6c550
commit
001ea7e495
3 changed files with 126 additions and 23 deletions
49
DiscordChatExporter.Cli/Sanctions.cs
Normal file
49
DiscordChatExporter.Cli/Sanctions.cs
Normal file
|
@ -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,8 +9,8 @@ using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace DiscordChatExporter.Gui
|
namespace DiscordChatExporter.Gui;
|
||||||
{
|
|
||||||
public class Bootstrapper : Bootstrapper<RootViewModel>
|
public class Bootstrapper : Bootstrapper<RootViewModel>
|
||||||
{
|
{
|
||||||
protected override void OnStart()
|
protected override void OnStart()
|
||||||
|
@ -18,7 +18,7 @@ namespace DiscordChatExporter.Gui
|
||||||
base.OnStart();
|
base.OnStart();
|
||||||
|
|
||||||
// Set default theme
|
// 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();
|
App.SetLightTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,12 @@ namespace DiscordChatExporter.Gui
|
||||||
{
|
{
|
||||||
base.OnUnhandledException(e);
|
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue