Skip to content
This repository was archived by the owner on May 27, 2026. It is now read-only.

Commit 4e47665

Browse files
authored
[Core & Milky] Implement quit_group (LagrangeDev#16)
1 parent 3e04e8c commit 4e47665

7 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lagrange.Core/Common/Interface/MessageExt.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,7 @@ public static Task GroupMemberRename(this BotContext context, long groupUin, lon
5555

5656
public static Task GroupRename(this BotContext context, long groupUin, string name)
5757
=> context.EventContext.GetLogic<OperationLogic>().GroupRename(groupUin, name);
58+
59+
public static Task GroupQuit(this BotContext context, long groupUin)
60+
=> context.EventContext.GetLogic<OperationLogic>().GroupQuit(groupUin);
5861
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Lagrange.Core.Internal.Events.System;
2+
3+
internal class GroupQuitEventReq(long groupUin) : ProtocolEvent
4+
{
5+
public long GroupUin { get; } = groupUin;
6+
}
7+
8+
internal class GroupQuitEventResp : ProtocolEvent
9+
{
10+
public static readonly GroupQuitEventResp Default = new();
11+
}

Lagrange.Core/Internal/Logic/OperationLogic.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public async Task GroupMemberRename(long groupUin, long targetUin, string name)
5252
}
5353
await context.EventContext.SendEvent<GroupMemberRenameEventResp>(new GroupMemberRenameEventReq(groupUin, uid, name));
5454
}
55+
56+
public async Task GroupQuit(long groupUin)
57+
{
58+
await context.EventContext.SendEvent<GroupQuitEventResp>(new GroupQuitEventReq(groupUin));
59+
}
5560

5661
public async Task<string> GroupFSDownload(long groupUin, string fileId)
5762
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Lagrange.Proto;
2+
3+
namespace Lagrange.Core.Internal.Packets.Service;
4+
5+
#pragma warning disable CS8618
6+
7+
[ProtoPackable]
8+
internal partial class D1097ReqBody
9+
{
10+
[ProtoMember(1)] public long GroupCode { get; set; }
11+
}
12+
13+
[ProtoPackable]
14+
internal partial class D1097RspBody;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Lagrange.Core.Common;
2+
using Lagrange.Core.Internal.Events;
3+
using Lagrange.Core.Internal.Events.System;
4+
using Lagrange.Core.Internal.Packets.Service;
5+
6+
namespace Lagrange.Core.Internal.Services.System;
7+
8+
[EventSubscribe<GroupQuitEventReq>(Protocols.All)]
9+
[Service("OidbSvcTrpcTcp.0x1097_1")]
10+
internal class GroupQuitService: OidbService<GroupQuitEventReq, GroupQuitEventResp, D1097ReqBody, D1097RspBody>
11+
{
12+
private protected override uint Command => 0x1097;
13+
14+
private protected override uint Service => 1;
15+
16+
private protected override Task<D1097ReqBody> ProcessRequest(GroupQuitEventReq request, BotContext context)
17+
{
18+
return Task.FromResult(new D1097ReqBody
19+
{
20+
GroupCode = request.GroupUin
21+
});
22+
}
23+
24+
private protected override Task<GroupQuitEventResp> ProcessResponse(D1097RspBody response, BotContext context)
25+
{
26+
return Task.FromResult(GroupQuitEventResp.Default);
27+
}
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Text.Json.Serialization;
2+
using Lagrange.Core;
3+
using Lagrange.Core.Common.Interface;
4+
5+
namespace Lagrange.Milky.Api.Handler.Group;
6+
7+
[Api("quit_group")]
8+
public class QuitGroupHandler(BotContext bot) : IEmptyResultApiHandler<QuitGroupParameter>
9+
{
10+
private readonly BotContext _bot = bot;
11+
12+
public async Task HandleAsync(QuitGroupParameter parameter, CancellationToken token)
13+
{
14+
await _bot.GroupQuit(parameter.GroupId);
15+
}
16+
}
17+
18+
public class QuitGroupParameter(long groupId)
19+
{
20+
[JsonRequired]
21+
[JsonPropertyName("group_id")]
22+
public long GroupId { get; init; } = groupId;
23+
}

Lagrange.Milky/Utility/JsonUtility.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public static partial class JsonUtility
8181
[JsonSerializable(typeof(SetGroupMemberCardParameter))]
8282
// set_group_member_special_title
8383
[JsonSerializable(typeof(SetGroupMemberSpecialTitleParameter))]
84+
// quit_group
85+
[JsonSerializable(typeof(QuitGroupParameter))]
8486
// == file ==
8587
// upload_group_file
8688
[JsonSerializable(typeof(UploadGroupFileParameter))]

0 commit comments

Comments
 (0)