Skip to content

Commit 082d3cb

Browse files
authored
[Core] Impl 0x88D_0 (#712)
* [Core] impl 0x88D_0 * Clean up `using`
1 parent ec3f51e commit 082d3cb

File tree

18 files changed

+296
-33
lines changed

18 files changed

+296
-33
lines changed

Lagrange.Core.Test/Tests/NTLoginTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Lagrange.Core.Common.Interface;
33
using Lagrange.Core.Common.Interface.Api;
44
using Lagrange.Core.Internal.Event.System;
5-
using Lagrange.Core.Message;
65

76
namespace Lagrange.Core.Test.Tests;
87

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Lagrange.Core.Common.Entity;
2+
3+
public class BotGroupInfo
4+
{
5+
public string OwnerUid { get; set; } = string.Empty;
6+
7+
public ulong CreateTime { get; set; }
8+
9+
public ulong MaxMemberCount { get; set; }
10+
11+
public ulong MemberCount { get; set; }
12+
13+
public ulong Level { get; set; }
14+
15+
public string Name { get; set; } = string.Empty;
16+
17+
public string NoticePreview { get; set; } = string.Empty;
18+
19+
public ulong Uin { get; set; }
20+
21+
public ulong LastSequence { get; set; }
22+
23+
public ulong LastMessageTime { get; set; }
24+
25+
public string Question { get; set; } = string.Empty;
26+
27+
public string Answer { get; set; } = string.Empty;
28+
29+
public ulong MaxAdminCount { get; set; }
30+
}

Lagrange.Core/Common/Interface/Api/OperationExt.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ public static Task<bool> SetCustomStatus(this BotContext bot, uint faceId, strin
137137
public static Task<bool> GroupTransfer(this BotContext bot, uint groupUin, uint targetUin)
138138
=> bot.ContextCollection.Business.OperationLogic.GroupTransfer(groupUin, targetUin);
139139

140-
public static Task<bool> DeleteFriend (this BotContext bot, uint friendUin, bool block)
141-
=>bot.ContextCollection.Business.OperationLogic.DeleteFriend(friendUin, block);
140+
public static Task<bool> DeleteFriend(this BotContext bot, uint friendUin, bool block)
141+
=> bot.ContextCollection.Business.OperationLogic.DeleteFriend(friendUin, block);
142142

143143
public static Task<bool> RequestFriend(this BotContext bot, uint targetUin, string question = "", string message = "")
144144
=> bot.ContextCollection.Business.OperationLogic.RequestFriend(targetUin, question, message);
@@ -206,6 +206,9 @@ public static Task<BotGroupClockInResult> GroupClockIn(this BotContext bot, uint
206206
public static Task<BotUserInfo?> FetchUserInfo(this BotContext bot, uint uin, bool refreshCache = false)
207207
=> bot.ContextCollection.Business.OperationLogic.FetchUserInfo(uin, refreshCache);
208208

209+
public static Task<(int code, string? message, BotGroupInfo info)> FetchGroupInfo(this BotContext bot, ulong uin)
210+
=> bot.ContextCollection.Business.OperationLogic.FetchGroupInfo(uin);
211+
209212
public static Task<List<string>?> FetchCustomFace(this BotContext bot)
210213
=> bot.ContextCollection.Business.OperationLogic.FetchCustomFace();
211214

@@ -293,7 +296,7 @@ public static Task<string> UploadImage(this BotContext bot, ImageEntity entity)
293296

294297
public static Task<(int Retcode, string Message)> SetPinGroup(this BotContext bot, uint uin, bool isPin)
295298
=> bot.ContextCollection.Business.OperationLogic.SetPinGroup(uin, isPin);
296-
299+
297300
public static Task<string> FetchPrivateFSDownload(this BotContext bot, string fileId, string fileHash, uint userId)
298301
=> bot.ContextCollection.Business.OperationLogic.FetchPrivateFSDownload(fileId, fileHash, userId);
299302
}

Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public async Task<string> FetchGroupFSDownload(uint groupUin, string fileId)
222222
var events = await Collection.Business.SendEvent(groupFSDownloadEvent);
223223
return $"{((GroupFSDownloadEvent)events[0]).FileUrl}{fileId}";
224224
}
225-
225+
226226
public async Task<string> FetchPrivateFSDownload(string fileId, string fileHash, uint userId)
227227
{
228228
var uid = await Collection.Business.CachingLogic.ResolveUid(null, userId);
@@ -620,6 +620,14 @@ public async Task<bool> GroupSetSpecialTitle(uint groupUin, uint targetUin, stri
620620
return await Collection.Business.CachingLogic.GetCachedUsers(uin, refreshCache);
621621
}
622622

623+
public async Task<(int code, string? message, BotGroupInfo info)> FetchGroupInfo(ulong uin)
624+
{
625+
var events = await Collection.Business.SendEvent(GetGroupInfoEvent.Create(uin));
626+
if (events.Count == 0) return (-1, "No Result", new());
627+
var @event = (GetGroupInfoEvent)events[0];
628+
return (@event.ResultCode, @event.Message, @event.Info);
629+
}
630+
623631
public async Task<bool> SetMessageReaction(uint groupUin, uint sequence, string code, bool isAdd)
624632
{
625633
if (isAdd)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Lagrange.Core.Common.Entity;
2+
3+
namespace Lagrange.Core.Internal.Event.Message;
4+
5+
internal class GetGroupInfoEvent : ProtocolEvent
6+
{
7+
public ulong Uin { get; }
8+
9+
public string? Message { get; }
10+
11+
public BotGroupInfo Info { get; }
12+
13+
protected GetGroupInfoEvent(ulong uin) : base(true)
14+
{
15+
Uin = uin;
16+
Info = new();
17+
}
18+
19+
protected GetGroupInfoEvent(int code, string? message, BotGroupInfo info) : base(code)
20+
{
21+
Message = message;
22+
Info = info;
23+
}
24+
25+
public static GetGroupInfoEvent Create(ulong uin) => new(uin);
26+
27+
public static GetGroupInfoEvent Result(int code, string? message, BotGroupInfo info)
28+
{
29+
return new(code, message, info);
30+
}
31+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using ProtoBuf;
2+
3+
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request;
4+
5+
#pragma warning disable CS8618
6+
// ReSharper disable InconsistentNaming
7+
8+
/// <summary>
9+
/// Get Cookie
10+
/// </summary>
11+
[ProtoContract]
12+
[OidbSvcTrpcTcp(0x88D, 0)]
13+
internal class OidbSvcTrpcTcp0x88D_0
14+
{
15+
[ProtoMember(1)]
16+
public uint Field1 { get; set; }
17+
18+
[ProtoMember(2)]
19+
public OidbSvcTrpcTcp0x88D_0Config Config { get; set; }
20+
}
21+
22+
[ProtoContract]
23+
internal class OidbSvcTrpcTcp0x88D_0Config
24+
{
25+
[ProtoMember(1)]
26+
public ulong Uin { get; set; }
27+
28+
[ProtoMember(2)]
29+
public OidbSvcTrpcTcp0x88D_0Flags Flags { get; set; }
30+
}
31+
32+
[ProtoContract]
33+
internal class OidbSvcTrpcTcp0x88D_0Flags
34+
{
35+
[ProtoMember(1)]
36+
public bool? OwnerUid { get; set; }
37+
38+
[ProtoMember(2)]
39+
public bool? CreateTime { get; set; }
40+
41+
[ProtoMember(5)]
42+
public bool? MaxMemberCount { get; set; }
43+
44+
[ProtoMember(6)]
45+
public bool? MemberCount { get; set; }
46+
47+
[ProtoMember(10)]
48+
public bool? Level { get; set; }
49+
50+
[ProtoMember(15)]
51+
public string? Name { get; set; }
52+
53+
[ProtoMember(16)]
54+
public string? NoticePreview { get; set; }
55+
56+
[ProtoMember(21)]
57+
public bool? Uin { get; set; }
58+
59+
[ProtoMember(22)]
60+
public bool? LastSequence { get; set; }
61+
62+
[ProtoMember(23)]
63+
public bool? LastMessageTime { get; set; }
64+
65+
[ProtoMember(24)]
66+
public bool? Question { get; set; }
67+
68+
[ProtoMember(25)]
69+
public string? Answer { get; set; }
70+
71+
[ProtoMember(29)]
72+
public string? MaxAdminCount { get; set; }
73+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using ProtoBuf;
2+
3+
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request;
4+
5+
#pragma warning disable CS8618
6+
// ReSharper disable InconsistentNaming
7+
8+
[ProtoContract]
9+
internal class OidbSvcTrpcTcp0x88D_0Response
10+
{
11+
[ProtoMember(1)]
12+
public OidbSvcTrpcTcp0x88D_0ResponseGroupInfo GroupInfo { get; set; }
13+
}
14+
15+
[ProtoContract]
16+
public class OidbSvcTrpcTcp0x88D_0ResponseGroupInfo
17+
{
18+
[ProtoMember(1)]
19+
public ulong Uin { get; set; }
20+
21+
[ProtoMember(2)]
22+
public OidbSvcTrpcTcp0x88D_0ResponseResults Results { get; set; }
23+
}
24+
25+
[ProtoContract]
26+
public class OidbSvcTrpcTcp0x88D_0ResponseResults
27+
{
28+
[ProtoMember(1)]
29+
public string OwnerUid { get; set; }
30+
31+
[ProtoMember(2)]
32+
public ulong CreateTime { get; set; }
33+
34+
[ProtoMember(5)]
35+
public ulong MaxMemberCount { get; set; }
36+
37+
[ProtoMember(6)]
38+
public ulong MemberCount { get; set; }
39+
40+
[ProtoMember(10)]
41+
public ulong Level { get; set; }
42+
43+
[ProtoMember(15)]
44+
public string Name { get; set; }
45+
46+
[ProtoMember(16)]
47+
public string NoticePreview { get; set; }
48+
49+
[ProtoMember(21)]
50+
public ulong Uin { get; set; }
51+
52+
[ProtoMember(22)]
53+
public ulong LastSequence { get; set; }
54+
55+
[ProtoMember(23)]
56+
public ulong LastMessageTime { get; set; }
57+
58+
[ProtoMember(24)]
59+
public string Question { get; set; }
60+
61+
[ProtoMember(25)]
62+
public string Answer { get; set; }
63+
64+
[ProtoMember(29)]
65+
public ulong MaxAdminCount { get; set; }
66+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using Lagrange.Core.Common;
2+
using Lagrange.Core.Common.Entity;
3+
using Lagrange.Core.Internal.Event;
4+
using Lagrange.Core.Internal.Event.Message;
5+
using Lagrange.Core.Internal.Packets.Service.Oidb;
6+
using Lagrange.Core.Internal.Packets.Service.Oidb.Request;
7+
using Lagrange.Core.Utility.Extension;
8+
using ProtoBuf;
9+
10+
namespace Lagrange.Core.Internal.Service.Message;
11+
12+
[EventSubscribe(typeof(GetGroupInfoEvent))]
13+
[Service("OidbSvcTrpcTcp.0x88d_0")]
14+
internal class GetGroupInfoService : BaseService<GetGroupInfoEvent>
15+
{
16+
protected override bool Build(GetGroupInfoEvent input, BotKeystore keystore, BotAppInfo appInfo,
17+
BotDeviceInfo device, out Span<byte> output, out List<Memory<byte>>? extraPackets)
18+
{
19+
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x88D_0>(new OidbSvcTrpcTcp0x88D_0
20+
{
21+
Field1 = 537099973,
22+
Config = new OidbSvcTrpcTcp0x88D_0Config
23+
{
24+
Uin = input.Uin,
25+
Flags = new OidbSvcTrpcTcp0x88D_0Flags
26+
{
27+
OwnerUid = true,
28+
CreateTime = true,
29+
MaxMemberCount = true,
30+
MemberCount = true,
31+
Level = true,
32+
Name = "",
33+
NoticePreview = "",
34+
Uin = true,
35+
LastSequence = true,
36+
LastMessageTime = true,
37+
Question = true,
38+
Answer = "",
39+
MaxAdminCount = "",
40+
}
41+
}
42+
});
43+
44+
output = packet.Serialize();
45+
extraPackets = null;
46+
return true;
47+
}
48+
49+
protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
50+
out GetGroupInfoEvent output, out List<ProtocolEvent>? extraEvents)
51+
{
52+
var payload = Serializer.Deserialize<OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x88D_0Response>>(input);
53+
54+
if (payload.ErrorCode == 0)
55+
{
56+
output = GetGroupInfoEvent.Result(0, null, new BotGroupInfo
57+
{
58+
OwnerUid = payload.Body.GroupInfo.Results.OwnerUid,
59+
CreateTime = payload.Body.GroupInfo.Results.CreateTime,
60+
MaxMemberCount = payload.Body.GroupInfo.Results.MaxMemberCount,
61+
MemberCount = payload.Body.GroupInfo.Results.MemberCount,
62+
Level = payload.Body.GroupInfo.Results.Level,
63+
Name = payload.Body.GroupInfo.Results.Name,
64+
NoticePreview = payload.Body.GroupInfo.Results.NoticePreview,
65+
Uin = payload.Body.GroupInfo.Results.Uin,
66+
LastSequence = payload.Body.GroupInfo.Results.LastSequence,
67+
LastMessageTime = payload.Body.GroupInfo.Results.LastMessageTime,
68+
Question = payload.Body.GroupInfo.Results.Question,
69+
Answer = payload.Body.GroupInfo.Results.Answer,
70+
MaxAdminCount = payload.Body.GroupInfo.Results.MaxAdminCount,
71+
});
72+
}
73+
else
74+
{
75+
output = GetGroupInfoEvent.Result((int)payload.ErrorCode, payload.ErrorMsg, new());
76+
}
77+
extraEvents = null;
78+
return true;
79+
}
80+
}

Lagrange.Core/Utility/Sign/LinuxSigner.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
using System.Net.Http.Json;
2-
using System.Text;
3-
using System.Text.Json;
4-
using System.Text.Json.Nodes;
5-
using Lagrange.Core.Utility.Extension;
6-
using Lagrange.Core.Utility.Network;
7-
81
namespace Lagrange.Core.Utility.Sign;
92

103
internal class LinuxSigner : UrlSigner

Lagrange.Core/Utility/Sign/MacSigner.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
using System.Net.Http.Json;
2-
using System.Text;
3-
using System.Text.Json;
4-
using System.Text.Json.Nodes;
5-
using Lagrange.Core.Utility.Extension;
6-
71
namespace Lagrange.Core.Utility.Sign;
82

93
internal class MacSigner : UrlSigner

0 commit comments

Comments
 (0)