Skip to content

Commit

Permalink
Add optional Github token setting to raise github rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
XDelta committed Apr 23, 2023
1 parent 9fa1fe7 commit abadf3d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Internals/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +24,8 @@ public class Config {
public static string LaunchArguments { get; set; } = @"";
/**<summary>Ignore message prompting to set Neos Install Path</summary>*/
public static bool IgnoreNeosInstallMissing { get; set; } = false;
/**<summary>Optional Github token, Increases rate limit from 60 to 5000 per hour</summary>*/
public static string GithubToken { get; set; } = "";


//Derived directories
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit abadf3d

Please sign in to comment.