Skip to content

Commit

Permalink
Merge pull request #12 from FabioGaming/dev
Browse files Browse the repository at this point in the history
Amino.NET 1.2.0
  • Loading branch information
FabioGaming authored Jan 21, 2023
2 parents 2c4dc48 + 293165c commit e8e7422
Show file tree
Hide file tree
Showing 13 changed files with 681 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Amino.NET/Amino.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>1.1.0-Dev-6.9.2.9</Version>
<Version>1.2.0</Version>
<Authors>FabioTheFox</Authors>
<Company>FabiDev</Company>
<Description>An unofficial C# wrapper for Aminos REST API for making amino bots and tools</Description>
Expand Down Expand Up @@ -36,7 +36,7 @@
</ItemGroup>

<ItemGroup>
<None Include="Amino.Net-Logo-V2.png">
<None Include="..\..\..\..\source\repos\Amino.NET\Amino.NET\Amino.Net-Logo-V2.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
Expand Down
84 changes: 84 additions & 0 deletions Amino.NET/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ public class Client
/// Fires each time an Amino chat title has been changed (only chats where the current Amino account is in)
/// </summary>
public event Action<Objects.ChatEvent> onChatTitleChanged;
/// <summary>
/// Fires each time an Amino chat content has been changed (only in chats where the currnt Amino account is in)
/// </summary>
public event Action<Objects.ChatEvent> onChatContentChanged;
public event Action<Objects.ChatAnnouncement> onChatAnnouncementPin;
public event Action<Objects.ChatEvent> onChatAnnouncementUnpin;
public event Action<Objects.ViewMode> onChatViewModeOn;
public event Action<Objects.ViewMode> onChatViewModeOff;
public event Action<Objects.ChatTipToggle> onChatTipEnabled;
public event Action<Objects.ChatTipToggle> onChatTipDisabled;
public event Action<Objects.SpecialChatEvent> onMessageForceRemovedByAdmin;
public event Action<Objects.ChatTip> onChatTip;

//headers.
private IDictionary<string, string> headers = new Dictionary<string, string>();
Expand Down Expand Up @@ -2407,6 +2419,78 @@ public void callChatTitleChangedEvent(Amino.Client _client, Amino.Objects.ChatEv
_client.onChatTitleChanged.Invoke(_chatEvent);
}
}

public void callChatContentChangedEvent(Amino.Client _client, Amino.Objects.ChatEvent _chatEvent)
{
if(_client.onChatContentChanged != null)
{
_client.onChatContentChanged.Invoke(_chatEvent);
}
}

public void callChatPinAnnouncementEvent(Amino.Client _client, Amino.Objects.ChatAnnouncement _chatAnnouncement)
{
if(_client.onChatAnnouncementPin != null)
{
_client.onChatAnnouncementPin.Invoke(_chatAnnouncement);
}
}

public void callChatUnpinAnnouncementEvent(Amino.Client _client, Amino.Objects.ChatEvent _chatEvent)
{
if(_client.onChatAnnouncementUnpin != null)
{
_client.onChatAnnouncementUnpin.Invoke(_chatEvent);
}
}

public void callChatViewModeOnEvent(Amino.Client _client, Amino.Objects.ViewMode _viewMode)
{
if(_client.onChatViewModeOn != null)
{
_client.onChatViewModeOn.Invoke(_viewMode);
}
}

public void callChatViewModeOffEvent(Amino.Client _client, Amino.Objects.ViewMode _viewMode)
{
if(_client.onChatViewModeOff != null)
{
_client.onChatViewModeOff.Invoke(_viewMode);
}
}

public void callChatTipEnabledEvent(Amino.Client _client, Amino.Objects.ChatTipToggle _chatTip)
{
if(_client.onChatTipEnabled != null)
{
_client.onChatTipEnabled.Invoke(_chatTip);
}
}

public void callChatTipDisabledEvent(Amino.Client _client, Amino.Objects.ChatTipToggle _chatTip)
{
if(_client.onChatTipDisabled != null)
{
_client.onChatTipDisabled.Invoke(_chatTip);
}
}

public void callMessageForceRemovedByAdminEvent(Amino.Client _client, Amino.Objects.SpecialChatEvent _chatEvent)
{
if(_client.onMessageForceRemovedByAdmin != null)
{
_client.onMessageForceRemovedByAdmin.Invoke(_chatEvent);
}
}

