Implement TradingPreferences, closes #351

It also kills deprecated now SteamTradeMatcher bool property
This commit is contained in:
JustArchi
2016-10-21 20:32:22 +02:00
parent e6cc3e060c
commit af45ac1e2d
6 changed files with 222 additions and 11 deletions

View File

@@ -47,6 +47,14 @@ namespace ArchiSteamFarm {
NamesDescending
}
[Flags]
internal enum ETradingPreferences : byte {
[SuppressMessage("ReSharper", "UnusedMember.Global")]
None = 0,
AcceptDonations = 1,
SteamTradeMatcher = 2
}
[JsonProperty(Required = Required.DisallowNull)]
internal readonly bool Enabled = false;
@@ -95,9 +103,6 @@ namespace ArchiSteamFarm {
[JsonProperty(Required = Required.DisallowNull)]
internal readonly bool IsBotAccount = false;
[JsonProperty(Required = Required.DisallowNull)]
internal readonly bool SteamTradeMatcher = false;
[JsonProperty(Required = Required.DisallowNull)]
internal readonly bool ForwardKeysToOtherBots = false;
@@ -116,6 +121,9 @@ namespace ArchiSteamFarm {
[JsonProperty(Required = Required.DisallowNull)]
internal readonly byte SendTradePeriod = 0;
[JsonProperty(Required = Required.DisallowNull)]
internal readonly ETradingPreferences TradingPreferences = ETradingPreferences.AcceptDonations;
[JsonProperty(Required = Required.DisallowNull)]
internal readonly byte AcceptConfirmationsPeriod = 0;

View File

@@ -186,8 +186,8 @@ namespace ArchiSteamFarm {
return null;
}
// Always accept trades when we're not losing anything
if (tradeOffer.ItemsToGive.Count == 0) {
// Accept trades when we're not losing anything
if ((tradeOffer.ItemsToGive.Count == 0) && Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.AcceptDonations)) {
// Unless it's steam fuckup and we're dealing with broken trade
return tradeOffer.ItemsToReceive.Count > 0 ? new ParseTradeResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.AcceptedWithoutItemLose) : new ParseTradeResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.RejectedTemporarily);
}
@@ -198,7 +198,7 @@ namespace ArchiSteamFarm {
}
// If we don't have SteamTradeMatcher enabled, this is the end for us
if (!Bot.BotConfig.SteamTradeMatcher) {
if (!Bot.BotConfig.TradingPreferences.HasFlag(BotConfig.ETradingPreferences.SteamTradeMatcher)) {
return new ParseTradeResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.RejectedPermanently);
}

View File

@@ -16,13 +16,13 @@
"HandleOfflineMessages": false,
"AcceptGifts": false,
"IsBotAccount": false,
"SteamTradeMatcher": false,
"ForwardKeysToOtherBots": false,
"DistributeKeys": false,
"ShutdownOnFarmingFinished": false,
"SendOnFarmingFinished": false,
"SteamTradeToken": null,
"SendTradePeriod": 0,
"TradingPreferences": 1,
"AcceptConfirmationsPeriod": 0,
"CustomGamePlayedWhileFarming": null,
"CustomGamePlayedWhileIdle": null,