mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Closes #383
This commit is contained in:
@@ -40,10 +40,10 @@ using Formatting = Newtonsoft.Json.Formatting;
|
||||
namespace ArchiSteamFarm {
|
||||
internal sealed class ArchiWebHandler : IDisposable {
|
||||
private const byte MinSessionTTL = GlobalConfig.DefaultHttpTimeout / 4; // Assume session is valid for at least that amount of seconds
|
||||
private const string SteamCommunityHost = "steamcommunity.com";
|
||||
|
||||
// We must use HTTPS for SteamCommunity, as http would make certain POST requests failing (trades)
|
||||
private const string SteamCommunityURL = "https://" + SteamCommunityHost;
|
||||
private const string SteamCommunityHost = "steamcommunity.com";
|
||||
|
||||
// We could (and should) use HTTPS for SteamStore, but that would make certain POST requests failing
|
||||
private const string SteamStoreHost = "store.steampowered.com";
|
||||
@@ -417,7 +417,12 @@ namespace ArchiSteamFarm {
|
||||
return await WebBrowser.UrlGetToHtmlDocumentRetry(request).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal async Task<HashSet<Steam.Item>> GetMySteamInventory(bool tradable) {
|
||||
internal async Task<HashSet<Steam.Item>> GetMySteamInventory(bool tradable, HashSet<Steam.Item.EType> wantedTypes) {
|
||||
if ((wantedTypes == null) || (wantedTypes.Count == 0)) {
|
||||
Bot.ArchiLogger.LogNullError(nameof(wantedTypes));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!await RefreshSessionIfNeeded().ConfigureAwait(false)) {
|
||||
return null;
|
||||
}
|
||||
@@ -513,6 +518,10 @@ namespace ArchiSteamFarm {
|
||||
steamItem.Type = description.Item2;
|
||||
}
|
||||
|
||||
if (!wantedTypes.Contains(steamItem.Type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.Add(steamItem);
|
||||
}
|
||||
|
||||
|
||||
@@ -1739,18 +1739,11 @@ namespace ArchiSteamFarm {
|
||||
|
||||
await Trading.LimitInventoryRequestsAsync().ConfigureAwait(false);
|
||||
|
||||
HashSet<Steam.Item> inventory = await ArchiWebHandler.GetMySteamInventory(true).ConfigureAwait(false);
|
||||
HashSet<Steam.Item> inventory = await ArchiWebHandler.GetMySteamInventory(true, BotConfig.LootableTypes).ConfigureAwait(false);
|
||||
if ((inventory == null) || (inventory.Count == 0)) {
|
||||
return "Nothing to send, inventory seems empty!";
|
||||
}
|
||||
|
||||
// Remove from our pending inventory all items that are not steam cards and boosters
|
||||
if (inventory.RemoveWhere(item => (item.Type != Steam.Item.EType.TradingCard) && ((item.Type != Steam.Item.EType.FoilTradingCard) || !BotConfig.IsBotAccount) && (item.Type != Steam.Item.EType.BoosterPack)) > 0) {
|
||||
if (inventory.Count == 0) {
|
||||
return "Nothing to send, inventory seems empty!";
|
||||
}
|
||||
}
|
||||
|
||||
if (!await ArchiWebHandler.SendTradeOffer(inventory, BotConfig.SteamMasterID, BotConfig.SteamTradeToken).ConfigureAwait(false)) {
|
||||
return "Trade offer failed due to error!";
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ArchiSteamFarm.JSON;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
@@ -77,6 +78,9 @@ namespace ArchiSteamFarm {
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal readonly bool IsBotAccount = false;
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal readonly HashSet<Steam.Item.EType> LootableTypes = new HashSet<Steam.Item.EType> { Steam.Item.EType.BoosterPack, Steam.Item.EType.FoilTradingCard, Steam.Item.EType.TradingCard };
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
internal readonly CryptoHelper.ECryptoMethod PasswordFormat = CryptoHelper.ECryptoMethod.PlainText;
|
||||
|
||||
|
||||
@@ -359,16 +359,14 @@ namespace ArchiSteamFarm.JSON {
|
||||
|
||||
internal enum EType : byte {
|
||||
Unknown,
|
||||
|
||||
BoosterPack,
|
||||
Coupon,
|
||||
Gift,
|
||||
SteamGems,
|
||||
|
||||
Emoticon,
|
||||
Gift,
|
||||
FoilTradingCard,
|
||||
ProfileBackground,
|
||||
TradingCard
|
||||
TradingCard,
|
||||
SteamGems
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace ArchiSteamFarm {
|
||||
// Now check if it's worth for us to do the trade
|
||||
await LimitInventoryRequestsAsync().ConfigureAwait(false);
|
||||
|
||||
HashSet<Steam.Item> inventory = await Bot.ArchiWebHandler.GetMySteamInventory(false).ConfigureAwait(false);
|
||||
HashSet<Steam.Item> inventory = await Bot.ArchiWebHandler.GetMySteamInventory(false, new HashSet<Steam.Item.EType> { Steam.Item.EType.TradingCard }).ConfigureAwait(false);
|
||||
if ((inventory == null) || (inventory.Count == 0)) {
|
||||
return new ParseTradeResult(tradeOffer.TradeOfferID, ParseTradeResult.EResult.AcceptedWithItemLose); // OK, assume that this trade is valid, we can't check our EQ
|
||||
}
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
{
|
||||
"Enabled": false,
|
||||
"Paused": false,
|
||||
"SteamLogin": null,
|
||||
"SteamPassword": null,
|
||||
"PasswordFormat": 0,
|
||||
"SteamParentalPIN": "0",
|
||||
"SteamApiKey": null,
|
||||
"SteamMasterID": 0,
|
||||
"SteamMasterClanID": 0,
|
||||
"CardDropsRestricted": true,
|
||||
"DismissInventoryNotifications": true,
|
||||
"FarmingOrder": 0,
|
||||
"FarmOffline": false,
|
||||
"HandleOfflineMessages": false,
|
||||
"AcceptGifts": false,
|
||||
"IsBotAccount": false,
|
||||
"ForwardKeysToOtherBots": false,
|
||||
"DistributeKeys": false,
|
||||
"ShutdownOnFarmingFinished": false,
|
||||
"SendOnFarmingFinished": false,
|
||||
"SteamTradeToken": null,
|
||||
"SendTradePeriod": 0,
|
||||
"TradingPreferences": 1,
|
||||
"AcceptConfirmationsPeriod": 0,
|
||||
"CustomGamePlayedWhileFarming": null,
|
||||
"CustomGamePlayedWhileIdle": null,
|
||||
"GamesPlayedWhileIdle": []
|
||||
}
|
||||
"AcceptConfirmationsPeriod" : 0,
|
||||
"AcceptGifts" : false,
|
||||
"CardDropsRestricted" : true,
|
||||
"CustomGamePlayedWhileFarming" : null,
|
||||
"CustomGamePlayedWhileIdle" : null,
|
||||
"DismissInventoryNotifications" : true,
|
||||
"DistributeKeys" : false,
|
||||
"Enabled" : false,
|
||||
"FarmOffline" : false,
|
||||
"FarmingOrder" : 0,
|
||||
"ForwardKeysToOtherBots" : false,
|
||||
"GamesPlayedWhileIdle" : [],
|
||||
"HandleOfflineMessages" : false,
|
||||
"IsBotAccount" : false,
|
||||
"LootableTypes" : [ 1, 5, 7 ],
|
||||
"PasswordFormat" : 0,
|
||||
"Paused" : false,
|
||||
"SendOnFarmingFinished" : false,
|
||||
"SendTradePeriod" : 0,
|
||||
"ShutdownOnFarmingFinished" : false,
|
||||
"SteamApiKey" : null,
|
||||
"SteamLogin" : null,
|
||||
"SteamMasterClanID" : 0,
|
||||
"SteamMasterID" : 0,
|
||||
"SteamParentalPIN" : "0",
|
||||
"SteamPassword" : null,
|
||||
"SteamTradeToken" : null,
|
||||
"TradingPreferences" : 1
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing.Design;
|
||||
using System.IO;
|
||||
using ConfigGenerator.JSON;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ConfigGenerator {
|
||||
@@ -83,6 +84,9 @@ namespace ConfigGenerator {
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
public bool IsBotAccount { get; set; } = false;
|
||||
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
public List<Steam.Item.EType> LootableTypes = new List<Steam.Item.EType> { Steam.Item.EType.BoosterPack, Steam.Item.EType.FoilTradingCard, Steam.Item.EType.TradingCard };
|
||||
|
||||
[Category("\tAccess")]
|
||||
[JsonProperty(Required = Required.DisallowNull)]
|
||||
public ECryptoMethod PasswordFormat { get; set; } = ECryptoMethod.PlainText;
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
<Compile Include="ConfigPage.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="JSON\Steam.cs" />
|
||||
<Compile Include="Logging.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
||||
20
ConfigGenerator/JSON/Steam.cs
Normal file
20
ConfigGenerator/JSON/Steam.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace ConfigGenerator.JSON {
|
||||
internal static class Steam {
|
||||
internal static class Item {
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
internal enum EType : byte {
|
||||
Unknown,
|
||||
BoosterPack,
|
||||
Coupon,
|
||||
Emoticon,
|
||||
Gift,
|
||||
FoilTradingCard,
|
||||
ProfileBackground,
|
||||
TradingCard,
|
||||
SteamGems
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user