Skip to content

Commit

Permalink
Merge pull request #11 from FabioGaming/dev
Browse files Browse the repository at this point in the history
Added v1.1
  • Loading branch information
FabioGaming authored Nov 28, 2022
2 parents 0bb82d6 + c7ae0ae commit 2c4dc48
Show file tree
Hide file tree
Showing 19 changed files with 1,657 additions and 19 deletions.
2 changes: 1 addition & 1 deletion 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.0.0-Dev-6.9.2.1</Version>
<Version>1.1.0-Dev-6.9.2.9</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
125 changes: 119 additions & 6 deletions Amino.NET/Amino.NET.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 97 additions & 2 deletions Amino.NET/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public class Client
//The value to access the websocket manager
private Amino.WebSocketHandler webSocket;
//Events
//public event EventHandler<Objects.Message> onMessage;
/// <summary>
/// Fires each time an Amino Text Message has been received by the current Amino account
/// </summary>
Expand All @@ -100,6 +99,38 @@ public class Client
/// Fires each time an Amino WebSocket Message has been receveived by the current Amino Client
/// </summary>
public event Action<string> onWebSocketMessage;
/// <summary>
/// Fires each time an Amino YouTube message has been received by the current Amino account
/// </summary>
public event Action<Objects.YouTubeMessage> onYouTubeMessage;
/// <summary>
/// Fires each time an Amino Voice message / note has been received by the current Amino account
/// </summary>
public event Action<Objects.VoiceMessage> onVoiceMessage;
/// <summary>
/// Fires each time an Amino Sticker message has been received by the current Amino account
/// </summary>
public event Action<Objects.StickerMessage> onStickerMessage;
/// <summary>
/// Fires each time an Amino message has been deleted (in a chat where the current Amino account is in)
/// </summary>
public event Action<Objects.DeletedMessage> onMessageDeleted;
/// <summary>
/// Fires each time an Amino member joined a chat where the current Amino account is in
/// </summary>
public event Action<Objects.JoinedChatMember> onChatMemberJoin;
/// <summary>
/// Fires each time an Amino member left a chat where the current Amino account is in
/// </summary>
public event Action<Objects.LeftChatMember> onChatMemberLeave;
/// <summary>
/// Fires each time an Amino chat background has changed (only chats where the current Amino account is in)
/// </summary>
public event Action<Objects.ChatEvent> onChatBackgroundChanged;
/// <summary>
/// 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;

//headers.
private IDictionary<string, string> headers = new Dictionary<string, string>();
Expand All @@ -111,9 +142,10 @@ private Task headerBuilder()
headers.Add("NDCDEVICEID", deviceID);
headers.Add("Accept-Language", "en-US");
headers.Add("Content-Type", "application/json; charset=utf-8");
headers.Add("Host", "service.narvii.com");
headers.Add("Host", "service.aminoapps.com");
headers.Add("Accept-Encoding", "gzip");
headers.Add("Connection", "Keep-Alive");
headers.Add("User-Agent", "Dalvik/2.1.0 (Linux; U; Android 7.1.2; SM-G965N Build/star2ltexx-user 7.1.; com.narvii.amino.master/3.4.33602)");
if(sessionID != null) { headers.Add("NDCAUTH", $"sid={sessionID}"); }
return Task.CompletedTask;
}
Expand Down Expand Up @@ -2312,6 +2344,69 @@ public void callImageMessageEvent(Amino.Client _client, Amino.Objects.ImageMessa
_client.onImageMessage.Invoke(_image);
}
}

public void callYouTubeMessageEvent(Amino.Client _client, Amino.Objects.YouTubeMessage _youtubeMessage)
{
if(_client.onYouTubeMessage != null)
{
_client.onYouTubeMessage.Invoke(_youtubeMessage);
}
}

public void callVoiceMessageEvent(Amino.Client _client, Amino.Objects.VoiceMessage _voiceMessage)
{
if(_client.onVoiceMessage != null)
{
_client.onVoiceMessage.Invoke(_voiceMessage);
}
}

public void callStickerMessageEvent(Amino.Client _client, Amino.Objects.StickerMessage _stickerMessage)
{
if(_client.onStickerMessage != null)
{
_client.onStickerMessage.Invoke(_stickerMessage);
}
}

public void callMessageDeletedEvent(Amino.Client _client, Amino.Objects.DeletedMessage _deletedMessage)
{
if(_client.onMessageDeleted != null)
{
_client.onMessageDeleted.Invoke(_deletedMessage);
}
}

