[OneBot] Implemented set_group_leave API

This commit is contained in:
Linwenxuan 2023-10-16 21:53:08 +08:00
parent 55560cbd2d
commit af6fc2586e
3 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace Lagrange.OneBot.Core.Entity.Action;
[Serializable]
public class OneBotSetGroupLeave
{
[JsonPropertyName("group_id")] public uint GroupId { get; set; }
[JsonPropertyName("is_dismiss")] public bool IsDismiss { get; set; }
}

View File

@ -0,0 +1,24 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using Lagrange.Core;
using Lagrange.Core.Common.Interface.Api;
using Lagrange.OneBot.Core.Entity.Action;
namespace Lagrange.OneBot.Core.Operation.Group;
[Operation("set_group_leave")]
public class SetGroupLeaveOperation : IOperation
{
public async Task<OneBotResult> HandleOperation(string echo, BotContext context, JsonObject? payload)
{
var message = payload.Deserialize<OneBotSetGroupLeave>();
if (message != null)
{
bool _ = await context.LeaveGroup(message.GroupId); // TODO: Figure out is_dismiss
return new OneBotResult(null, 0, "ok", echo);
}
throw new Exception();
}
}

View File

@ -116,7 +116,7 @@ Please use Lagrange.Core responsibly and in accordance with the law.
| [/set_group_anonymous] | 🔴 |
| [/set_group_card] | 🟢 |
| [/set_group_name] | 🟢 |
| [/set_group_leave] | 🔴 |
| [/set_group_leave] | 🟢 |
| [/set_group_special_title] | 🔴 |
| [/set_friend_add_request] | 🔴 |
| [/set_group_add_request] | 🔴 |