Skip to content

Commit decfd27

Browse files
committed
refactored more objects
1 parent def723f commit decfd27

12 files changed

Lines changed: 184 additions & 345 deletions

Amino.NET/Events/EventHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public Task ReceiveEvent(JObject webSocketMessage, Client client)
2828
try
2929
{
3030
JsonElement root = JsonDocument.Parse(webSocketMessage.ToString()).RootElement;
31-
SocketBase sBase = System.Text.Json.JsonSerializer.Deserialize<SocketBase>(root.GetProperty("o"));
3231
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(webSocketMessage.ToString());
3332
if(jsonObj["o"]["chatMessage"]["mediaType"] != null)
3433
{
35-
36-
switch((int)jsonObj["o"]["chatMessage"]["mediaType"])
34+
35+
SocketBase sBase = System.Text.Json.JsonSerializer.Deserialize<SocketBase>(root.GetProperty("o"));
36+
switch ((int)jsonObj["o"]["chatMessage"]["mediaType"])
3737
{
3838
case 0: //TextMessage / MessageDeleted / ChatMember Left, ChatMember Joined / ChatBackground changed / ChatTitle changed / ChatContent chaaged / ChatAnnouncementPin / ChatAnnouncementUnpin / ChatViewOnlyOn / ChatViewOnlyOff / ChatTipEnabled / ChatTipDisabled / MessageForceRemoved / ChatTip
3939
switch((int)jsonObj["o"]["chatMessage"]["type"])

Amino.NET/Objects/DeviceInfo.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class DeviceInfo
11+
{
12+
[JsonPropertyName("lastClientType")] public int LastClientType { get; set; }
13+
}
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class GenericAuthorExtensions
11+
{
12+
/// <summary>
13+
/// <para>The ID of the original sticker</para>
14+
/// NOTE: this might only be availabe in the context of a <see cref="Objects.StickerMessage"/>
15+
/// </summary>
16+
[JsonPropertyName("originalStickerId")] public string OriginalStickerId { get; set; }
17+
/// <summary>
18+
/// <para>The Sticker object related to this Extensions object</para>
19+
/// NOTE: this might only be availabe in the context of a <see cref="Objects.StickerMessage"/>
20+
/// </summary>
21+
[JsonPropertyName("sticker")] public Sticker Sticker { get; set; }
22+
}
23+
}

Amino.NET/Objects/GenericProfile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class GenericProfile // ROOT JSON ELEMENT: userProfile
2424

2525
[JsonPropertyName("avatarFrame")] public GenericAvatarFrame AvatarFrame { get; set; }
2626
[JsonPropertyName("influencerInfo")] public InfluencerPriceInfo InfluencerInfo { get; set; }
27+
[JsonPropertyName("extensions")] public GenericAuthorExtensions Extensions { get; set; }
2728

2829
}
2930
}

Amino.NET/Objects/SpecialChatEvent.cs

Lines changed: 15 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,26 @@
11
using Newtonsoft.Json;
22
using Newtonsoft.Json.Linq;
3+
using System.Text.Json.Serialization;
34

