-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OneBot] Implemented SetGroupReactionOperation (#318)
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
Lagrange.OneBot/Core/Entity/Action/OneBotSetGroupReaction.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,13 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Lagrange.OneBot.Core.Entity.Action; | ||
|
||
[Serializable] | ||
public class OneBotSetGroupReaction | ||
{ | ||
[JsonPropertyName("group_id")] public uint GroupId { get; set; } | ||
|
||
[JsonPropertyName("message_id")] public uint MessageId { get; set; } | ||
|
||
[JsonPropertyName("code")] public required string Code { get; set; } | ||
} |
25 changes: 25 additions & 0 deletions
25
Lagrange.OneBot/Core/Operation/Group/SetGroupReactionOperation.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,25 @@ | ||
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.Group; | ||
|
||
[Operation("set_group_reaction")] | ||
public class SetGroupReactionOperation : IOperation | ||
{ | ||
public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload) | ||
{ | ||
var message = payload.Deserialize<OneBotSetGroupReaction>(SerializerOptions.DefaultOptions); | ||
|
||
if (message != null) | ||
{ | ||
bool result = await context.GroupSetMessageReaction(message.GroupId, message.MessageId, message.Code); | ||
return new OneBotResult(null, result ? 0 : 1, result ? "ok" : "failed"); | ||
} | ||
|
||
throw new Exception(); | ||
} | ||
} |