Skip to content

Commit 442bc3e

Browse files
committed
Bug fixes
1 parent 9b921d0 commit 442bc3e

File tree

3 files changed

+52
-31
lines changed

3 files changed

+52
-31
lines changed

AutoClaimStickers/AutoClaimStickers.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ private static async Task ClaimItemTask(Bot bot) {
114114
}
115115
(bool success, ClaimItemResponse? response) = await ClaimItem(bot, token).ConfigureAwait(false);
116116
if (success) {
117-
CommunityItemData? rewardItemData = response!.RewardItem?.community_item_data;
118-
ASF.ArchiLogger.LogGenericInfo($"[{bot.BotName}] Claim success! ItemId: {response.CommunityItemId}{(rewardItemData == null ? "" : $"({rewardItemData.item_name})")}");
117+
CommunityItem? rewardItemData = response!.RewardItem?.CommunityItemData;
118+
ASF.ArchiLogger.LogGenericInfo($"[{bot.BotName}] Claim success! ItemId: {response.CommunityItemId}{(rewardItemData == null ? "" : $"({rewardItemData.ItemName})")}");
119119
} else {
120120
ASF.ArchiLogger.LogGenericWarning($"[{bot.BotName}] Claim failed! Response: {JsonSerializer.Serialize(response, SerializerOptions)}");
121121
}
@@ -132,7 +132,7 @@ private static async Task<bool> CanClaimItem(Bot bot, string token) {
132132
return (false, response?.Content?.Response);
133133
}
134134
ClaimItemData? result = response.Content;
135-
return (result?.Response?.CommunityItemId > 0, result?.Response);
135+
return (!string.IsNullOrWhiteSpace(result?.Response?.CommunityItemId), result?.Response);
136136
}
137137
private async void OnAutoClaimTimer(object? state = null) => await AutoClaim().ConfigureAwait(false);
138138
public void Dispose() => AutoClaimTimer?.Dispose();

AutoClaimStickers/ClaimItemData.cs

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal sealed record CanClaimItemResponse {
1111
[JsonPropertyName("can_claim")]
1212
public bool? CanClaim { get; init; }
1313
[JsonPropertyName("next_claim_time")]
14-
public int? NextClaimTime { get; init; }
14+
public uint? NextClaimTime { get; init; }
1515
[JsonPropertyName("reward_item")]
1616
public RewardItem? RewardItem { get; init; }
1717
}
@@ -21,37 +21,58 @@ internal sealed record ClaimItemData {
2121
}
2222
internal sealed record ClaimItemResponse {
2323
[JsonPropertyName("communityitemid")]
24-
public long? CommunityItemId { get; init; }
24+
public string? CommunityItemId { get; init; }
2525
[JsonPropertyName("next_claim_time")]
26-
public int? NextClaimTime { get; init; }
26+
public uint? NextClaimTime { get; init; }
2727
[JsonPropertyName("reward_item")]
2828
public RewardItem? RewardItem { get; init; }
2929
}
30-
#pragma warning disable IDE1006
3130
internal sealed record RewardItem {
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; }
31+
[JsonPropertyName("appid")]
32+
public int? AppId { get; init; }
33+
[JsonPropertyName("defid")]
34+
public int? DefId { get; init; }
35+
[JsonPropertyName("type")]
36+
public int? Type { get; init; }
37+
[JsonPropertyName("community_item_class")]
38+
public int? CommunityItemClass { get; init; }
39+
[JsonPropertyName("community_item_type")]
40+
public int? CommunityItemType { get; init; }
41+
[JsonPropertyName("point_cost")]
42+
public string? PointCost { get; init; }
43+
[JsonPropertyName("timestamp_created")]
44+
public uint? TimestampCreated { get; init; }
45+
[JsonPropertyName("timestamp_updated")]
46+
public uint? TimestampUpdated { get; init; }
47+
[JsonPropertyName("timestamp_available")]
48+
public uint? TimestampAvailable { get; init; }
49+
[JsonPropertyName("timestamp_available_end")]
50+
public uint? TimestampAvailableEnd { get; init; }
51+
[JsonPropertyName("quantity")]
52+
public string? Quantity { get; init; }
53+
[JsonPropertyName("internal_description")]
54+
public string? InternalDescription { get; init; }
55+
[JsonPropertyName("active")]
56+
public bool? Active { get; init; }
57+
[JsonPropertyName("community_item_data")]
58+
public CommunityItem? CommunityItemData { get; init; }
59+
[JsonPropertyName("usable_duration")]
60+
public int? UsableDuration { get; init; }
61+
[JsonPropertyName("bundle_discount")]
62+
public int? BundleDiscount { get; init; }
4863
}
49-
internal sealed record CommunityItemData {
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; }
64+
internal sealed record CommunityItem {
65+
[JsonPropertyName("item_name")]
66+
public string? ItemName { get; init; }
67+
[JsonPropertyName("item_title")]
68+
public string? ItemTitle { get; init; }
69+
[JsonPropertyName("item_description")]
70+
public string? ItemDescription { get; init; }
71+
[JsonPropertyName("item_image_small")]
72+
public string? ItemImageSmall { get; init; }
73+
[JsonPropertyName("item_image_large")]
74+
public string? ItemImageLarge { get; init; }
75+
[JsonPropertyName("animated")]
76+
public bool? Animated { get; init; }
5677
}
5778
#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.3</Version>
6+
<Version>1.0.1.4</Version>
77
</PropertyGroup>
88

99
<PropertyGroup>

0 commit comments

Comments
 (0)