Skip to content
Closed
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
1 change: 1 addition & 0 deletions Lagrange.Core/Common/Entity/BotGroupNotificationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Lagrange.Core.Common.Entity;
public enum BotGroupNotificationType
{
Join = 1,
InviteSelf = 2,
SetAdmin = 3,
KickOther = 6,
KickSelf = 7,
Expand Down
3 changes: 3 additions & 0 deletions Lagrange.Core/Common/Interface/MessageExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ public static Task GroupRename(this BotContext context, long groupUin, string na

public static Task GroupQuit(this BotContext context, long groupUin)
=> context.EventContext.GetLogic<OperationLogic>().GroupQuit(groupUin);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use SetGroupNotification!

public static Task SetGroupInviteSelfAccept(this BotContext context, long groupUin, long sequence)
=> context.EventContext.GetLogic<OperationLogic>().SetGroupInviteSelfAccept(groupUin, sequence);
}
5 changes: 5 additions & 0 deletions Lagrange.Core/Internal/Logic/OperationLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public async Task GroupMemberRename(long groupUin, long targetUin, string name)
await context.EventContext.SendEvent<GroupMemberRenameEventResp>(new GroupMemberRenameEventReq(groupUin, uid, name));
}

public async Task SetGroupInviteSelfAccept(long groupUin, long sequence)
Copy link
Copy Markdown
Collaborator

@NoirHare NoirHare Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use SetGroupNotification!

{
await context.EventContext.SendEvent<SetGroupNotificationEventReq>(new SetGroupNotificationEventReq(groupUin, (ulong)sequence, BotGroupNotificationType.InviteSelf, GroupNotificationOperate.Allow, String.Empty));
}

public async Task GroupQuit(long groupUin)
{
await context.EventContext.SendEvent<GroupQuitEventResp>(new GroupQuitEventReq(groupUin));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Text.Json.Serialization;
using Lagrange.Core;
using Lagrange.Core.Common.Interface;

namespace Lagrange.Milky.Api.Handler.Request;

[Api("accept_group_invitation")]
public class AcceptGroupInvitationRequestHandler(BotContext bot) : IEmptyResultApiHandler<AcceptGroupInvitationRequestParameter>
{
private readonly BotContext _bot = bot;

public async Task HandleAsync(AcceptGroupInvitationRequestParameter parameter, CancellationToken token)
{
await _bot.SetGroupInviteSelfAccept(parameter.GroupId, parameter.InvitationSeq);
}
}

public class AcceptGroupInvitationRequestParameter(long groupId, long invitationSeq)
{
[JsonRequired]
[JsonPropertyName("group_id")]
public long GroupId { get; } = groupId;

[JsonRequired]
[JsonPropertyName("invitation_seq")]
public long InvitationSeq { get; } = invitationSeq;
}
3 changes: 3 additions & 0 deletions Lagrange.Milky/Utility/JsonUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Lagrange.Milky.Api.Handler.Friend;
using Lagrange.Milky.Api.Handler.Group;
using Lagrange.Milky.Api.Handler.Message;
using Lagrange.Milky.Api.Handler.Request;
using Lagrange.Milky.Api.Handler.System;
using Lagrange.Milky.Api.Result;
using Lagrange.Milky.Entity.Event;
Expand Down Expand Up @@ -83,6 +84,8 @@ public static partial class JsonUtility
[JsonSerializable(typeof(SetGroupMemberSpecialTitleParameter))]
// quit_group
[JsonSerializable(typeof(QuitGroupParameter))]
// accept_group_invitation
[JsonSerializable(typeof(AcceptGroupInvitationRequestParameter))]
// == file ==
// upload_group_file
[JsonSerializable(typeof(UploadGroupFileParameter))]
Expand Down
Loading