Skip to content

Commit

Permalink
[OneBot] 添加戳一戳二合一接口 (#725)
Browse files Browse the repository at this point in the history
传入group_id按group_poke处理,
否则按friend_poke处理

Update Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs

Co-authored-by: DarkRRb <[email protected]>

忘删了

合并

失败返回-1并对提交签名
  • Loading branch information
Shua-github authored Jan 6, 2025
1 parent 17b66f7 commit 116c61f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Lagrange.OneBot/Core/Entity/Action/OneBotSendPoke.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
23 changes: 23 additions & 0 deletions Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs
Original file line number Diff line number Diff line change
@@ -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<OneBotResult> HandleOperation(BotContext context, JsonNode? payload)
{
if (payload.Deserialize<OneBotSendPoke>(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();
}
}

0 comments on commit 116c61f

Please sign in to comment.