|
4 | 4 | using System.Globalization;
|
5 | 5 | using System.IO;
|
6 | 6 | using System.Linq;
|
| 7 | +using System.Net.Http; |
7 | 8 | using System.Text;
|
8 | 9 | using System.Threading;
|
9 | 10 | using System.Threading.Tasks;
|
10 |
| -using System.Threading.Tasks.Dataflow; |
11 |
| -using Amino.Objects; |
12 | 11 | using Newtonsoft.Json;
|
13 | 12 | using Newtonsoft.Json.Linq;
|
14 | 13 | using RestSharp;
|
@@ -389,6 +388,47 @@ public Task login_sid(string sessionId, bool fetchProfile = true, bool connectSo
|
389 | 388 | return Task.CompletedTask;
|
390 | 389 | }
|
391 | 390 |
|
| 391 | + /// <summary> |
| 392 | + /// Allows you to register an Amino account using a google account |
| 393 | + /// </summary> |
| 394 | + /// <param name="nickname"></param> |
| 395 | + /// <param name="googleToken"></param> |
| 396 | + /// <param name="password"></param> |
| 397 | + /// <param name="deviceId"></param> |
| 398 | + /// <returns></returns> |
| 399 | + /// <exception cref="Exception"></exception> |
| 400 | + public Task register_google(string nickname, string googleToken, string password, string deviceId = null) |
| 401 | + { |
| 402 | + deviceId = deviceId == null ? helpers.generate_device_id() : deviceId; |
| 403 | + RestClient client = new RestClient(helpers.BaseUrl); |
| 404 | + RestRequest request = new RestRequest("/g/s/auth/login"); |
| 405 | + request.AddHeaders(headers); |
| 406 | + |
| 407 | + Dictionary<string, object> data = new Dictionary<string, object>() |
| 408 | + { |
| 409 | + { "secret", $"12 {googleToken}" }, |
| 410 | + { "secret2", $"0 {password}" }, |
| 411 | + { "deviceID", deviceId }, |
| 412 | + { "clientType", 100 }, |
| 413 | + { "nickname", nickname }, |
| 414 | + { "latitude", 0 }, |
| 415 | + { "longitude", 0 }, |
| 416 | + { "address", null }, |
| 417 | + { "clientCallbackURL", "narviiapp://relogin" }, |
| 418 | + { "timestamp", helpers.GetTimestamp() * 1000 }, |
| 419 | + }; |
| 420 | + |
| 421 | + request.AddJsonBody(System.Text.Json.JsonSerializer.Serialize(data)); |
| 422 | + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data))); |
| 423 | + |
| 424 | + var response = client.ExecutePost(request); |
| 425 | + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } |
| 426 | + if(debug) { Trace.WriteLine(response.Content); } |
| 427 | + return Task.CompletedTask; |
| 428 | + } |
| 429 | + |
| 430 | + |
| 431 | + |
392 | 432 |
|
393 | 433 | /// <summary>
|
394 | 434 | /// Allows you to register an Amino account
|
@@ -428,7 +468,7 @@ public Task register(string _name, string _email, string _password, string _veri
|
428 | 468 | RestClient client = new RestClient(helpers.BaseUrl);
|
429 | 469 | RestRequest request = new RestRequest("/g/s/auth/register");
|
430 | 470 | request.AddHeaders(headers);
|
431 |
| - request.AddJsonBody(data); |
| 471 | + request.AddJsonBody(JsonConvert.SerializeObject(data)); |
432 | 472 | request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data)));
|
433 | 473 | var response = client.ExecutePost(request);
|
434 | 474 | if ((int)response.StatusCode != 200) { throw new Exception(response.Content); }
|
@@ -1416,6 +1456,11 @@ public Task flag_community(string communityId, string reason, Types.Flag_Types f
|
1416 | 1456 | /// <returns>string : The URL to the media file you just uploaded</returns>
|
1417 | 1457 | public string upload_media(string filePath, Types.upload_File_Types type)
|
1418 | 1458 | {
|
| 1459 | + if(filePath.StartsWith("http")) |
| 1460 | + { |
| 1461 | + byte[] fileBytes = new HttpClient().GetAsync(filePath).Result.Content.ReadAsByteArrayAsync().Result; |
| 1462 | + return upload_media(fileBytes, type); |
| 1463 | + } |
1419 | 1464 | return upload_media(File.ReadAllBytes(filePath), type);
|
1420 | 1465 | }
|
1421 | 1466 |
|
@@ -2421,6 +2466,94 @@ public Task send_sticker(string chatId, string stickerId)
|
2421 | 2466 | return Task.CompletedTask;
|
2422 | 2467 | }
|
2423 | 2468 |
|
| 2469 | + /// <summary> |
| 2470 | + /// Allows you to get information about a blog post |
| 2471 | + /// </summary> |
| 2472 | + /// <param name="blogId"></param> |
| 2473 | + /// <returns></returns> |
| 2474 | + /// <exception cref="Exception"></exception> |
| 2475 | + public Objects.Blog get_blog_info(string blogId) |
| 2476 | + { |
| 2477 | + RestClient client = new RestClient(helpers.BaseUrl); |
| 2478 | + RestRequest request = new RestRequest($"/g/s/blog/{blogId}"); |
| 2479 | + request.AddHeaders(headers); |
| 2480 | + var response = client.ExecuteGet(request); |
| 2481 | + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } |
| 2482 | + if(debug) { Trace.WriteLine(response.Content); } |
| 2483 | + return new Objects.Blog(JObject.Parse(response.Content)); |
| 2484 | + } |
| 2485 | + |
| 2486 | + |
| 2487 | + /// <summary> |
| 2488 | + /// Allows you to get information about a wiki post |
| 2489 | + /// </summary> |
| 2490 | + /// <param name="wikiId"></param> |
| 2491 | + /// <returns></returns> |
| 2492 | + /// <exception cref="Exception"></exception> |
| 2493 | + public Objects.Wiki get_wiki_info(string wikiId) |
| 2494 | + { |
| 2495 | + RestClient client = new RestClient(helpers.BaseUrl); |
| 2496 | + RestRequest request = new RestRequest($"/g/s/item/{wikiId}"); |
| 2497 | + request.AddHeaders(headers); |
| 2498 | + var response = client.ExecuteGet(request); |
| 2499 | + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } |
| 2500 | + if(debug) { Trace.WriteLine(response.Content); } |
| 2501 | + return new Objects.Wiki(JObject.Parse(response.Content)); |
| 2502 | + } |
| 2503 | + |
| 2504 | + /// <summary> |
| 2505 | + /// Allows you to get information about a message in a chat |
| 2506 | + /// </summary> |
| 2507 | + /// <param name="chatId"></param> |
| 2508 | + /// <param name="messageId"></param> |
| 2509 | + /// <returns></returns> |
| 2510 | + /// <exception cref="Exception"></exception> |
| 2511 | + public Objects.Message get_message_info(string chatId, string messageId) |
| 2512 | + { |
| 2513 | + RestClient client = new RestClient(helpers.BaseUrl); |
| 2514 | + RestRequest request = new RestRequest($"/g/s/chat/thread/{chatId}/message/{messageId}"); |
| 2515 | + request.AddHeaders(headers); |
| 2516 | + var response = client.ExecuteGet(request); |
| 2517 | + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } |
| 2518 | + if(debug) { Trace.WriteLine(response.Content); } |
| 2519 | + return new Objects.Message(JObject.Parse(response.Content)); |
| 2520 | + } |
| 2521 | + |
| 2522 | + /// <summary> |
| 2523 | + /// Allows you to get comments from a blog, THIS FUNCTION IS NOT FINISHED |
| 2524 | + /// </summary> |
| 2525 | + /// <param name="blogId"></param> |
| 2526 | + /// <param name="start"></param> |
| 2527 | + /// <param name="size"></param> |
| 2528 | + /// <param name="sorting"></param> |
| 2529 | + /// <returns></returns> |
| 2530 | + /// <exception cref="Exception"></exception> |
| 2531 | + public List<Objects.Comment> get_blog_comments(string blogId, int start = 0, int size = 25, Types.Sorting_Types sorting = Types.Sorting_Types.Newest) |
| 2532 | + { |
| 2533 | + string sortingType = ""; |
| 2534 | + switch(sorting) |
| 2535 | + { |
| 2536 | + case Types.Sorting_Types.Newest: |
| 2537 | + sortingType = "newest"; |
| 2538 | + break; |
| 2539 | + case Types.Sorting_Types.Oldest: |
| 2540 | + sortingType = "oldest"; |
| 2541 | + break; |
| 2542 | + case Types.Sorting_Types.Top: |
| 2543 | + sortingType = "vote"; |
| 2544 | + break; |
| 2545 | + } |
| 2546 | + RestClient client = new RestClient(helpers.BaseUrl); |
| 2547 | + RestRequest request = new RestRequest($"/g/s/blog/{blogId}?sort={sortingType}&start={size}&size={size}"); |
| 2548 | + request.AddHeaders(headers); |
| 2549 | + var response = client.ExecuteGet(request); |
| 2550 | + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } |
| 2551 | + if(debug) { Trace.WriteLine(response.Content); } |
| 2552 | + |
| 2553 | + return null; // FINISH LATER |
| 2554 | + |
| 2555 | + } |
| 2556 | + |
2424 | 2557 |
|
2425 | 2558 | /// <summary>
|
2426 | 2559 | /// Sets the SubClient of the Client, not for development use
|
|
0 commit comments