From abadf3dccce785c1cbf1b87f75f53c5a193eff42 Mon Sep 17 00:00:00 2001 From: Delta Date: Sun, 23 Apr 2023 06:45:00 -0700 Subject: [PATCH] Add optional Github token setting to raise github rate limit --- Internals/Config.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Internals/Config.cs b/Internals/Config.cs index 8000e03..c8d9d8d 100644 --- a/Internals/Config.cs +++ b/Internals/Config.cs @@ -6,6 +6,7 @@ class ConfigData { public string NeosCacheDirectory { get; set; } public string LaunchArguments { get; set; } public bool IgnoreNeosInstallMissing { get; set; } + public string GithubToken { get; set; } } public class Config { //Config file @@ -23,6 +24,8 @@ public class Config { public static string LaunchArguments { get; set; } = @""; /**Ignore message prompting to set Neos Install Path*/ public static bool IgnoreNeosInstallMissing { get; set; } = false; + /**Optional Github token, Increases rate limit from 60 to 5000 per hour*/ + public static string GithubToken { get; set; } = ""; //Derived directories @@ -66,8 +69,9 @@ static void WriteNewConfig() { LaunchArguments = "", NeosDataDirectory = "", NeosCacheDirectory = "", - IgnoreNeosInstallMissing = false - }; + IgnoreNeosInstallMissing = false, + GithubToken = "" + }; string json = JsonSerializer.Serialize(_data, JsonSerializerOptions); File.WriteAllText(ConfigFile, json); } catch (Exception ex) { @@ -84,8 +88,9 @@ public static void SaveConfig() { UseNeosLauncher = UseNeosLauncher, NeosDataDirectory = NeosDataDirectory, NeosCacheDirectory = NeosCacheDirectory, - IgnoreNeosInstallMissing = IgnoreNeosInstallMissing - }; + IgnoreNeosInstallMissing = IgnoreNeosInstallMissing, + GithubToken = GithubToken + }; string json = JsonSerializer.Serialize(_data, JsonSerializerOptions); File.WriteAllText(ConfigFile, json); ReadConfig(); //ensures derived values are updated @@ -123,6 +128,8 @@ public static void ReadConfig() { //TODO check what happens for missing or invalid keys IgnoreNeosInstallMissing = openedConfig.IgnoreNeosInstallMissing; + GithubToken = openedConfig.GithubToken; + //Creates nml_mods and nml_libs if they don't exist if (!Directory.Exists(NeosInstallDirectory)) { Log("Neos install directory does not exist", Level.ERROR);