diff --git a/Lagrange.OneBot/Core/Entity/Action/OneBotSetGroupReaction.cs b/Lagrange.OneBot/Core/Entity/Action/OneBotSetGroupReaction.cs new file mode 100644 index 000000000..4cdc986e6 --- /dev/null +++ b/Lagrange.OneBot/Core/Entity/Action/OneBotSetGroupReaction.cs @@ -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; } +} \ No newline at end of file diff --git a/Lagrange.OneBot/Core/Operation/Group/SetGroupReactionOperation.cs b/Lagrange.OneBot/Core/Operation/Group/SetGroupReactionOperation.cs new file mode 100644 index 000000000..fe721be09 --- /dev/null +++ b/Lagrange.OneBot/Core/Operation/Group/SetGroupReactionOperation.cs @@ -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 HandleOperation(BotContext context, JsonNode? payload) + { + var message = payload.Deserialize(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(); + } +} \ No newline at end of file