Skip to content

Commit

Permalink
[OneBot] Implemented SetGroupReactionOperation (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
CrackTC authored Apr 16, 2024
1 parent fdb1ca8 commit 0795d62
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Lagrange.OneBot/Core/Entity/Action/OneBotSetGroupReaction.cs
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 Lagrange.OneBot/Core/Operation/Group/SetGroupReactionOperation.cs
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();
}
}

0 comments on commit 0795d62

Please sign in to comment.