From 6e0f2813aeca032c93d1d8f234c90fbfda16d8a0 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Fri, 19 Apr 2024 10:51:27 +0200 Subject: [PATCH 1/4] refactored some code and added feature [ # ] SubClient.post_blog now accepts IEnumerable instead of List type [ # ] SubClient.post_wiki now accepts IEnumerable instead of List type [ # ] SubClient.edit_blog now accepts IEnumerable instead of List type [ + ] Added ability to pass Links into Client.upload_media(string), this allows people to pass custom media URLs into Amino Media --- Amino.NET/Client.cs | 8 ++++++-- Amino.NET/SubClient.cs | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index e4a34e7..61e8a28 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -4,11 +4,10 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Net.Http; using System.Text; using System.Threading; using System.Threading.Tasks; -using System.Threading.Tasks.Dataflow; -using Amino.Objects; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RestSharp; @@ -1416,6 +1415,11 @@ public Task flag_community(string communityId, string reason, Types.Flag_Types f /// string : The URL to the media file you just uploaded public string upload_media(string filePath, Types.upload_File_Types type) { + if(filePath.StartsWith("http")) + { + byte[] fileBytes = new HttpClient().GetAsync(filePath).Result.Content.ReadAsByteArrayAsync().Result; + return upload_media(fileBytes, type); + } return upload_media(File.ReadAllBytes(filePath), type); } diff --git a/Amino.NET/SubClient.cs b/Amino.NET/SubClient.cs index f3c5d84..5c28894 100644 --- a/Amino.NET/SubClient.cs +++ b/Amino.NET/SubClient.cs @@ -147,7 +147,7 @@ public Task delete_invite_code(string inviteId) /// /// /// - public Task post_blog(string title, string content, List imageList = null, bool fansOnly = false, string backgroundColor = null) + public Task post_blog(string title, string content, IEnumerable imageList = null, bool fansOnly = false, string backgroundColor = null) { JArray mediaList = new JArray(); JObject extensionData = new JObject(); @@ -200,7 +200,7 @@ public Task post_blog(string title, string content, List imageList = nul /// /// /// - public Task post_wiki(string title, string content, List imageList = null, bool fansOnly = false, string backgroundColor = null) + public Task post_wiki(string title, string content, IEnumerable imageList = null, bool fansOnly = false, string backgroundColor = null) { JArray mediaList = new JArray(); JObject extensionData = new JObject(); @@ -249,7 +249,7 @@ public Task post_wiki(string title, string content, List imageList = nul /// /// /// - public Task edit_blog(string blogId, string title = null, string content = null, List imageList = null, bool fansOnly = false, string backgroundColor = null) + public Task edit_blog(string blogId, string title = null, string content = null, IEnumerable imageList = null, bool fansOnly = false, string backgroundColor = null) { JArray mediaList = new JArray(); JObject extensionData = new JObject(); From 0bd1bbd858b9bb75d9b4fcc3b9971ef7da31eff6 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Mon, 22 Apr 2024 12:02:50 +0200 Subject: [PATCH 2/4] Added more functions [ + ] Added Client.get_blog_info(string) [ + ] Added Client.get_wiki_info(string) [ + ] Added Client.get_message_info(string,string) --- Amino.NET/Client.cs | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index 61e8a28..4fca005 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -2425,6 +2425,59 @@ public Task send_sticker(string chatId, string stickerId) return Task.CompletedTask; } + /// + /// Allows you to get information about a blog post + /// + /// + /// + /// + public Objects.Blog get_blog_info(string blogId) + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/g/s/blog/{blogId}"); + request.AddHeaders(headers); + var response = client.ExecuteGet(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return new Objects.Blog(JObject.Parse(response.Content)); + } + + + /// + /// Allows you to get information about a wiki post + /// + /// + /// + /// + public Objects.Wiki get_wiki_info(string wikiId) + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/g/s/item/{wikiId}"); + request.AddHeaders(headers); + var response = client.ExecuteGet(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return new Objects.Wiki(JObject.Parse(response.Content)); + } + + /// + /// Allows you to get information about a message in a chat + /// + /// + /// + /// + /// + public Objects.Message get_message_info(string chatId, string messageId) + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/message/{messageId}"); + request.AddHeaders(headers); + var response = client.ExecuteGet(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return new Objects.Message(JObject.Parse(response.Content)); + } + /// /// Sets the SubClient of the Client, not for development use From 9a3d58f5cadfcd818c2b713b166efd6ccdeca1d2 Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Mon, 22 Apr 2024 12:28:57 +0200 Subject: [PATCH 3/4] Added function template --- Amino.NET/Client.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index 4fca005..7069aff 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -2478,6 +2478,41 @@ public Objects.Message get_message_info(string chatId, string messageId) return new Objects.Message(JObject.Parse(response.Content)); } + /// + /// Allows you to get comments from a blog, THIS FUNCTION IS NOT FINISHED + /// + /// + /// + /// + /// + /// + /// + public List get_blog_comments(string blogId, int start = 0, int size = 25, Types.Sorting_Types sorting = Types.Sorting_Types.Newest) + { + string sortingType = ""; + switch(sorting) + { + case Types.Sorting_Types.Newest: + sortingType = "newest"; + break; + case Types.Sorting_Types.Oldest: + sortingType = "oldest"; + break; + case Types.Sorting_Types.Top: + sortingType = "vote"; + break; + } + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/g/s/blog/{blogId}?sort={sortingType}&start={size}&size={size}"); + request.AddHeaders(headers); + var response = client.ExecuteGet(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + + return null; // FINISH LATER + + } + /// /// Sets the SubClient of the Client, not for development use From 0a0bee23a21d7b08a14bdec84aa42e2ce1eae9ff Mon Sep 17 00:00:00 2001 From: Fabio Gaming Date: Thu, 25 Apr 2024 11:02:01 +0200 Subject: [PATCH 4/4] added functions [ + ] Added Client.register_google(string, string, string, string) [ # ] Client.register() should no longer throw invalid request --- Amino.NET/Client.cs | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index 7069aff..69b248a 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -388,6 +388,47 @@ public Task login_sid(string sessionId, bool fetchProfile = true, bool connectSo return Task.CompletedTask; } + /// + /// Allows you to register an Amino account using a google account + /// + /// + /// + /// + /// + /// + /// + public Task register_google(string nickname, string googleToken, string password, string deviceId = null) + { + deviceId = deviceId == null ? helpers.generate_device_id() : deviceId; + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest("/g/s/auth/login"); + request.AddHeaders(headers); + + Dictionary data = new Dictionary() + { + { "secret", $"12 {googleToken}" }, + { "secret2", $"0 {password}" }, + { "deviceID", deviceId }, + { "clientType", 100 }, + { "nickname", nickname }, + { "latitude", 0 }, + { "longitude", 0 }, + { "address", null }, + { "clientCallbackURL", "narviiapp://relogin" }, + { "timestamp", helpers.GetTimestamp() * 1000 }, + }; + + request.AddJsonBody(System.Text.Json.JsonSerializer.Serialize(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data))); + + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + + + /// /// Allows you to register an Amino account @@ -427,7 +468,7 @@ public Task register(string _name, string _email, string _password, string _veri RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/auth/register"); request.AddHeaders(headers); - request.AddJsonBody(data); + request.AddJsonBody(JsonConvert.SerializeObject(data)); request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { throw new Exception(response.Content); }