Skip to content

Commit

Permalink
update for asf 5.1.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudokhvist committed May 28, 2021
1 parent 4e38762 commit 8879335
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ArchiSteamFarm
Submodule ArchiSteamFarm updated 278 files
6 changes: 3 additions & 3 deletions ItemDispenser/DispenseItems.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System.Collections.Immutable;
using ArchiSteamFarm.Json;
using ArchiSteamFarm.Steam.Data;
using Newtonsoft.Json;

namespace ItemDispenser {

public sealed class DispenseItem {
public static readonly ImmutableHashSet<Steam.Asset.EType> EmptyTypes = ImmutableHashSet<Steam.Asset.EType>.Empty;
public static readonly ImmutableHashSet<Asset.EType> EmptyTypes = ImmutableHashSet<Asset.EType>.Empty;

[JsonProperty(Required = Required.Always)]
public readonly uint AppID;
[JsonProperty(Required = Required.Always)]
public readonly ulong ContextID;
[JsonProperty]
public readonly ImmutableHashSet<Steam.Asset.EType> Types = EmptyTypes;
public readonly ImmutableHashSet<Asset.EType> Types = EmptyTypes;
}
}
17 changes: 10 additions & 7 deletions ItemDispenser/ItemDispenser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
using System.Composition;
using System.Linq;
using System.Threading.Tasks;
using ArchiSteamFarm;
using ArchiSteamFarm.Steam;
using ArchiSteamFarm.Steam.Cards;
using ArchiSteamFarm.Steam.Data;
using ArchiSteamFarm.Steam.Storage;
using ArchiSteamFarm.Collections;
using ArchiSteamFarm.Json;
using ArchiSteamFarm.Plugins;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Plugins.Interfaces;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand All @@ -23,7 +26,7 @@ public class ItemDispenser : IBotTradeOffer, IBotModules {

public Version Version => typeof(ItemDispenser).Assembly.GetName().Version ?? new Version("0");

public async Task<bool> OnBotTradeOffer([NotNull] Bot bot, [NotNull] Steam.TradeOffer tradeOffer) {
public async Task<bool> OnBotTradeOffer([NotNull] Bot bot, [NotNull] TradeOffer tradeOffer) {
if (tradeOffer == null) {
ASF.ArchiLogger.LogNullError(nameof(tradeOffer));
return false;
Expand All @@ -43,7 +46,7 @@ public async Task<bool> OnBotTradeOffer([NotNull] Bot bot, [NotNull] Steam.Trade
// If user has a trade hold, we add extra logic
if (holdDuration.Value > 0) {
// If trade hold duration exceeds our max, or user asks for cards with short lifespan, reject the trade
if ((holdDuration.Value > (ASF.GlobalConfig?.MaxTradeHoldDuration ?? 0)) || tradeOffer.ItemsToGiveReadOnly.Any(item => ((item.Type == Steam.Asset.EType.FoilTradingCard) || (item.Type == Steam.Asset.EType.TradingCard)) && CardsFarmer.SalesBlacklist.Contains(item.RealAppID))) {
if ((holdDuration.Value > (ASF.GlobalConfig?.MaxTradeHoldDuration ?? 0)) || tradeOffer.ItemsToGiveReadOnly.Any(item => ((item.Type == Asset.EType.FoilTradingCard) || (item.Type == Asset.EType.TradingCard)) && CardsFarmer.SalesBlacklist.Contains(item.RealAppID))) {
return false;
}
}
Expand All @@ -53,7 +56,7 @@ public async Task<bool> OnBotTradeOffer([NotNull] Bot bot, [NotNull] Steam.Trade
return false;
}

foreach (Steam.Asset item in tradeOffer.ItemsToGiveReadOnly) {
foreach (Asset item in tradeOffer.ItemsToGiveReadOnly) {
if (!ItemsToDispense.Any( sample =>
(sample.AppID == item.AppID) &&
(sample.ContextID == item.ContextID) &&
Expand Down Expand Up @@ -83,7 +86,7 @@ public void OnBotInitModules([NotNull] Bot bot, [CanBeNull] IReadOnlyDictionary<

ConcurrentHashSet <DispenseItem>? dispenseItems;
try {
dispenseItems = jToken.Value<JArray>().ToObject<ConcurrentHashSet<DispenseItem>>();
dispenseItems = jToken.Value<JArray>()?.ToObject<ConcurrentHashSet<DispenseItem>>();
if (dispenseItems == null){
bot.ArchiLogger.LogNullError(nameof(dispenseItems));
return;
Expand Down
6 changes: 1 addition & 5 deletions ItemDispenser/ItemDispenser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Authors>Ryzhehvost</Authors>
<AssemblyVersion>0.2.0.0</AssemblyVersion>
<AssemblyVersion>0.3.0.0</AssemblyVersion>
<TargetFrameworks>net5.0;net48</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand All @@ -16,8 +16,4 @@
<ProjectReference Include="..\ArchiSteamFarm\ArchiSteamFarm\ArchiSteamFarm.csproj" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="mkdir $(TargetDir)ItemDispenser&#xD;&#xA;copy $(TargetPath) $(TargetDir)ItemDispenser\&#xD;&#xA;7z a -tzip -mx7 ItemDispenser.zip $(TargetDir)ItemDispenser" />
</Target>

</Project>

0 comments on commit 8879335

Please sign in to comment.