public void callChatMemberJoinEvent(Amino.Client _client, Amino.Objects.JoinedChatMember _joinedMember)
{
if(_client.onChatMemberJoin != null)
{
_client.onChatMemberJoin.Invoke(_joinedMember);
}
}

public void callChatMemberLeaveEvent(Amino.Client _client, Amino.Objects.LeftChatMember _leftMember)
{
if(_client.onChatMemberLeave != null)
{
_client.onChatMemberLeave.Invoke(_leftMember);
}
}

public void callChatBackgroundChangedEvent(Amino.Client _client, Amino.Objects.ChatEvent _chatEvent)
{
if(_client.onChatBackgroundChanged != null)
{
_client.onChatBackgroundChanged.Invoke(_chatEvent);
}
}
public void callChatTitleChangedEvent(Amino.Client _client, Amino.Objects.ChatEvent _chatEvent)
{
if(_client.onChatTitleChanged != null)
{
_client.onChatTitleChanged.Invoke(_chatEvent);
}
}
}
}
}
53 changes: 50 additions & 3 deletions Amino.NET/Events/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@

namespace Amino.Events
{
/// <summary>
/// This class is responsible for all Events of Amino.Net
/// </summary>
public class EventHandler
{
/// <summary>
/// This function handles the websocket responses and converts them into objects to call events with
/// </summary>
/// <param name="webSocketMessage"></param>
/// <param name="client"></param>
/// <returns></returns>
public Task ReceiveEvent(JObject webSocketMessage, Client client)
{
Client.Events eventCall = new Client.Events();
Expand All @@ -21,14 +30,52 @@ public Task ReceiveEvent(JObject webSocketMessage, Client client)
{
switch((int)jsonObj["o"]["chatMessage"]["mediaType"])
{
case 0: //TextMessage
Amino.Objects.Message _message = new Amino.Objects.Message(webSocketMessage);
eventCall.callMessageEvent(client, this, _message);
case 0: //TextMessage / MessageDeleted / ChatMember Left, ChatMember Joined / ChatBackground changed / ChatTitle changed
switch((int)jsonObj["o"]["chatMessage"]["type"])
{
case 0: //Textmessage recevied
Amino.Objects.Message _message = new Amino.Objects.Message(webSocketMessage);
eventCall.callMessageEvent(client, this, _message);
break;
case 100: // Textmessage deleted
Amino.Objects.DeletedMessage _deletedMessage = new Objects.DeletedMessage(webSocketMessage);
eventCall.callMessageDeletedEvent(client, _deletedMessage);
break;
case 101: // ChatMember Joined
Amino.Objects.JoinedChatMember _joinedMember = new Objects.JoinedChatMember(webSocketMessage);
eventCall.callChatMemberJoinEvent(client, _joinedMember);
break;
case 102: // ChatMember Left
Amino.Objects.LeftChatMember _leftMember = new Objects.LeftChatMember(webSocketMessage);
eventCall.callChatMemberLeaveEvent(client, _leftMember);
break;
case 104: // ChatBackground changed
Amino.Objects.ChatEvent _chatBackgroundChanged = new Objects.ChatEvent(webSocketMessage);
eventCall.callChatBackgroundChangedEvent(client, _chatBackgroundChanged);
break;
case 105: // ChatTitle changed
Amino.Objects.ChatEvent _chatTitleChanged = new Objects.ChatEvent(webSocketMessage);
eventCall.callChatTitleChangedEvent(client, _chatTitleChanged);
break;
}

break;
case 100: //ImageMessage
Amino.Objects.ImageMessage _imageMessage = new Amino.Objects.ImageMessage(webSocketMessage);
eventCall.callImageMessageEvent(client, _imageMessage);
break;
case 103: //YouTubeMessage
Amino.Objects.YouTubeMessage _youtubeMessage = new Objects.YouTubeMessage(webSocketMessage);
eventCall.callYouTubeMessageEvent(client, _youtubeMessage);
break;
case 110: //VoiceMessage
Amino.Objects.VoiceMessage _voiceMessage = new Objects.VoiceMessage(webSocketMessage);
eventCall.callVoiceMessageEvent(client, _voiceMessage);
break;
case 113: //StickerMessage
Amino.Objects.StickerMessage _stickerMessage = new Objects.StickerMessage(webSocketMessage);
eventCall.callStickerMessageEvent(client, _stickerMessage);
break;
}
}
}
Expand Down
Loading

0 comments on commit 2c4dc48

Please sign in to comment.