Skip to content

Commit 8af6988

Browse files
committed
[Core] Implemented PokeRecall and GroupRemark
1 parent 992be7c commit 8af6988

9 files changed

Lines changed: 234 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
@@ -93,6 +93,9 @@ 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 RemarkGroup(this BotContext context, long groupUin, string remark)
97+
=> context.EventContext.GetLogic<OperationLogic>().RemarkGroup(groupUin, remark);
98+
9699
public static Task<bool> MuteGroupGlobal(this BotContext context, long groupUin, bool isMute)
97100
=> context.EventContext.GetLogic<OperationLogic>().MuteGroupGlobal(groupUin, isMute);
98101

Lagrange.Core/Common/Interface/OperationExt.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public static Task<bool> SetStatus(this BotContext context, uint status) =>
2424
public static Task<bool> SetCustomStatus(this BotContext context, uint faceId, string text) =>
2525
context.EventContext.GetLogic<OperationLogic>().SetCustomStatus(faceId, text);
2626

27+
public static Task GroupRecallPoke(this BotContext context, ulong groupUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) =>
28+
context.EventContext.GetLogic<OperationLogic>().GroupRecallPoke(groupUin, messageSequence, messageTime, tipsSeqId);
29+
30+
public static Task FriendRecallPoke(this BotContext context, ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) =>
31+
context.EventContext.GetLogic<OperationLogic>().FriendRecallPoke(peerUin, messageSequence, messageTime, tipsSeqId);
32+
2733
public static Task<List<BotFriend>> FetchFriends(this BotContext context, bool refresh = false) =>
2834
context.CacheContext.GetFriendList(refresh);
2935

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Lagrange.Core.Events;
2+
3+
namespace Lagrange.Core.Internal.Events.Message;
4+
5+
internal class RecallPokeEventReq(bool isGroup, ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) : ProtocolEvent
6+
{
7+
public bool IsGroup { get; } = isGroup;
8+
9+
public ulong PeerUin { get; } = peerUin;
10+
11+
public ulong MessageSequence { get; } = messageSequence;
12+
13+
public ulong MessageTime { get; } = messageTime;
14+
15+
public ulong TipsSeqId { get; } = tipsSeqId;
16+
}
17+
18+
internal class RecallPokeEventResp : ProtocolEvent;
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 GroupRemarkEventReq(long groupUin, string targetRemark) : ProtocolEvent
6+
{
7+
public long GroupUin { get; } = groupUin;
8+
9+
public string TargetRemark { get; } = targetRemark;
10+
}
11+
12+
internal class GroupRemarkEventResp : ProtocolEvent
13+
{
14+
public static readonly GroupRemarkEventResp Default = new();
15+
}

Lagrange.Core/Internal/Logic/OperationLogic.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public async Task<bool> SendNudge(bool isGroup, long peerUin, long targetUin)
4242
return true;
4343
}
4444

45+
public Task GroupRecallPoke(ulong groupUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) =>
46+
RecallPoke(true, groupUin, messageSequence, messageTime, tipsSeqId);
47+
48+
public Task FriendRecallPoke(ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) =>
49+
RecallPoke(false, peerUin, messageSequence, messageTime, tipsSeqId);
50+
51+
private async Task RecallPoke(bool isGroup, ulong peerUin, ulong messageSequence, ulong messageTime, ulong tipsSeqId) =>
52+
await context.EventContext.SendEvent<RecallPokeEventResp>(new RecallPokeEventReq(isGroup, peerUin, messageSequence, messageTime, tipsSeqId));
53+
4554
public async Task<bool> SetStatus(uint status)
4655
{
4756
if (status > int.MaxValue) throw new ArgumentOutOfRangeException(nameof(status));
@@ -61,6 +70,11 @@ public async Task GroupRename(long groupUin, string name)
6170
await context.EventContext.SendEvent<GroupRenameEventResp>(new GroupRenameEventReq(groupUin, name));
6271
}
6372

