Skip to content

Commit 992be7c

Browse files
committed
[Core] Implemented Group related events&services
1 parent feef0d3 commit 992be7c

15 files changed

Lines changed: 644 additions & 0 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Lagrange.Core.Common.Entity;
2+
3+
public class BotStrangerGroupInfo
4+
{
5+
public ulong CreateTime { get; set; }
6+
7+
public ulong MaxMemberCount { get; set; }
8+
9+
public ulong MemberCount { get; set; }
10+
11+
public string Name { get; set; } = string.Empty;
12+
13+
public ulong Uin { get; set; }
14+
}

Lagrange.Core/Common/Interface/MessageExt.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ public static Task<bool> KickGroupMember(this BotContext context, long groupUin,
9393
public static Task GroupRename(this BotContext context, long groupUin, string name)
9494
=> context.EventContext.GetLogic<OperationLogic>().GroupRename(groupUin, name);
9595

96+
public static Task<bool> MuteGroupGlobal(this BotContext context, long groupUin, bool isMute)
97+
=> context.EventContext.GetLogic<OperationLogic>().MuteGroupGlobal(groupUin, isMute);
98+
99+
public static Task<bool> GroupTransfer(this BotContext context, long groupUin, long targetUin)
100+
=> context.EventContext.GetLogic<OperationLogic>().GroupTransfer(groupUin, targetUin);
101+
102+
public static Task<(uint RemainAtAllCountForUin, uint RemainAtAllCountForGroup)> GroupRemainAtAll(this BotContext context, long groupUin)
103+
=> context.EventContext.GetLogic<OperationLogic>().GroupRemainAtAll(groupUin);
104+
96105
public static Task GroupQuit(this BotContext context, long groupUin)
97106
=> context.EventContext.GetLogic<OperationLogic>().GroupQuit(groupUin);
98107
}

Lagrange.Core/Common/Interface/OperationExt.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public static Task<List<BotGroup>> FetchGroups(this BotContext context, bool ref
3333
public static Task<BotGroupExtra> FetchGroupExtra(this BotContext context, long groupUin) =>
3434
context.EventContext.GetLogic<OperationLogic>().FetchGroupExtra(groupUin);
3535

36+
public static Task<BotStrangerGroupInfo> FetchStrangerGroupInfo(this BotContext context, ulong groupUin) =>
37+
context.EventContext.GetLogic<OperationLogic>().FetchStrangerGroupInfo(groupUin);
38+
3639
public static Task<List<BotGroupMember>> FetchMembers(this BotContext context, long groupUin, bool refresh = false) =>
3740
context.CacheContext.GetMemberList(groupUin, refresh);
3841

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Lagrange.Core.Events;
2+
3+
namespace Lagrange.Core.Internal.Events.System;
4+
5+
internal class FetchGroupAtAllRemainEventReq(long groupUin) : ProtocolEvent
6+
{
7+
public long GroupUin { get; } = groupUin;
8+
}
9+
10+
internal class FetchGroupAtAllRemainEventResp(bool canAtAll, uint remainAtAllCountForUin, uint remainAtAllCountForGroup) : ProtocolEvent
11+
{
12+
public bool CanAtAll { get; } = canAtAll;
13+
14+
public uint RemainAtAllCountForUin { get; } = remainAtAllCountForUin;
15+
16+
public uint RemainAtAllCountForGroup { get; } = remainAtAllCountForGroup;
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Lagrange.Core.Common.Entity;
2+
using Lagrange.Core.Events;
3+
4+
namespace Lagrange.Core.Internal.Events.System;
5+
6+
internal class FetchStrangerGroupInfoEventReq(ulong groupUin) : ProtocolEvent
7+
{
8+
public ulong GroupUin { get; } = groupUin;
9+
}
10+
11+
internal class FetchStrangerGroupInfoEventResp(BotStrangerGroupInfo info) : ProtocolEvent
12+
{
13+
public BotStrangerGroupInfo Info { get; } = info;
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Lagrange.Core.Events;
2+
3+
namespace Lagrange.Core.Internal.Events.System;
4+
5+
internal class GroupMuteGlobalEventReq(long groupUin, bool isMute) : ProtocolEvent
6+
{
7+
public long GroupUin { get; } = groupUin;
8+
9+
public bool IsMute { get; } = isMute;
10+
}
11+
12+
internal class GroupMuteGlobalEventResp : ProtocolEvent
13+
{
14+
public static readonly GroupMuteGlobalEventResp Default = new();
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Lagrange.Core.Events;
2+
3+
namespace Lagrange.Core.Internal.Events.System;
4+
5+
internal class GroupTransferEventReq(long groupUin, long targetUin) : ProtocolEvent
6+
{
7+
public long GroupUin { get; } = groupUin;
8+
9+
public long TargetUin { get; } = targetUin;
10+
}
11+
12+
internal class GroupTransferEventResp : ProtocolEvent
13+
{
14+
public static readonly GroupTransferEventResp Default = new();
15+
}

Lagrange.Core/Internal/Logic/OperationLogic.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ public async Task GroupRename(long groupUin, string name)
6161
await context.EventContext.SendEvent<GroupRenameEventResp>(new GroupRenameEventReq(groupUin, name));
6262
}
6363

64+
public async Task<bool> MuteGroupGlobal(long groupUin, bool isMute)
65+
{
66+
await context.EventContext.SendEvent<GroupMuteGlobalEventResp>(new GroupMuteGlobalEventReq(groupUin, isMute));
67+
return true;
68+
}
69+
70+
public async Task<bool> GroupTransfer(long groupUin, long targetUin)
71+
{
72+
await context.EventContext.SendEvent<GroupTransferEventResp>(new GroupTransferEventReq(groupUin, targetUin));
73+
return true;
74+
}
75+
76+
public async Task<(uint RemainAtAllCountForUin, uint RemainAtAllCountForGroup)> GroupRemainAtAll(long groupUin)
77+
{
78+
var response = await context.EventContext.SendEvent<FetchGroupAtAllRemainEventResp>(new FetchGroupAtAllRemainEventReq(groupUin));
79+
return (response.RemainAtAllCountForUin, response.RemainAtAllCountForGroup);
80+
}
81+
6482
public async Task GroupSetSpecialTitle(long groupUin, long targetUin, string title)
6583
{
6684
if (context.CacheContext.ResolveCachedUid(targetUin) is not { } uid)
@@ -354,6 +372,12 @@ public async Task<BotGroupExtra> FetchGroupExtra(long groupUin)
354372
return resp.Extra;
355373
}
356374

375+
public async Task<BotStrangerGroupInfo> FetchStrangerGroupInfo(ulong groupUin)
376+
{
377+
var response = await context.EventContext.SendEvent<FetchStrangerGroupInfoEventResp>(new FetchStrangerGroupInfoEventReq(groupUin));
378+
return response.Info;
379+
}
380+
357381
public async Task<List<BotGroupNotificationBase>> FetchGroupNotifications(ulong count, ulong start)
358382
{
359383
var req = new FetchGroupNotificationsEventReq(count, start);

0 commit comments

Comments
 (0)