Compare commits

..

4 Commits

Author SHA1 Message Date
JustArchi
b9064bbfda Fix awaiting null tasks, closes #128 2016-03-06 21:49:34 +01:00
Łukasz Domeradzki
eddcc2816a Update README.md 2016-03-06 21:17:21 +01:00
JustArchi
52360a682a Add DismissInventoryNotifications, closes #132 2016-03-06 14:15:59 +01:00
JustArchi
709ce6489b Add only enabled bots to collection, closes #139 2016-03-06 14:09:08 +01:00
5 changed files with 30 additions and 20 deletions

View File

@@ -24,9 +24,11 @@
using SteamKit2;
using SteamKit2.Internal;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace ArchiSteamFarm {
internal sealed class ArchiHandler : ClientMsgHandler {
@@ -216,7 +218,7 @@ namespace ArchiSteamFarm {
Client.Send(request);
}
internal AsyncJob<PurchaseResponseCallback> RedeemKey(string key) {
internal async Task<PurchaseResponseCallback> RedeemKey(string key) {
if (string.IsNullOrEmpty(key) || !Client.IsConnected) {
return null;
}
@@ -228,7 +230,12 @@ namespace ArchiSteamFarm {
request.Body.key = key;
Client.Send(request);
return new AsyncJob<PurchaseResponseCallback>(Client, request.SourceJobID);
try {
return await new AsyncJob<PurchaseResponseCallback>(Client, request.SourceJobID);
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
}
/*

View File

@@ -27,7 +27,6 @@ using SteamAuth;
using SteamKit2;
using SteamKit2.Internal;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
@@ -40,7 +39,7 @@ namespace ArchiSteamFarm {
private const ulong ArchiSCFarmGroup = 103582791440160998;
private const ushort CallbackSleep = 500; // In miliseconds
internal static readonly ConcurrentDictionary<string, Bot> Bots = new ConcurrentDictionary<string, Bot>();
internal static readonly Dictionary<string, Bot> Bots = new Dictionary<string, Bot>();
private static readonly uint LoginID = MsgClientLogon.ObfuscationMask; // This must be the same for all ASF bots and all ASF processes
@@ -111,18 +110,6 @@ namespace ArchiSteamFarm {
return;
}
bool alreadyExists;
lock (Bots) {
alreadyExists = Bots.ContainsKey(botName);
if (!alreadyExists) {
Bots[botName] = this;
}
}
if (alreadyExists) {
return;
}
BotName = botName;
string botPath = Path.Combine(Program.ConfigDirectory, botName);
@@ -176,6 +163,18 @@ namespace ArchiSteamFarm {
return;
}
bool alreadyExists;
lock (Bots) {
alreadyExists = Bots.ContainsKey(botName);
if (!alreadyExists) {
Bots[botName] = this;
}
}
if (alreadyExists) {
return;
}
BotDatabase = BotDatabase.Load(botPath + ".db");
SentryFile = botPath + ".bin";
@@ -525,7 +524,7 @@ namespace ArchiSteamFarm {
ArchiHandler.PurchaseResponseCallback result;
try {
result = await currentBot.ArchiHandler.RedeemKey(key);
result = await currentBot.ArchiHandler.RedeemKey(key).ConfigureAwait(false);
} catch (Exception e) {
Logging.LogGenericException(e, currentBot.BotName);
break;
@@ -576,7 +575,7 @@ namespace ArchiSteamFarm {
ArchiHandler.PurchaseResponseCallback otherResult;
try {
otherResult = await bot.ArchiHandler.RedeemKey(key);
otherResult = await bot.ArchiHandler.RedeemKey(key).ConfigureAwait(false);
} catch (Exception e) {
Logging.LogGenericException(e, bot.BotName);
break; // We're done with this key
@@ -1267,7 +1266,7 @@ namespace ArchiSteamFarm {
Trading.CheckTrades();
}
if (markInventory) {
if (markInventory && BotConfig.DismissInventoryNotifications) {
await ArchiWebHandler.MarkInventory().ConfigureAwait(false);
}
}

View File

@@ -59,6 +59,9 @@ namespace ArchiSteamFarm {
[JsonProperty(Required = Required.DisallowNull)]
internal bool CardDropsRestricted { get; private set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
internal bool DismissInventoryNotifications { get; private set; } = true;
[JsonProperty(Required = Required.DisallowNull)]
internal bool FarmOffline { get; private set; } = false;

View File

@@ -8,6 +8,7 @@
"SteamMasterID": 0,
"SteamMasterClanID": 0,
"CardDropsRestricted": false,
"DismissInventoryNotifications": true,
"FarmOffline": false,
"HandleOfflineMessages": false,
"ForwardKeysToOtherBots": false,

View File

@@ -1,7 +1,7 @@
ArchiSteamFarm
===================
[![Build status](https://ci.appveyor.com/api/projects/status/yi0y25nipcb1j1yj?svg=true)](https://ci.appveyor.com/project/JustArchi/archisteamfarm) [![GitHub release](https://img.shields.io/github/release/JustArchi/ArchiSteamFarm.svg)](https://github.com/JustArchi/ArchiSteamFarm/releases/latest) [![Github All Releases](https://img.shields.io/github/downloads/JustArchi/ArchiSteamFarm/total.svg)](https://github.com/JustArchi/ArchiSteamFarm/releases) [![Paypal donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HD2P2P3WGS5Y4)
[![Build status](https://ci.appveyor.com/api/projects/status/yi0y25nipcb1j1yj?svg=true)](https://ci.appveyor.com/project/JustArchi/archisteamfarm) [![GitHub release](https://img.shields.io/github/release/JustArchi/ArchiSteamFarm.svg)](https://github.com/JustArchi/ArchiSteamFarm/releases/latest) [![Github All Releases](https://img.shields.io/github/downloads/JustArchi/ArchiSteamFarm/total.svg)](https://github.com/JustArchi/ArchiSteamFarm/releases) [![Paypal donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HD2P2P3WGS5Y4) [![Steam donate](https://img.shields.io/badge/steam-donate-yellow.svg)](https://steamcommunity.com/tradeoffer/new/?partner=46697991&token=0ix2Ruv_)
---