Skip to content
Open
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
3 changes: 3 additions & 0 deletions Lagrange.Core/Common/Interface/MessageExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public static Task RemarkGroup(this BotContext context, long groupUin, string re
public static Task<bool> MuteGroupGlobal(this BotContext context, long groupUin, bool isMute)
=> context.EventContext.GetLogic<OperationLogic>().MuteGroupGlobal(groupUin, isMute);

public static Task<bool> MuteGroupMember(this BotContext context, long groupUin, long targetUin, uint duration)
=> context.EventContext.GetLogic<OperationLogic>().MuteGroupMember(groupUin, targetUin, duration);

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

Expand Down
17 changes: 17 additions & 0 deletions Lagrange.Core/Internal/Events/System/GroupMuteMemberEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Lagrange.Core.Events;

namespace Lagrange.Core.Internal.Events.System;

internal class GroupMuteMemberEventReq(long groupUin, string targetUid, uint duration) : ProtocolEvent
{
public long GroupUin { get; } = groupUin;

public string TargetUid { get; } = targetUid;

public uint Duration { get; } = duration;
}

internal class GroupMuteMemberEventResp : ProtocolEvent
{
public static readonly GroupMuteMemberEventResp Default = new();
}
14 changes: 14 additions & 0 deletions Lagrange.Core/Internal/Logic/OperationLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ public async Task<bool> MuteGroupGlobal(long groupUin, bool isMute)
return true;
}

public async Task<bool> MuteGroupMember(long groupUin, long targetUin, uint duration)
{
if (context.CacheContext.ResolveCachedUid(targetUin) is not { } uid)
{
await context.CacheContext.GetMemberList(groupUin, true);
uid = context.CacheContext.ResolveCachedUid(targetUin);
}

if (uid == null) return false;

await context.EventContext.SendEvent<GroupMuteMemberEventResp>(new GroupMuteMemberEventReq(groupUin, uid, duration));
return true;
}

public async Task<bool> GroupTransfer(long groupUin, long targetUin)
{
await context.EventContext.SendEvent<GroupTransferEventResp>(new GroupTransferEventReq(groupUin, targetUin));
Expand Down
29 changes: 29 additions & 0 deletions Lagrange.Core/Internal/Packets/Service/Oidb_0x1253.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Lagrange.Proto;

namespace Lagrange.Core.Internal.Packets.Service;

#pragma warning disable CS8618

[ProtoPackable]
internal partial class D1253ReqBody
{
[ProtoPackable]
internal partial class MuteInfo
{
[ProtoMember(1)] public string TargetUid { get; set; }

[ProtoMember(2)] public uint Duration { get; set; }
}

[ProtoMember(1)] public long GroupUin { get; set; }

[ProtoMember(2)] public uint Type { get; set; }

[ProtoMember(3)] public MuteInfo Body { get; set; }
}

[ProtoPackable]
internal partial class D1253RspBody
{
[ProtoMember(2)] public string? Success { get; set; }
}
32 changes: 32 additions & 0 deletions Lagrange.Core/Internal/Services/System/GroupMuteMemberService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Lagrange.Core.Common;
using Lagrange.Core.Internal.Events.System;
using Lagrange.Core.Internal.Packets.Service;
using Lagrange.Core.Services;

namespace Lagrange.Core.Internal.Services.System;

[EventSubscribe<GroupMuteMemberEventReq>(Protocols.All)]
[Service("OidbSvcTrpcTcp.0x1253_1")]
internal class GroupMuteMemberService : OidbService<GroupMuteMemberEventReq, GroupMuteMemberEventResp, D1253ReqBody, D1253RspBody>
{
protected override uint Command => 0x1253;

protected override uint Service => 1;

protected override Task<D1253ReqBody> ProcessRequest(GroupMuteMemberEventReq request, BotContext context)
{
return Task.FromResult(new D1253ReqBody
{
GroupUin = request.GroupUin,
Type = 1,
Body = new D1253ReqBody.MuteInfo
{
TargetUid = request.TargetUid,
Duration = request.Duration
}
});
}

protected override Task<GroupMuteMemberEventResp> ProcessResponse(D1253RspBody response, BotContext context) =>
Task.FromResult(GroupMuteMemberEventResp.Default);
}