diff --git a/.gitignore b/.gitignore
index 64d0f58c7..734a256a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,9 +2,12 @@
## ArchiSteamFarm
#################
-# Ignore all config files
+# Ignore all files in config directory
ArchiSteamFarm/config
+# Except placeholder to include the folder
+!ArchiSteamFarm/config/.gitkeep
+
# Include default pre-defined config files
!ArchiSteamFarm/config/ASF.json
!ArchiSteamFarm/config/example.json
diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs
index 8f626649a..219be734f 100644
--- a/ArchiSteamFarm/ASF.cs
+++ b/ArchiSteamFarm/ASF.cs
@@ -253,8 +253,6 @@ namespace ArchiSteamFarm {
switch (botName) {
case SharedInfo.ASF:
- case "example":
- case "minimal":
return false;
default:
return true;
@@ -586,7 +584,7 @@ namespace ArchiSteamFarm {
Directory.CreateDirectory(directory);
}
- if (string.IsNullOrEmpty(zipFile.Name) || zipFile.Name.Equals(SharedInfo.GlobalConfigFileName)) {
+ if (string.IsNullOrEmpty(zipFile.Name)) {
continue;
}
diff --git a/ArchiSteamFarm/ArchiSteamFarm.csproj b/ArchiSteamFarm/ArchiSteamFarm.csproj
index a1bbd4cfd..77470f06a 100644
--- a/ArchiSteamFarm/ArchiSteamFarm.csproj
+++ b/ArchiSteamFarm/ArchiSteamFarm.csproj
@@ -107,13 +107,7 @@
PreserveNewest
-
- PreserveNewest
-
-
- PreserveNewest
-
-
+
PreserveNewest
diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs
index 3c5a986da..e1c1c34aa 100755
--- a/ArchiSteamFarm/Bot.cs
+++ b/ArchiSteamFarm/Bot.cs
@@ -861,7 +861,7 @@ namespace ArchiSteamFarm {
string databaseFilePath = botPath + SharedInfo.DatabaseExtension;
- BotDatabase botDatabase = await BotDatabase.Load(databaseFilePath).ConfigureAwait(false);
+ BotDatabase botDatabase = await BotDatabase.CreateOrLoad(databaseFilePath).ConfigureAwait(false);
if (botDatabase == null) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, databaseFilePath));
return;
diff --git a/ArchiSteamFarm/BotDatabase.cs b/ArchiSteamFarm/BotDatabase.cs
index 3b9ef3f47..0c796de44 100644
--- a/ArchiSteamFarm/BotDatabase.cs
+++ b/ArchiSteamFarm/BotDatabase.cs
@@ -144,6 +144,34 @@ namespace ArchiSteamFarm {
}
}
+ internal static async Task CreateOrLoad(string filePath) {
+ if (string.IsNullOrEmpty(filePath)) {
+ ASF.ArchiLogger.LogNullError(nameof(filePath));
+ return null;
+ }
+
+ if (!File.Exists(filePath)) {
+ return new BotDatabase(filePath);
+ }
+
+ BotDatabase botDatabase;
+
+ try {
+ botDatabase = JsonConvert.DeserializeObject(await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false));
+ } catch (Exception e) {
+ ASF.ArchiLogger.LogGenericException(e);
+ return null;
+ }
+
+ if (botDatabase == null) {
+ ASF.ArchiLogger.LogNullError(nameof(botDatabase));
+ return null;
+ }
+
+ botDatabase.FilePath = filePath;
+ return botDatabase;
+ }
+
internal IReadOnlyCollection GetBlacklistedFromTradesSteamIDs() => BlacklistedFromTradesSteamIDs;
internal (string Key, string Name) GetGameToRedeemInBackground() {
@@ -186,34 +214,6 @@ namespace ArchiSteamFarm {
return IdlingPriorityAppIDs.Contains(appID);
}
- internal static async Task Load(string filePath) {
- if (string.IsNullOrEmpty(filePath)) {
- ASF.ArchiLogger.LogNullError(nameof(filePath));
- return null;
- }
-
- if (!File.Exists(filePath)) {
- return new BotDatabase(filePath);
- }
-
- BotDatabase botDatabase;
-
- try {
- botDatabase = JsonConvert.DeserializeObject(await RuntimeCompatibility.File.ReadAllTextAsync(filePath).ConfigureAwait(false));
- } catch (Exception e) {
- ASF.ArchiLogger.LogGenericException(e);
- return null;
- }
-
- if (botDatabase == null) {
- ASF.ArchiLogger.LogNullError(nameof(botDatabase));
- return null;
- }
-
- botDatabase.FilePath = filePath;
- return botDatabase;
- }
-
internal async Task MakeReadOnly() {
if (ReadOnly) {
return;
diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs
index 3b1d257e5..2de013728 100644
--- a/ArchiSteamFarm/GlobalConfig.cs
+++ b/ArchiSteamFarm/GlobalConfig.cs
@@ -246,6 +246,12 @@ namespace ArchiSteamFarm {
return Enum.IsDefined(typeof(EUpdateChannel), UpdateChannel) ? (true, null) : (false, string.Format(Strings.ErrorConfigPropertyInvalid, nameof(UpdateChannel), UpdateChannel));
}
+ internal static GlobalConfig Create() =>
+ new GlobalConfig {
+ ShouldSerializeEverything = false,
+ ShouldSerializeSensitiveDetails = false
+ };
+
internal static async Task Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath));
diff --git a/ArchiSteamFarm/GlobalDatabase.cs b/ArchiSteamFarm/GlobalDatabase.cs
index 4b5f8c146..7e037ec3d 100644
--- a/ArchiSteamFarm/GlobalDatabase.cs
+++ b/ArchiSteamFarm/GlobalDatabase.cs
@@ -69,16 +69,7 @@ namespace ArchiSteamFarm {
PackagesRefreshSemaphore.Dispose();
}
- internal HashSet GetPackageIDs(uint appID) {
- if (appID == 0) {
- ASF.ArchiLogger.LogNullError(nameof(appID));
- return null;
- }
-
- return PackagesData.Where(package => package.Value.AppIDs?.Contains(appID) == true).Select(package => package.Key).ToHashSet();
- }
-
- internal static async Task Load(string filePath) {
+ internal static async Task CreateOrLoad(string filePath) {
if (string.IsNullOrEmpty(filePath)) {
ASF.ArchiLogger.LogNullError(nameof(filePath));
return null;
@@ -106,6 +97,15 @@ namespace ArchiSteamFarm {
return globalDatabase;
}
+ internal HashSet GetPackageIDs(uint appID) {
+ if (appID == 0) {
+ ASF.ArchiLogger.LogNullError(nameof(appID));
+ return null;
+ }
+
+ return PackagesData.Where(package => package.Value.AppIDs?.Contains(appID) == true).Select(package => package.Key).ToHashSet();
+ }
+
internal async Task RefreshPackages(Bot bot, IReadOnlyDictionary packages) {
if ((bot == null) || (packages == null) || (packages.Count == 0)) {
ASF.ArchiLogger.LogNullError(nameof(bot) + " || " + nameof(packages));
diff --git a/ArchiSteamFarm/IPC/ArchiKestrel.cs b/ArchiSteamFarm/IPC/ArchiKestrel.cs
index d91fd6b8b..d0e28efab 100644
--- a/ArchiSteamFarm/IPC/ArchiKestrel.cs
+++ b/ArchiSteamFarm/IPC/ArchiKestrel.cs
@@ -34,9 +34,8 @@ namespace ArchiSteamFarm.IPC {
internal static class ArchiKestrel {
private const string ConfigurationFile = nameof(IPC) + ".config";
- internal static string WebsiteDirectory { get; private set; } = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory);
-
internal static HistoryTarget HistoryTarget { get; private set; }
+ internal static string WebsiteDirectory { get; private set; } = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory);
private static IWebHost KestrelWebHost;
diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs
index 5b9e24e58..3abb57e88 100644
--- a/ArchiSteamFarm/Program.cs
+++ b/ArchiSteamFarm/Program.cs
@@ -239,12 +239,16 @@ namespace ArchiSteamFarm {
private static async Task InitGlobalConfigAndLanguage() {
string globalConfigFile = Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalConfigFileName);
- GlobalConfig = await GlobalConfig.Load(globalConfigFile).ConfigureAwait(false);
- if (GlobalConfig == null) {
- ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorGlobalConfigNotLoaded, globalConfigFile));
- await Task.Delay(5 * 1000).ConfigureAwait(false);
- await Exit(1).ConfigureAwait(false);
- return;
+ if (File.Exists(globalConfigFile)) {
+ GlobalConfig = await GlobalConfig.Load(globalConfigFile).ConfigureAwait(false);
+ if (GlobalConfig == null) {
+ ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorGlobalConfigNotLoaded, globalConfigFile));
+ await Task.Delay(5 * 1000).ConfigureAwait(false);
+ await Exit(1).ConfigureAwait(false);
+ return;
+ }
+ } else {
+ GlobalConfig = GlobalConfig.Create();
}
if (Debugging.IsUserDebugging) {
@@ -312,7 +316,7 @@ namespace ArchiSteamFarm {
await Task.Delay(5 * 1000).ConfigureAwait(false);
}
- GlobalDatabase = await GlobalDatabase.Load(globalDatabaseFile).ConfigureAwait(false);
+ GlobalDatabase = await GlobalDatabase.CreateOrLoad(globalDatabaseFile).ConfigureAwait(false);
if (GlobalDatabase == null) {
ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorDatabaseInvalid, globalDatabaseFile));
await Task.Delay(5 * 1000).ConfigureAwait(false);
diff --git a/ArchiSteamFarm/config/.gitkeep b/ArchiSteamFarm/config/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/ArchiSteamFarm/config/ASF.json b/ArchiSteamFarm/config/ASF.json
deleted file mode 100644
index 2ea16cb29..000000000
--- a/ArchiSteamFarm/config/ASF.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "AutoRestart": true,
- "Blacklist": [],
- "CommandPrefix": "!",
- "ConfirmationsLimiterDelay": 10,
- "ConnectionTimeout": 60,
- "CurrentCulture": null,
- "Debug": false,
- "FarmingDelay": 15,
- "GiftsLimiterDelay": 1,
- "Headless": false,
- "IdleFarmingPeriod": 8,
- "InventoryLimiterDelay": 3,
- "IPC": false,
- "IPCPassword": null,
- "LoginLimiterDelay": 10,
- "MaxFarmingTime": 10,
- "MaxTradeHoldDuration": 15,
- "OptimizationMode": 0,
- "Statistics": true,
- "SteamMessagePrefix": "/me ",
- "SteamOwnerID": 0,
- "SteamProtocols": 5,
- "UpdateChannel": 1,
- "UpdatePeriod": 24,
- "WebLimiterDelay": 200,
- "WebProxy": null,
- "WebProxyPassword": null,
- "WebProxyUsername": null
-}
diff --git a/ArchiSteamFarm/config/example.json b/ArchiSteamFarm/config/example.json
deleted file mode 100644
index 4a02fafed..000000000
--- a/ArchiSteamFarm/config/example.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "AcceptGifts": false,
- "AutoSteamSaleEvent": false,
- "BotBehaviour": 0,
- "CustomGamePlayedWhileFarming": null,
- "CustomGamePlayedWhileIdle": null,
- "Enabled": false,
- "FarmingOrders": [],
- "GamesPlayedWhileIdle": [],
- "HoursUntilCardDrops": 3,
- "IdlePriorityQueueOnly": false,
- "IdleRefundableGames": true,
- "LootableTypes": [
- 1,
- 3,
- 5
- ],
- "MatchableTypes": [
- 5
- ],
- "OnlineStatus": 1,
- "PasswordFormat": 0,
- "Paused": false,
- "RedeemingPreferences": 0,
- "SendOnFarmingFinished": false,
- "SendTradePeriod": 0,
- "ShutdownOnFarmingFinished": false,
- "SteamLogin": null,
- "SteamMasterClanID": 0,
- "SteamParentalCode": null,
- "SteamPassword": null,
- "SteamTradeToken": null,
- "SteamUserPermissions": {},
- "TradingPreferences": 0,
- "TransferableTypes": [
- 1,
- 3,
- 5
- ],
- "UseLoginKeys": true
-}
diff --git a/ArchiSteamFarm/config/minimal.json b/ArchiSteamFarm/config/minimal.json
deleted file mode 100644
index 9699bdba5..000000000
--- a/ArchiSteamFarm/config/minimal.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "Enabled": false,
- "SteamLogin": null,
- "SteamPassword": null
-}