73+
public async Task RemarkGroup(long groupUin, string remark)
74+
{
75+
await context.EventContext.SendEvent<GroupRemarkEventResp>(new GroupRemarkEventReq(groupUin, remark));
76+
}
77+
6478
public async Task<bool> MuteGroupGlobal(long groupUin, bool isMute)
6579
{
6680
await context.EventContext.SendEvent<GroupMuteGlobalEventResp>(new GroupMuteGlobalEventReq(groupUin, isMute));
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 DF16ReqBody
9+
{
10+
[ProtoMember(1)] public F16GroupRemarkInfoReq RemarkInfo { get; set; }
11+
}
12+
13+
[ProtoPackable]
14+
internal partial class F16GroupRemarkInfoReq
15+
{
16+
[ProtoMember(1)] public ulong GroupCode { get; set; }
17+
18+
[ProtoMember(2)] public ulong? GroupUin { get; set; }
19+
20+
[ProtoMember(3)] public byte[] RemarkName { get; set; }
21+
}
22+
23+
[ProtoPackable]
24+
internal partial class DF16RspBody
25+
{
26+
[ProtoMember(1)] public F16GroupRemarkInfoRsp? RemarkInfo { get; set; }
27+
}
28+
29+
[ProtoPackable]
30+
internal partial class F16GroupRemarkInfoRsp
31+
{
32+
[ProtoMember(1)] public ulong GroupCode { get; set; }
33+
34+
[ProtoMember(2)] public ulong GroupUin { get; set; }
35+
36+
[ProtoMember(3)] public int Result { get; set; }
37+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 DF51ReqBody
9+
{
10+
[ProtoMember(1)] public F51C2CMsgInfo? C2CMsgInfo { get; set; }
11+
12+
[ProtoMember(2)] public F51GroupMsgInfo? GroupMsgInfo { get; set; }
13+
14+
[ProtoMember(3)] public F51CommGrayTipsInfo CommGrayTipsInfo { get; set; }
15+
}
16+
17+
[ProtoPackable]
18+
internal partial class F51C2CMsgInfo
19+
{
20+
[ProtoMember(1)] public ulong AioUin { get; set; }
21+
22+
[ProtoMember(2)] public ulong MsgType { get; set; }
23+
24+
[ProtoMember(3)] public ulong MsgSeq { get; set; }
25+
26+
[ProtoMember(4)] public ulong MsgTime { get; set; }
27+
28+
[ProtoMember(5)] public ulong MsgUid { get; set; }
29+
}
30+
31+
[ProtoPackable]
32+
internal partial class F51GroupMsgInfo
33+
{
34+
[ProtoMember(1)] public ulong GroupCode { get; set; }
35+
36+
[ProtoMember(2)] public ulong MsgType { get; set; }
37+
38+
[ProtoMember(3)] public ulong MsgSeq { get; set; }
39+
40+
[ProtoMember(4)] public ulong MsgTime { get; set; }
41+
42+
[ProtoMember(5)] public ulong MsgUid { get; set; }
43+
44+
[ProtoMember(6)] public ulong MsgId { get; set; }
45+
}
46+
47+
[ProtoPackable]
48+
internal partial class F51CommGrayTipsInfo
49+
{
50+
[ProtoMember(1)] public ulong BusiId { get; set; }
51+
52+
[ProtoMember(2)] public ulong TipsSeqId { get; set; }
53+
}
54+
55+
[ProtoPackable]
56+
internal partial class DF51RspBody;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using Lagrange.Core.Common;
2+
using Lagrange.Core.Internal.Events.Message;
3+
using Lagrange.Core.Internal.Packets.Service;
4+
using Lagrange.Core.Services;
5+
6+
namespace Lagrange.Core.Internal.Services.Message;
7+
8+
[EventSubscribe<RecallPokeEventReq>(Protocols.All)]
9+
[Service("OidbSvcTrpcTcp.0xf51_1")]
10+
internal class RecallPokeService : OidbService<RecallPokeEventReq, RecallPokeEventResp, DF51ReqBody, DF51RspBody>
11+
{
12+
protected override uint Command => 0xf51;
13+
14+
protected override uint Service => 1;
15+
16+
protected override Task<DF51ReqBody> ProcessRequest(RecallPokeEventReq request, BotContext context)
17+
{
18+
ulong messageUid = request.IsGroup
19+
? (ulong)Random.Shared.NextInt64(7_580_000_000_000_000_000, 7_580_099_999_999_999_999)
20+
: (ulong)Random.Shared.NextInt64(7_500_000_000_000_000_000, 7_509_999_999_999_999_999);
21+
22+
return Task.FromResult(new DF51ReqBody
23+
{
24+
C2CMsgInfo = request.IsGroup ? null : new F51C2CMsgInfo
25+
{
26+
AioUin = request.PeerUin,
27+
MsgType = 5,
28+
MsgSeq = request.MessageSequence,
29+
MsgTime = request.MessageTime,
30+
MsgUid = messageUid
31+
},
32+
GroupMsgInfo = request.IsGroup ? new F51GroupMsgInfo
33+
{
34+
GroupCode = request.PeerUin,
35+
MsgType = 5,
36+
MsgSeq = request.MessageSequence,
37+
MsgTime = request.MessageTime,
38+
MsgUid = messageUid,
39+
MsgId = messageUid
40+
} : null,
41+
CommGrayTipsInfo = new F51CommGrayTipsInfo
42+
{
43+
BusiId = 1061,
44+
TipsSeqId = request.TipsSeqId
45+
}
46+
});
47+
}
48+
49+
protected override Task<RecallPokeEventResp> ProcessResponse(DF51RspBody response, BotContext context) =>
50+
Task.FromResult(new RecallPokeEventResp());
51+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Text;
2+
using Lagrange.Core.Common;
3+
using Lagrange.Core.Exceptions;
4+
using Lagrange.Core.Internal.Events.System;
5+
using Lagrange.Core.Internal.Packets.Service;
6+
using Lagrange.Core.Services;
7+
8+
namespace Lagrange.Core.Internal.Services.System;
9+
10+
[EventSubscribe<GroupRemarkEventReq>(Protocols.All)]
11+
[Service("OidbSvcTrpcTcp.0xf16_1")]
12+
internal class GroupRemarkService : OidbService<GroupRemarkEventReq, GroupRemarkEventResp, DF16ReqBody, DF16RspBody>
13+
{
14+
protected override uint Command => 0xf16;
15+
16+
protected override uint Service => 1;
17+
18+
protected override Task<DF16ReqBody> ProcessRequest(GroupRemarkEventReq request, BotContext context)
19+
{
20+
return Task.FromResult(new DF16ReqBody
21+
{
22+
RemarkInfo = new F16GroupRemarkInfoReq
23+
{
24+
GroupCode = (ulong)request.GroupUin,
25+
RemarkName = Encoding.UTF8.GetBytes(request.TargetRemark)
26+
}
27+
});
28+
}
29+
30+
protected override Task<GroupRemarkEventResp> ProcessResponse(DF16RspBody response, BotContext context)
31+
{
32+
return Task.FromResult(GroupRemarkEventResp.Default);
33+
}
34+
}

0 commit comments

Comments
 (0)