Skip to content

Commit 9b921d0

Browse files
committed
Update ArchiSteamFarm to 6.0.1.2
1 parent a5ae68d commit 9b921d0

File tree

5 files changed

+60
-55
lines changed

5 files changed

+60
-55
lines changed

ArchiSteamFarm

Submodule ArchiSteamFarm updated 171 files

AutoClaimStickers/AutoClaimStickers.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
using System.Collections.Immutable;
44
using System.Composition;
55
using System.Linq;
6+
using System.Text.Json;
7+
using System.Text.Json.Serialization;
68
using System.Threading;
79
using System.Threading.Tasks;
810
using ArchiSteamFarm.Core;
911
using ArchiSteamFarm.Plugins.Interfaces;
1012
using ArchiSteamFarm.Steam;
1113
using ArchiSteamFarm.Steam.Integration;
1214
using ArchiSteamFarm.Web.Responses;
13-
using Newtonsoft.Json;
14-
using Newtonsoft.Json.Linq;
1515

1616
namespace AutoClaimStickers;
1717

@@ -26,31 +26,37 @@ internal sealed class AutoClaimStickers : IPlugin, IASF, IDisposable {
2626
private Timer? AutoClaimTimer;
2727
private static readonly SemaphoreSlim AutoClaimSemaphore = new(1, 1);
2828
private static readonly SemaphoreSlim BotSemaphore = new(3, 3);
29+
private static readonly JsonSerializerOptions SerializerOptions = new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
2930

3031
public Task OnLoaded() {
3132
AutoClaimTimer = new(OnAutoClaimTimer);
3233
return Task.CompletedTask;
3334
}
34-
public Task OnASFInit(IReadOnlyDictionary<string, JToken>? additionalConfigProperties = null) {
35+
public Task OnASFInit(IReadOnlyDictionary<string, JsonElement>? additionalConfigProperties = null) {
3536
if (additionalConfigProperties == null) {
3637
return Task.CompletedTask;
3738
}
3839
if (AutoClaimTimer == null) {
3940
throw new InvalidOperationException(nameof(AutoClaimTimer));
4041
}
41-
foreach ((string configProperty, JToken configValue) in additionalConfigProperties) {
42+
foreach ((string configProperty, JsonElement configValue) in additionalConfigProperties) {
4243
switch (configProperty) {
43-
case $"{nameof(AutoClaimStickers)}{nameof(Interval)}" when configValue.Type == JTokenType.Integer:
44-
lock (AutoClaimSemaphore) {
45-
Interval = configValue.Value<ushort>();
44+
case $"{nameof(AutoClaimStickers)}{nameof(Interval)}" when configValue.ValueKind == JsonValueKind.Number:
45+
if (configValue.TryGetUInt16(out ushort iterval)) {
46+
lock (AutoClaimSemaphore) {
47+
Interval = iterval;
48+
}
4649
}
4750
break;
48-
case $"{nameof(AutoClaimStickers)}{nameof(Blacklist)}" when configValue.Type == JTokenType.Array:
49-
JArray? array = configValue.Value<JArray>();
50-
if (array != null) {
51+
case $"{nameof(AutoClaimStickers)}{nameof(Blacklist)}" when configValue.ValueKind == JsonValueKind.Array:
52+
ImmutableHashSet<string>? blackList = null;
53+
try {
54+
blackList = configValue.EnumerateArray().Select(item => item.GetString() ?? string.Empty).Where(item => !string.IsNullOrWhiteSpace(item)).ToImmutableHashSet();
5155
lock (Blacklist) {
52-
Blacklist = array.ToObject<ImmutableHashSet<string>>() ?? [];
56+
Blacklist = blackList;
5357
}
58+
} catch (Exception) {
59+
ASF.ArchiLogger.LogGenericWarning($"Invalid config property: {configProperty}");
5460
}
5561
break;
5662
default:
@@ -111,7 +117,7 @@ private static async Task ClaimItemTask(Bot bot) {
111117
CommunityItemData? rewardItemData = response!.RewardItem?.community_item_data;
112118
ASF.ArchiLogger.LogGenericInfo($"[{bot.BotName}] Claim success! ItemId: {response.CommunityItemId}{(rewardItemData == null ? "" : $"({rewardItemData.item_name})")}");
113119
} else {
114-
ASF.ArchiLogger.LogGenericWarning($"[{bot.BotName}] Claim failed! Response: {JsonConvert.SerializeObject(response, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })}");
120+
ASF.ArchiLogger.LogGenericWarning($"[{bot.BotName}] Claim failed! Response: {JsonSerializer.Serialize(response, SerializerOptions)}");
115121
}
116122
}
117123
private static async Task<bool> CanClaimItem(Bot bot, string token) {

AutoClaimStickers/AutoClaimStickers.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<ItemGroup>
77
<PackageReference Include="ConfigureAwaitChecker.Analyzer" PrivateAssets="all" />
88
<PackageReference Include="JetBrains.Annotations" PrivateAssets="all" />
9-
<PackageReference Include="Newtonsoft.Json" IncludeAssets="compile" />
109
<PackageReference Include="System.Composition.AttributedModel" IncludeAssets="compile" />
1110
</ItemGroup>
1211

AutoClaimStickers/ClaimItemData.cs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json.Serialization;
22

33
namespace AutoClaimStickers;
4+
45
#pragma warning disable CA1812
56
internal sealed record CanClaimItemData {
6-
[JsonProperty("response", Required = Required.Always)]
7-
public CanClaimItemResponse? Response { get; set; }
7+
[JsonPropertyName("response"), JsonRequired]
8+
public CanClaimItemResponse? Response { get; init; }
89
}
910
internal sealed record CanClaimItemResponse {
10-
[JsonProperty("can_claim")]
11-
public bool? CanClaim { get; set; }
12-
[JsonProperty("next_claim_time")]
13-
public int? NextClaimTime { get; set; }
14-
[JsonProperty("reward_item")]
15-
public RewardItem? RewardItem { get; set; }
11+
[JsonPropertyName("can_claim")]
12+
public bool? CanClaim { get; init; }
13+
[JsonPropertyName("next_claim_time")]
14+
public int? NextClaimTime { get; init; }
15+
[JsonPropertyName("reward_item")]
16+
public RewardItem? RewardItem { get; init; }
1617
}
1718
internal sealed record ClaimItemData {
18-
[JsonProperty("response", Required = Required.Always)]
19-
public ClaimItemResponse? Response { get; set; }
19+
[JsonPropertyName("response"), JsonRequired]
20+
public ClaimItemResponse? Response { get; init; }
2021
}
2122
internal sealed record ClaimItemResponse {
22-
[JsonProperty("communityitemid")]
23-
public long? CommunityItemId { get; set; }
24-
[JsonProperty("next_claim_time")]
25-
public int? NextClaimTime { get; set; }
26-
[JsonProperty("reward_item")]
27-
public RewardItem? RewardItem { get; set; }
23+
[JsonPropertyName("communityitemid")]
24+
public long? CommunityItemId { get; init; }
25+
[JsonPropertyName("next_claim_time")]
26+
public int? NextClaimTime { get; init; }
27+
[JsonPropertyName("reward_item")]
28+
public RewardItem? RewardItem { get; init; }
2829
}
2930
#pragma warning disable IDE1006
3031
internal sealed record RewardItem {
31-
public int? appid { get; set; }
32-
public int? defid { get; set; }
33-
public int? type { get; set; }
34-
public int? community_item_class { get; set; }
35-
public int? community_item_type { get; set; }
36-
public string? point_cost { get; set; }
37-
public int? timestamp_created { get; set; }
38-
public int? timestamp_updated { get; set; }
39-
public int? timestamp_available { get; set; }
40-
public int? timestamp_available_end { get; set; }
41-
public string? quantity { get; set; }
42-
public string? internal_description { get; set; }
43-
public bool? active { get; set; }
44-
public CommunityItemData? community_item_data { get; set; }
45-
public int? usable_duration { get; set; }
46-
public int? bundle_discount { get; set; }
32+
public int? appid { get; init; }
33+
public int? defid { get; init; }
34+
public int? type { get; init; }
35+
public int? community_item_class { get; init; }
36+
public int? community_item_type { get; init; }
37+
public string? point_cost { get; init; }
38+
public int? timestamp_created { get; init; }
39+
public int? timestamp_updated { get; init; }
40+
public int? timestamp_available { get; init; }
41+
public int? timestamp_available_end { get; init; }
42+
public string? quantity { get; init; }
43+
public string? internal_description { get; init; }
44+
public bool? active { get; init; }
45+
public CommunityItemData? community_item_data { get; init; }
46+
public int? usable_duration { get; init; }
47+
public int? bundle_discount { get; init; }
4748
}
4849
internal sealed record CommunityItemData {
49-
public string? item_name { get; set; }
50-
public string? item_title { get; set; }
51-
public string? item_description { get; set; }
52-
public string? item_image_small { get; set; }
53-
public string? item_image_large { get; set; }
54-
public bool? animated { get; set; }
50+
public string? item_name { get; init; }
51+
public string? item_title { get; init; }
52+
public string? item_description { get; init; }
53+
public string? item_image_small { get; init; }
54+
public string? item_image_large { get; init; }
55+
public bool? animated { get; init; }
5556
}
56-
#pragma warning restore IDE1006
5757
#pragma warning restore CA1812

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<PropertyGroup>
55
<PluginName>AutoClaimStickers</PluginName>
6-
<Version>1.0.1.2</Version>
6+
<Version>1.0.1.3</Version>
77
</PropertyGroup>
88

99
<PropertyGroup>

0 commit comments

Comments
 (0)