public void callChatTipEvent(Amino.Client _client, Amino.Objects.ChatTip _chatTip)
{
if(_client.onChatTip != null)
{
_client.onChatTip.Invoke(_chatTip);
}
}
}
}
}
39 changes: 38 additions & 1 deletion Amino.NET/Events/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Task ReceiveEvent(JObject webSocketMessage, Client client)
{
switch((int)jsonObj["o"]["chatMessage"]["mediaType"])
{
case 0: //TextMessage / MessageDeleted / ChatMember Left, ChatMember Joined / ChatBackground changed / ChatTitle changed
case 0: //TextMessage / MessageDeleted / ChatMember Left, ChatMember Joined / ChatBackground changed / ChatTitle changed / ChatContent chaaged / ChatAnnouncementPin / ChatAnnouncementUnpin / ChatViewOnlyOn / ChatViewOnlyOff / ChatTipEnabled / ChatTipDisabled / MessageForceRemoved / ChatTip
switch((int)jsonObj["o"]["chatMessage"]["type"])
{
case 0: //Textmessage recevied
Expand All @@ -57,6 +57,43 @@ public Task ReceiveEvent(JObject webSocketMessage, Client client)
Amino.Objects.ChatEvent _chatTitleChanged = new Objects.ChatEvent(webSocketMessage);
eventCall.callChatTitleChangedEvent(client, _chatTitleChanged);
break;
case 113: // ChatContent Changed
Amino.Objects.ChatEvent _chatContentChanged = new Objects.ChatEvent(webSocketMessage);
eventCall.callChatContentChangedEvent(client, _chatContentChanged);
break;
case 119: // MessageForceRemovedByAdmin
Amino.Objects.SpecialChatEvent _messageForceRemovedByAdmin = new Objects.SpecialChatEvent(webSocketMessage);
eventCall.callMessageForceRemovedByAdminEvent(client, _messageForceRemovedByAdmin);
break;
case 120: // ChatTip
Amino.Objects.ChatTip _chatTip = new Objects.ChatTip(webSocketMessage);
eventCall.callChatTipEvent(client, _chatTip);
break;
case 121: // ChatAnnouncementPin
Amino.Objects.ChatAnnouncement _chatAnnouncementPinEvent = new Objects.ChatAnnouncement(webSocketMessage);
eventCall.callChatPinAnnouncementEvent(client, _chatAnnouncementPinEvent);
break;
case 125: // ChatViewModeOn
Amino.Objects.ViewMode _viewModeOn = new Objects.ViewMode(webSocketMessage);
eventCall.callChatViewModeOnEvent(client, _viewModeOn);
break;
case 126: // ChatViewModeOff
Amino.Objects.ViewMode _viewModeOff = new Objects.ViewMode(webSocketMessage);
eventCall.callChatViewModeOffEvent(client, _viewModeOff);
break;
case 127: // ChatAnnouncementUnPin
Amino.Objects.ChatEvent _chatAnnouncementUnPin = new Objects.ChatEvent(webSocketMessage);
eventCall.callChatUnpinAnnouncementEvent(client, _chatAnnouncementUnPin);
break;
case 128: // ChatTipEnabled
Amino.Objects.ChatTipToggle _chatTipEnabled = new Objects.ChatTipToggle(webSocketMessage);
eventCall.callChatTipEnabledEvent(client, _chatTipEnabled);
break;
case 129: // ChatTipDisabled
Amino.Objects.ChatTipToggle _chatTipDisabled = new Objects.ChatTipToggle(webSocketMessage);
eventCall.callChatTipDisabledEvent(client, _chatTipDisabled);
break;

}

break;
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
49 changes: 49 additions & 0 deletions Amino.NET/Objects/ChatAnnouncement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Amino.Objects
{

[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class ChatAnnouncement
{
public int _type { get; }
public int communityId { get; }
public int alertOption { get; }
public int membershipStatus { get; }

public string chatId { get; }
public int mediaType { get; }
public string content { get; }
public int clientRefId { get; }
public string messageId { get; }
public string userId { get; }
public string createdTime { get; }
public int type { get; }
public bool isHidden { get; }
public bool includedInSummary { get; }
public string json { get; }

public ChatAnnouncement(JObject _json)
{
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
_type = (int)jsonObj["t"];
communityId = (int)jsonObj["o"]["ndcId"];
alertOption = (int)jsonObj["o"]["alertOption"];
membershipStatus = (int)jsonObj["o"]["membershipStatus"];

chatId = (string)jsonObj["o"]["chatMessage"]["threadId"];
mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"];
content = (string)jsonObj["o"]["chatMessage"]["content"];
clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"];
messageId = (string)jsonObj["o"]["chatMessage"]["messageId"];
userId = (string)jsonObj["o"]["chatMessage"]["uid"];
createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"];
type = (int)jsonObj["o"]["chatMessage"]["type"];
isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"];
includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"];
json = _json.ToString();
}

}
}
134 changes: 134 additions & 0 deletions Amino.NET/Objects/ChatTip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Amino.Objects
{
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class ChatTip
{
public int _type { get; }
public int alertOption { get; }
public int membershipStatus { get; }
public int communityId { get; }

public string chatId { get; }
public int mediaType { get; }
public int clientRefId { get; }
public string messageId { get; }
public string userId { get; }
public string createdTime { get; }
public int type { get; }
public bool isHidden { get; }
public bool includedInSummary { get; }
public string json { get; }
public _Author Author { get; }
public _Extensions Extensions { get; }


public ChatTip(JObject _json)
{
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
_type = (int)jsonObj["t"];
alertOption = (int)jsonObj["o"]["alertOption"];
membershipStatus = (int)jsonObj["o"]["membershipStatus"];
communityId = (int)jsonObj["o"]["ndcId"];

chatId = (string)jsonObj["o"]["chatMessage"]["threadId"];
mediaType = (int)jsonObj["o"]["chatMessage"]["mediaType"];
clientRefId = (int)jsonObj["o"]["chatMessage"]["clientRefId"];
messageId = (string)jsonObj["o"]["chatMessage"]["messageId"];
userId = (string)jsonObj["o"]["chatMessage"]["uid"];
createdTime = (string)jsonObj["o"]["chatMessage"]["createdTime"];
type = (int)jsonObj["o"]["chatMessage"]["type"];
isHidden = (bool)jsonObj["o"]["chatMessage"]["isHidden"];
includedInSummary = (bool)jsonObj["o"]["chatMessage"]["includedInSummary"];
json = _json.ToString();
Author = new _Author(_json);
Extensions = new _Extensions(_json);

}

[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class _Author
{
public string userId { get; }
public int status { get; }
public string iconUrl { get; }
public int reputation { get; }
public int role { get; }
public string nickname { get; }
public int level { get; }
public int accountMembershipStatus { get; }
public string avatarFrameId { get; }
public _AvatarFrame AvatarFrame { get; }
public _InfluencerInfo InfluencerInfo { get; }

public _Author(JObject _json)
{
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
userId = (string)jsonObj["o"]["chatMessage"]["author"]["uid"];
status = (int)jsonObj["o"]["chatMessage"]["author"]["status"];
if(jsonObj["o"]["chatMessage"]["author"]["icon"] != null) { iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["icon"]; }
reputation = (int)jsonObj["o"]["chatMessage"]["author"]["reputation"];
role = (int)jsonObj["o"]["chatMessage"]["author"]["role"];
nickname = (string)jsonObj["o"]["chatMessage"]["author"]["nickname"];
level = (int)jsonObj["o"]["chatMessage"]["author"]["level"];
accountMembershipStatus = (int)jsonObj["o"]["chatMessage"]["author"]["accountMembershipStatus"];
avatarFrameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrameId"];
if(jsonObj["o"]["chatMessage"]["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); }
if(jsonObj["o"]["chatMessage"]["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); }
}


[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class _AvatarFrame
{
public int status { get; }
public int version { get; }
public string resourceUrl { get; }
public string name { get; }
public string iconUrl { get; }
public int frameType { get; }
public string frameId { get; }

public _AvatarFrame(JObject _json)
{
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
status = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["status"];
version = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["version"];
resourceUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["resourceUrl"];
name = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["name"];
iconUrl = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["icon"];
frameType = (int)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameType"];
frameId = (string)jsonObj["o"]["chatMessage"]["author"]["avatarFrame"]["frameId"];
}
}

[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class _InfluencerInfo
{
public int fansCount { get; }
public int monthlyFee { get; }

public _InfluencerInfo(JObject _json)
{
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
fansCount = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["fansCount"];
monthlyFee = (int)jsonObj["o"]["chatMessage"]["author"]["influencerInfo"]["monthlyFee"];
}
}
}

[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class _Extensions
{
public int tippedCoins { get; }

public _Extensions(JObject _json)
{
dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString());
tippedCoins = (int)jsonObj["o"]["chatMessage"]["extensions"]["tippingCoins"];
}
}
}
}
Loading

0 comments on commit e8e7422

Please sign in to comment.