Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OneBot] Implemented SetGroupReactionOperation #318

Merged
1 commit merged into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}