-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
传入group_id按group_poke处理, 否则按friend_poke处理 Update Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs Co-authored-by: DarkRRb <[email protected]> 忘删了 合并 失败返回-1并对提交签名
- Loading branch information
1 parent
17b66f7
commit 116c61f
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
Lagrange.OneBot/Core/Operation/Message/SendPokeOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |