Skip to content

Commit

Permalink
Improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Mar 14, 2016
1 parent de4fbf8 commit c189b39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions ArchiSteamFarm/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ internal Bot(string botName) {

if (BotConfig.AcceptConfirmationsPeriod > 0 && AcceptConfirmationsTimer == null) {
AcceptConfirmationsTimer = new Timer(
async e => await AcceptConfirmations(true).ConfigureAwait(false),
async e => await AcceptConfirmations().ConfigureAwait(false),
null,
TimeSpan.FromMinutes(BotConfig.AcceptConfirmationsPeriod), // Delay
TimeSpan.FromMinutes(BotConfig.AcceptConfirmationsPeriod) // Period
Expand All @@ -247,7 +247,7 @@ internal Bot(string botName) {
Start().Wait();
}

internal async Task AcceptConfirmations(bool all) {
internal async Task AcceptConfirmations(Confirmation.ConfirmationType allowedConfirmationType = Confirmation.ConfirmationType.Unknown) {
if (BotDatabase.SteamGuardAccount == null) {
return;
}
Expand All @@ -263,7 +263,7 @@ internal async Task AcceptConfirmations(bool all) {
}

foreach (Confirmation confirmation in confirmations) {
if (confirmation.ConfType != Confirmation.ConfirmationType.Trade && !all) {
if (allowedConfirmationType != Confirmation.ConfirmationType.Unknown && confirmation.ConfType != allowedConfirmationType) {
continue;
}

Expand Down Expand Up @@ -537,7 +537,7 @@ private async Task<string> ResponseSendTrade() {
}

if (await ArchiWebHandler.SendTradeOffer(inventory, BotConfig.SteamMasterID, BotConfig.SteamTradeToken).ConfigureAwait(false)) {
await AcceptConfirmations(false).ConfigureAwait(false);
await AcceptConfirmations(Confirmation.ConfirmationType.Trade).ConfigureAwait(false);
return "Trade offer sent successfully!";
} else {
return "Trade offer failed due to error!";
Expand Down Expand Up @@ -609,7 +609,7 @@ private async Task<string> Response2FAOK() {
return "That bot doesn't have ASF 2FA enabled!";
}

await AcceptConfirmations(true).ConfigureAwait(false);
await AcceptConfirmations().ConfigureAwait(false);
return "Done!";
}

Expand Down
3 changes: 2 additions & 1 deletion ArchiSteamFarm/Trading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
*/

using SteamAuth;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -81,7 +82,7 @@ private async Task ParseActiveTrades() {
}

await Task.WhenAll(tasks).ConfigureAwait(false);
await Bot.AcceptConfirmations(false).ConfigureAwait(false);
await Bot.AcceptConfirmations(Confirmation.ConfirmationType.Trade).ConfigureAwait(false);
}

private async Task ParseTrade(Steam.TradeOffer tradeOffer) {
Expand Down

0 comments on commit c189b39

Please sign in to comment.