From 769aa1344cd4f0e22f83b3e9fe1b7f7cbd8ad183 Mon Sep 17 00:00:00 2001 From: ruruke <123709459+Ruruke@users.noreply.github.com> Date: Fri, 10 May 2024 09:32:58 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20:=20Add=20new=20function=20/=20Note?= =?UTF-8?q?=E3=82=92=E9=80=81=E4=BF=A1=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MisskeyDotNet/WebAPI/MiWebAPI.cs | 38 +++++++++++++++++++++++ MisskeyDotNet/WebAPI/Object/MiSendNote.cs | 31 ++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 MisskeyDotNet/WebAPI/MiWebAPI.cs create mode 100644 MisskeyDotNet/WebAPI/Object/MiSendNote.cs diff --git a/MisskeyDotNet/WebAPI/MiWebAPI.cs b/MisskeyDotNet/WebAPI/MiWebAPI.cs new file mode 100644 index 0000000..7a1c058 --- /dev/null +++ b/MisskeyDotNet/WebAPI/MiWebAPI.cs @@ -0,0 +1,38 @@ +using System.Text; +using System.Text.Json; +using MisskeyDotNet.Object; + +namespace MisskeyDotNet.WebAPI; + +public class MiWebAPI +{ + HttpClient client = new(); + string _url = "https://misskey.io/api"; + string _token = ""; + + public MiWebAPI(String token, String baseURL = "misskey.io") + { + _token = token; + _url = $"https://{baseURL}/api"; + } + + public async Task Note(String token, MiSendNote miSendNote) + { + + miSendNote.i = token; + var json_in = JsonSerializer.Serialize(miSendNote); + Console.WriteLine(json_in); + + var content = new StringContent(json_in, Encoding.UTF8, @"application/json"); + + Console.WriteLine("API Call..."); + + var responce = await client.PostAsync(_url + "/notes/create", content); + + Console.WriteLine(responce.StatusCode); + + var responce_text = await responce.Content.ReadAsStringAsync(); + Console.WriteLine(responce_text); + return responce_text; + } +} \ No newline at end of file diff --git a/MisskeyDotNet/WebAPI/Object/MiSendNote.cs b/MisskeyDotNet/WebAPI/Object/MiSendNote.cs new file mode 100644 index 0000000..070747f --- /dev/null +++ b/MisskeyDotNet/WebAPI/Object/MiSendNote.cs @@ -0,0 +1,31 @@ +using System.Text.Json.Serialization; + +namespace MisskeyDotNet.WebAPI; + +public class MiSendNote +{ + public string i { get; set;} + public string visibility { get; set; } = "public"; + public List visibleUserIds { get; set; } = new(); + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string cw { get; set; } = null; + public bool localOnly { get; set; } = false; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public object reactionAcceptance { get; set; } = null; + public bool noExtractMentions { get; set; } = false; + public bool noExtractHashtags { get; set; } = false; + public bool noExtractEmojis { get; set; } = false; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string replyId { get; set; } = null; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public object renoteId { get; set; } = null; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string channelId { get; set; } = null!; + public string text { get; set; } = ""; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public object fileIds { get; set; } = null; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public object mediaIds { get; set; } = null; + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public object poll { get; set; } = null; +} \ No newline at end of file