45
namespace Amino.Objects
56
{
67

7-
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
8+
// ROOT JSON ELEMENT: o/chatMessage
89
public class SpecialChatEvent
910
{
10-
11-
public int _type { get; }
12-
public int communityId { get; }
13-
public int alertOption { get; }
14-
public int membershipStatus { get; }
15-
16-
public string chatId { get; }
17-
public int mediaType { get; }
18-
public int clientRefId { get; }
19-
public string messageId { get; }
20-
public string userId { get; }
21-
public string createdTime { get; }
22-
public int type { get; }
23-
public bool isHidden { get; }
24-
public bool includedInSummary { get; }
25-
public string json { get; }
26-
public _Author Author { get; }
27-
28-
public SpecialChatEvent(JObject _json)
29-
{
30-
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
31-
_type = (int)jsonObj["t"];
32-
communityId = (int)jsonObj["o"]["ndcId"];
33-
alertOption = (int)jsonObj["o"]["alertOption"];
34-
membershipStatus = (int)jsonObj["o"]["membershipStatus"];
35-
36-
chatId = (string)jsonObj["o"]["chatMessage"]["threadId"];
37-
mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"];
38-
clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"];
39-
messageId = (string)jsonObj["o"]["chatMessage"]["messageId"];
40-
userId = (string)jsonObj["o"]["chatMessage"]["uid"];
41-
createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"];
42-
type = (int)jsonObj["o"]["chatMessage"]["type"];
43-
isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"];
44-
includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"];
45-
json = _json.ToString();
46-
Author = new _Author(_json);
47-
}
48-
49-
50-
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
51-
public class _Author
52-
{
53-
public string userId { get; }
54-
public int status { get; }
55-
public string iconUrl { get; }
56-
public int reputation { get; }
57-
public int role { get; }
58-
public string nickname { get; }
59-
public int level { get; }
60-
public int accountMembershipStatus { get; }
61-
public _AvatarFrame AvatarFrame { get; }
62-
public _InfluencerInfo InfluencerInfo { get; }
63-
64-
public _Author(JObject _json)
65-
{
66-
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
67-
userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"];
68-
status = (int)jsonObj["o"]["chatMessage"]["author"]["status"];
69-
if (jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; }
70-
reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"];
71-
role = (int)jsonObj["o"]["chatMessage"]["author"]["role"];
72-
nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"];
73-
level = (int)jsonObj["o"]["chatMessage"]["author"]["level"];
74-
accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"];
75-
if (jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); }
76-
if (jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); }
77-
78-
79-
}
80-
81-
82-
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
83-
public class _AvatarFrame
84-
{
85-
public int status { get; }
86-
public int version { get; }
87-
public string resourceUrl { get; }
88-
public string name { get; }
89-
public string iconUrl { get; }
90-
public int frameType { get; }
91-
public string frameId { get; }
92-
93-
public _AvatarFrame(JObject _json)
94-
{
95-
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
96-
status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"];
97-
version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"];
98-
resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"];
99-
name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"];
100-
iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"];
101-
frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"];
102-
frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"];
103-
}
104-
}
105-
106-
107-
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
108-
public class _InfluencerInfo
109-
{
110-
public int fansCount { get; }
111-
public int monthlyFee { get; }
112-
113-
public _InfluencerInfo(JObject _json)
114-
{
115-
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
116-
fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"];
117-
monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"];
118-
}
119-
}
120-
}
121-
11+
public SocketBase SocketBase { get; set; }
12+
public string Json { get; set; }
13+
14+
[JsonPropertyName("threadId")]public string ChatId { get; set; }
15+
[JsonPropertyName("mediaType")]public int MediaType { get; set; }
16+
[JsonPropertyName("clientRefId")]public int ClientRefId { get; set; }
17+
[JsonPropertyName("messageId")]public string MessageId { get; set; }
18+
[JsonPropertyName("uid")]public string ObjectId { get; set; }
19+
[JsonPropertyName("createdTime")]public string CreatedTime { get; set; }
20+
[JsonPropertyName("type")]public int Type { get; set; }
21+
[JsonPropertyName("isHidden")]public bool IsHidden { get; set; }
22+
[JsonPropertyName("includedInSummary")]public bool IncludedInSummary { get; set; }
23+
[JsonPropertyName("author")]public GenericProfile Author { get; set; }
12224

12325

12426
}

Amino.NET/Objects/Sticker.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class Sticker
11+
{
12+
[JsonPropertyName("status")] public int Status { get; set; }
13+
[JsonPropertyName("iconV2")] public string IconV2Url { get; set; }
14+
[JsonPropertyName("stickerId")] public string StickerId { get; set; }
15+
[JsonPropertyName("smallIconV2")] public string SmallIconV2Url { get; set; }
16+
[JsonPropertyName("smallIcon")] public string SmallIconUrl { get; set; }
17+
[JsonPropertyName("stickerCollectionId")] public string StickerCollectionId { get; set; }
18+
[JsonPropertyName("mediumIcon")] public string MediumIconUrl { get; set; }
19+
[JsonPropertyName("usedCount")] public int UsedCount { get; set; }
20+
[JsonPropertyName("mediumIconV2")] public string MediumIconV2Url { get; set; }
21+
[JsonPropertyName("createdTime")] public string CreatedTime { get; set; }
22+
[JsonPropertyName("icon")] public string IconUrl { get; set; }
23+
[JsonPropertyName("stickerCollectionSummary")] StickerCollectionSummary StickerCollectionSummary { get; set; }
24+
}
25+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.Json.Serialization;
6+
using System.Threading.Tasks;
7+
8+
namespace Amino.Objects
9+
{
10+
public class StickerCollectionSummary
11+
{
12+
[JsonPropertyName("status")] public int Status { get; set; }
13+
[JsonPropertyName("collectionType")] public int CollectionType { get; set; }
14+
[JsonPropertyName("uid")] public string ObjectId { get; set; }
15+
[JsonPropertyName("modifiedTime")] public string ModifiedTime { get; set; }
16+
[JsonPropertyName("smallIcon")] public string SmallIconUrl { get; set; }
17+
[JsonPropertyName("usedCount")] public int UsedCount { get; set; }
18+
[JsonPropertyName("icon")] public string IconUrl { get; set; }
19+
[JsonPropertyName("name")] public string Name { get; set; }
20+
[JsonPropertyName("collectionId")] public string CollectionId { get; set; }
21+
[JsonPropertyName("createdTime")] public string CreatedTime { get; set; }
22+
}
23+
}

0 commit comments

Comments
 (0)