From c94c09307f6e19c95fe7581828d50e82cd66a1a3 Mon Sep 17 00:00:00 2001 From: Linwenxuan <116782992+Linwenxuan05@users.noreply.github.com> Date: Fri, 26 Jan 2024 18:55:48 +0800 Subject: [PATCH] [OneBot] get_cookies Implemented --- .../Operation/Generic/GetCookiesOperation.cs | 21 +++++++++++++++++++ README.md | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Lagrange.OneBot/Core/Operation/Generic/GetCookiesOperation.cs diff --git a/Lagrange.OneBot/Core/Operation/Generic/GetCookiesOperation.cs b/Lagrange.OneBot/Core/Operation/Generic/GetCookiesOperation.cs new file mode 100644 index 000000000..341e35b17 --- /dev/null +++ b/Lagrange.OneBot/Core/Operation/Generic/GetCookiesOperation.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Nodes; +using Lagrange.Core; +using Lagrange.Core.Common.Interface.Api; +using Lagrange.OneBot.Core.Entity.Action; + +namespace Lagrange.OneBot.Core.Operation.Generic; + +[Operation("get_cookies")] +public class GetCookiesOperation : IOperation +{ + public async Task HandleOperation(BotContext context, JsonObject? payload) + { + if (payload?["domain"]?.ToString() is { } domain) + { + var cookies = await context.FetchCookies([domain]); + return new OneBotResult(new JsonObject { { "cookies", cookies[0] } }, 200, "ok"); + } + + throw new Exception(); + } +} \ No newline at end of file diff --git a/README.md b/README.md index ce43f5577..f5d5bf299 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Please use Lagrange.Core responsibly and in accordance with the law. | [/get_group_member_info] | 🟢 | | [/get_group_member_list] | 🟢 | | [/get_group_honor_info] | 🔴 | -| [/get_cookies] | 🔴 | +| [/get_cookies] | 🟢 | | [/get_csrf_token] | 🔴 | | [/get_credentials] | 🔴 | | [/get_record] | 🔴 |