From 116c61f953cef6de468890c3184846104a587715 Mon Sep 17 00:00:00 2001 From: Shua Date: Tue, 7 Jan 2025 07:10:26 +0800 Subject: [PATCH] =?UTF-8?q?[OneBot]=20=E6=B7=BB=E5=8A=A0=E6=88=B3=E4=B8=80?= =?UTF-8?q?=E6=88=B3=E4=BA=8C=E5=90=88=E4=B8=80=E6=8E=A5=E5=8F=A3=20(#725)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 传入group_id按group_poke处理, 否则按friend_poke处理 Update Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs Co-authored-by: DarkRRb <177549718+DarkRRb@users.noreply.github.com> 忘删了 合并 失败返回-1并对提交签名 --- .../Core/Entity/Action/OneBotSendPoke.cs | 11 +++++++++ .../Operation/Message/SendPokeOperation.cs | 23 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Lagrange.OneBot/Core/Entity/Action/OneBotSendPoke.cs create mode 100644 Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs diff --git a/Lagrange.OneBot/Core/Entity/Action/OneBotSendPoke.cs b/Lagrange.OneBot/Core/Entity/Action/OneBotSendPoke.cs new file mode 100644 index 000000000..f017e1b3e --- /dev/null +++ b/Lagrange.OneBot/Core/Entity/Action/OneBotSendPoke.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace Lagrange.OneBot.Core.Entity.Action; + +[Serializable] +public class OneBotSendPoke +{ + [JsonPropertyName("user_id")] public uint UserId { get; set; } + + [JsonPropertyName("group_id")] public uint? GroupId { get; set; } +} \ No newline at end of file diff --git a/Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs b/Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs new file mode 100644 index 000000000..e6fb9b5ff --- /dev/null +++ b/Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs @@ -0,0 +1,23 @@ +using System.Text.Json; +using System.Text.Json.Nodes; +using Lagrange.Core; +using Lagrange.Core.Common.Interface.Api; +using Lagrange.OneBot.Core.Entity.Action; +using Lagrange.OneBot.Core.Operation.Converters; + +namespace Lagrange.OneBot.Core.Operation.Message; + +[Operation("send_poke")] +public class SendPokeOperation : IOperation +{ + public async Task HandleOperation(BotContext context, JsonNode? payload) + { + if (payload.Deserialize(SerializerOptions.DefaultOptions) is { } poke) + { + bool result = poke.GroupId.HasValue ? await context.GroupPoke(poke.GroupId.Value, poke.UserId) : await context.FriendPoke(poke.UserId); + return new OneBotResult(null, result ? 0 : -1, result ? "ok" : "failed"); + } + + throw new Exception(); + } +} \ No newline at end of file