mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Add new Bot actions + a lot of performance improvements
This commit is contained in:
@@ -38,6 +38,8 @@ namespace ArchiSteamFarm {
|
||||
private readonly ConcurrentHashSet<ulong> HandledGifts = new ConcurrentHashSet<ulong>();
|
||||
private readonly SemaphoreSlim LootingSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
internal bool SkipFirstShutdown { get; set; }
|
||||
|
||||
private bool LootingAllowed = true;
|
||||
private bool LootingScheduled;
|
||||
private bool ProcessingGiftsScheduled;
|
||||
@@ -60,21 +62,7 @@ namespace ArchiSteamFarm {
|
||||
return await Bot.BotDatabase.MobileAuthenticator.HandleConfirmations(confirmations, accept).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
IEnumerable<Task<Steam.ConfirmationDetails>> tasks = confirmations.Select(Bot.BotDatabase.MobileAuthenticator.GetConfirmationDetails);
|
||||
ICollection<Steam.ConfirmationDetails> results;
|
||||
|
||||
switch (Program.GlobalConfig.OptimizationMode) {
|
||||
case GlobalConfig.EOptimizationMode.MinMemoryUsage:
|
||||
results = new List<Steam.ConfirmationDetails>(confirmations.Count);
|
||||
foreach (Task<Steam.ConfirmationDetails> task in tasks) {
|
||||
results.Add(await task.ConfigureAwait(false));
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
IList<Steam.ConfirmationDetails> results = await Utilities.InParallel(confirmations.Select(Bot.BotDatabase.MobileAuthenticator.GetConfirmationDetails)).ConfigureAwait(false);
|
||||
|
||||
foreach (MobileAuthenticator.Confirmation confirmation in results.Where(details => (details != null) && ((acceptedType != details.Type) || ((acceptedSteamID != 0) && (details.OtherSteamID64 != 0) && (acceptedSteamID != details.OtherSteamID64)) || ((acceptedTradeIDs != null) && (details.TradeOfferID != 0) && !acceptedTradeIDs.Contains(details.TradeOfferID)))).Select(details => details.Confirmation)) {
|
||||
confirmations.Remove(confirmation);
|
||||
@@ -250,6 +238,25 @@ namespace ArchiSteamFarm {
|
||||
return (true, Strings.Done);
|
||||
}
|
||||
|
||||
internal (bool Success, string Output) Start() {
|
||||
if (Bot.KeepRunning) {
|
||||
return (false, Strings.BotAlreadyRunning);
|
||||
}
|
||||
|
||||
SkipFirstShutdown = true;
|
||||
Utilities.InBackground(Bot.Start);
|
||||
return (true, Strings.Done);
|
||||
}
|
||||
|
||||
internal (bool Success, string Output) Stop() {
|
||||
if (!Bot.KeepRunning) {
|
||||
return (false, Strings.BotAlreadyStopped);
|
||||
}
|
||||
|
||||
Bot.Stop();
|
||||
return (true, Strings.Done);
|
||||
}
|
||||
|
||||
internal bool SwitchLootingAllowed() => LootingAllowed = !LootingAllowed;
|
||||
|
||||
internal static async Task<(bool Success, Version Version)> Update() {
|
||||
|
||||
Reference in New Issue
Block a user