mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
CMs refresh has to be done only once
This commit is contained in:
@@ -120,6 +120,20 @@ namespace ArchiSteamFarm {
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal static void RefreshCMs() {
|
||||
bool initialized = false;
|
||||
while (!initialized) {
|
||||
try {
|
||||
Logging.LogGenericInfo("Main", "Refreshing list of CMs...");
|
||||
SteamDirectory.Initialize().Wait();
|
||||
initialized = true;
|
||||
Logging.LogGenericInfo("Main", "Success!");
|
||||
} catch (TaskCanceledException) {
|
||||
Logging.LogGenericWarning("Main", "Failed! Retrying...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal Bot(string botName) {
|
||||
if (Bots.ContainsKey(botName)) {
|
||||
return;
|
||||
@@ -190,19 +204,6 @@ namespace ArchiSteamFarm {
|
||||
);
|
||||
}
|
||||
|
||||
// Before attempting to connect, initialize our list of CMs
|
||||
bool initialized = false;
|
||||
while (!initialized) {
|
||||
try {
|
||||
Logging.LogGenericInfo(BotName, "Getting list of CMs...");
|
||||
SteamDirectory.Initialize().Wait();
|
||||
initialized = true;
|
||||
Logging.LogGenericInfo(BotName, "Success!");
|
||||
} catch (TaskCanceledException) {
|
||||
Logging.LogGenericWarning(BotName, "Failed! Retrying...");
|
||||
}
|
||||
}
|
||||
|
||||
// Start
|
||||
var handleCallbacks = Task.Run(() => HandleCallbacks());
|
||||
var start = Task.Run(async () => await Start().ConfigureAwait(false));
|
||||
|
||||
@@ -256,6 +256,9 @@ namespace ArchiSteamFarm {
|
||||
Task.Run(async () => await Exit(1).ConfigureAwait(false)).Wait();
|
||||
}
|
||||
|
||||
// Before attempting to connect, initialize our list of CMs
|
||||
Bot.RefreshCMs();
|
||||
|
||||
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.xml")) {
|
||||
string botName = Path.GetFileNameWithoutExtension(configFile);
|
||||
Bot bot = new Bot(botName);
|
||||
|
||||
Reference in New Issue
Block a user