-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Linwenxuan
authored and
Linwenxuan
committed
Oct 8, 2023
1 parent
e39c6b4
commit f3777f7
Showing
14 changed files
with
343 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Lagrange.Core/Internal/Event/Protocol/Action/GroupFSDeleteEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Lagrange.Core.Internal.Event.Protocol.Action; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
internal class GroupFSDeleteEvent : GroupFSOperationEvent | ||
{ | ||
public string FileId { get; set; } | ||
|
||
public string ParentDirectory { get; set; } | ||
|
||
public GroupFSDeleteEvent(uint groupUin, string fileId, string parentDirectory) : base(groupUin) | ||
{ | ||
FileId = fileId; | ||
ParentDirectory = parentDirectory; | ||
} | ||
|
||
public GroupFSDeleteEvent(int resultCode) : base(resultCode) { } | ||
|
||
public static GroupFSDeleteEvent Create(uint groupUin, string fileId, string parentDirectory) | ||
=> new(groupUin, fileId, parentDirectory); | ||
|
||
public static GroupFSDeleteEvent Result(int resultCode) | ||
=> new(resultCode); | ||
} |
24 changes: 24 additions & 0 deletions
24
Lagrange.Core/Internal/Event/Protocol/Action/GroupFSDownloadEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Lagrange.Core.Internal.Event.Protocol.Action; | ||
|
||
internal class GroupFSDownloadEvent : GroupFSOperationEvent | ||
{ | ||
public string FileUrl { get; set; } | ||
|
||
public string FileId { get; set; } | ||
|
||
private GroupFSDownloadEvent(uint groupUin, string fileId) : base(groupUin) | ||
{ | ||
FileId = fileId; | ||
FileUrl = ""; | ||
} | ||
|
||
private GroupFSDownloadEvent(int resultCode, string fileUrl) : base(resultCode) | ||
{ | ||
FileUrl = fileUrl; | ||
FileId = ""; | ||
} | ||
|
||
public static GroupFSDownloadEvent Create(uint groupUin, string fileId) => new(groupUin, fileId); | ||
|
||
public static GroupFSDownloadEvent Result(int resultCode, string fileId) => new(resultCode, fileId); | ||
} |
27 changes: 27 additions & 0 deletions
27
Lagrange.Core/Internal/Event/Protocol/Action/GroupFSMoveEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace Lagrange.Core.Internal.Event.Protocol.Action; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
internal class GroupFSMoveEvent : GroupFSOperationEvent | ||
{ | ||
public string FileId { get; set; } | ||
|
||
public string ParentDirectory { get; set; } | ||
|
||
public string TargetDirectory { get; set; } | ||
|
||
private GroupFSMoveEvent(uint groupUin, string fileId, string parentDirectory, string targetDirectory) : base(groupUin) | ||
{ | ||
FileId = fileId; | ||
ParentDirectory = parentDirectory; | ||
TargetDirectory = targetDirectory; | ||
} | ||
|
||
private GroupFSMoveEvent(int resultCode) : base(resultCode) { } | ||
|
||
public static GroupFSMoveEvent Create(uint groupUin, string fileId, string parentDirectory, string targetDirectory) | ||
=> new(groupUin, fileId, parentDirectory, targetDirectory); | ||
|
||
public static GroupFSMoveEvent Result(int resultCode) | ||
=> new(resultCode); | ||
} |
13 changes: 13 additions & 0 deletions
13
Lagrange.Core/Internal/Event/Protocol/Action/GroupFSOperationEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Lagrange.Core.Internal.Event.Protocol.Action; | ||
|
||
internal abstract class GroupFSOperationEvent : ProtocolEvent | ||
{ | ||
public uint GroupUin { get; set; } | ||
|
||
protected GroupFSOperationEvent(uint groupUin) : base(true) | ||
{ | ||
GroupUin = groupUin; | ||
} | ||
|
||
protected GroupFSOperationEvent(int resultCode) : base(resultCode) { } | ||
} |
27 changes: 27 additions & 0 deletions
27
Lagrange.Core/Internal/Event/Protocol/Action/GroupFSRenameEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace Lagrange.Core.Internal.Event.Protocol.Action; | ||
|
||
#pragma warning disable CS8618 | ||
|
||
internal class GroupFSRenameEvent : GroupFSOperationEvent | ||
{ | ||
public string FileId { get; set; } | ||
|
||
public string ParentDirectory { get; set; } | ||
|
||
public string TargetDirectory { get; set; } | ||
|
||
private GroupFSRenameEvent(uint groupUin, string fileId, string parentDirectory, string targetDirectory) : base(groupUin) | ||
{ | ||
FileId = fileId; | ||
ParentDirectory = parentDirectory; | ||
TargetDirectory = targetDirectory; | ||
} | ||
|
||
private GroupFSRenameEvent(int resultCode) : base(resultCode) { } | ||
|
||
public static GroupFSRenameEvent Create(uint groupUin, string fileId, string parentDirectory, string targetDirectory) | ||
=> new(groupUin, fileId, parentDirectory, targetDirectory); | ||
|
||
public static GroupFSRenameEvent Result(int resultCode) | ||
=> new(resultCode); | ||
} |
12 changes: 12 additions & 0 deletions
12
Lagrange.Core/Internal/Event/Protocol/Action/GroupFSUploadEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Lagrange.Core.Internal.Event.Protocol.Action; | ||
|
||
internal class GroupFSUploadEvent : GroupFSOperationEvent | ||
{ | ||
public GroupFSUploadEvent(uint groupUin) : base(groupUin) | ||
{ | ||
} | ||
|
||
public GroupFSUploadEvent(int resultCode) : base(resultCode) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0x6D6_2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
|
||
#pragma warning disable CS8618 | ||
// ReSharper disable InconsistentNaming | ||
|
||
/// <summary> | ||
/// Group File Download | ||
/// </summary> | ||
[ProtoContract] | ||
[OidbSvcTrpcTcp(0x6d6, 2)] | ||
internal class OidbSvcTrpcTcp0x6D6_2 | ||
{ | ||
[ProtoMember(3)] public OidbSvcTrpcTcp0x6D6_2Download? Download { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTcp0x6D6_2Download | ||
{ | ||
[ProtoMember(1)] public uint GroupUin { get; set; } | ||
|
||
[ProtoMember(2)] public uint AppId { get; set; } // 7 | ||
|
||
[ProtoMember(3)] public uint BusId { get; set; } // 102 | ||
|
||
[ProtoMember(4)] public string FileId { get; set; } | ||
} |
29 changes: 29 additions & 0 deletions
29
Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0x6D6_5.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
|
||
#pragma warning disable CS8618 | ||
// ReSharper disable InconsistentNaming | ||
|
||
[ProtoContract] | ||
[OidbSvcTrpcTcp(0x6d6, 5)] | ||
internal class OidbSvcTrpcTcp0x6D6_5 | ||
{ | ||
[ProtoMember(6)] public OidbSvcTrpcTcp0x6D6_5Move? Move { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTcp0x6D6_5Move | ||
{ | ||
[ProtoMember(1)] public uint GroupUin { get; set; } | ||
|
||
[ProtoMember(2)] public uint AppId { get; set; } // 7 | ||
|
||
[ProtoMember(3)] public uint BusId { get; set; } // 102 | ||
|
||
[ProtoMember(4)] public string fileId { get; set; } | ||
|
||
[ProtoMember(5)] public string ParentDirectory { get; set; } | ||
|
||
[ProtoMember(6)] public string TargetDirectory { get; set; } | ||
} |
12 changes: 12 additions & 0 deletions
12
Lagrange.Core/Internal/Packets/Service/Oidb/Response/OidbSvcTrpcTco0x6D6Response.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Response; | ||
|
||
#pragma warning disable CS8618 | ||
// ReSharper disable InconsistentNaming | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTco0x6D6Response | ||
{ | ||
[ProtoMember(3)] public OidbSvcTrpcTcp0x6D6_2Response Download { get; set; } | ||
} |
34 changes: 34 additions & 0 deletions
34
Lagrange.Core/Internal/Packets/Service/Oidb/Response/OidbSvcTrpcTcp0x6D6_2Response.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Response; | ||
|
||
#pragma warning disable CS8618 | ||
// ReSharper disable InconsistentNaming | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTcp0x6D6_2Response | ||
{ | ||
[ProtoMember(1)] public int RetCode { get; set; } | ||
|
||
[ProtoMember(2)] public string RetMsg { get; set; } | ||
|
||
[ProtoMember(3)] public string ClientWording { get; set; } | ||
|
||
[ProtoMember(4)] public string DownloadIp { get; set; } | ||
|
||
[ProtoMember(5)] public string DownloadDns { get; set; } | ||
|
||
[ProtoMember(6)] public byte[] DownloadUrl { get; set; } | ||
|
||
[ProtoMember(7)] public byte[] FileSha1 { get; set; } | ||
|
||
[ProtoMember(8)] public byte[] FileSha3 { get; set; } // ? | ||
|
||
[ProtoMember(9)] public byte[] FileMd5 { get; set; } | ||
|
||
[ProtoMember(10)] public byte[] CookieVal { get; set; } | ||
|
||
[ProtoMember(11)] public string SaveFileName { get; set; } | ||
|
||
[ProtoMember(12)] public uint PreviewPort { get; set; } | ||
} |
54 changes: 54 additions & 0 deletions
54
Lagrange.Core/Internal/Service/Action/GroupFSDownloadService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Lagrange.Core.Common; | ||
using Lagrange.Core.Internal.Event.Protocol; | ||
using Lagrange.Core.Internal.Event.Protocol.Action; | ||
using Lagrange.Core.Internal.Packets; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb.Response; | ||
using Lagrange.Core.Internal.Service.Abstraction; | ||
using Lagrange.Core.Utility.Extension; | ||
using Lagrange.Core.Utility.Binary; | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Service.Action; | ||
|
||
[EventSubscribe(typeof(GroupFSDownloadEvent))] | ||
[Service("OidbSvcTrpcTcp.0x6d6_2")] | ||
internal class GroupFSDownloadService : BaseService<GroupFSDownloadEvent> | ||
{ | ||
protected override bool Build(GroupFSDownloadEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out BinaryPacket output, out List<BinaryPacket>? extraPackets) | ||
{ | ||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x6D6_2>(new OidbSvcTrpcTcp0x6D6_2 | ||
{ | ||
Download = new OidbSvcTrpcTcp0x6D6_2Download | ||
{ | ||
GroupUin = input.GroupUin, | ||
AppId = 7, | ||
BusId = 102, | ||
FileId = input.FileId | ||
} | ||
}, false, true); | ||
|
||
var stream = new MemoryStream(); | ||
Serializer.Serialize(stream, packet); | ||
output = new BinaryPacket(stream); | ||
|
||
extraPackets = null; | ||
return true; | ||
} | ||
|
||
protected override bool Parse(SsoPacket input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out GroupFSDownloadEvent output, out List<ProtocolEvent>? extraEvents) | ||
{ | ||
var payload = input.Payload.ReadBytes(BinaryPacket.Prefix.Uint32 | BinaryPacket.Prefix.WithPrefix); | ||
var packet = Serializer.Deserialize<OidbSvcTrpcTcpResponse<OidbSvcTrpcTco0x6D6Response>>(payload.AsSpan()); | ||
var download = packet.Body.Download; | ||
|
||
string url = $"https://{download.DownloadIp}:443/ftn_handler/{download.DownloadUrl.Hex(true)}/?fname="; | ||
|
||
output = GroupFSDownloadEvent.Result((int)packet.ErrorCode, url); | ||
extraEvents = null; | ||
return true; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
Lagrange.Core/Internal/Service/Action/GroupFSMoveService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Lagrange.Core.Common; | ||
using Lagrange.Core.Internal.Event.Protocol; | ||
using Lagrange.Core.Internal.Event.Protocol.Action; | ||
using Lagrange.Core.Internal.Packets; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
using Lagrange.Core.Internal.Service.Abstraction; | ||
using Lagrange.Core.Utility.Extension; | ||
using Lagrange.Core.Utility.Binary; | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Service.Action; | ||
|
||
[EventSubscribe(typeof(GroupFSMoveEvent))] | ||
[Service("OidbSvcTrpcTcp.0x6d6_5")] | ||
internal class GroupFSMoveService : BaseService<GroupFSMoveEvent> | ||
{ | ||
protected override bool Build(GroupFSMoveEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out BinaryPacket output, out List<BinaryPacket>? extraPackets) | ||
{ | ||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x6D6_5>(new OidbSvcTrpcTcp0x6D6_5 | ||
{ | ||
Move = new OidbSvcTrpcTcp0x6D6_5Move | ||
{ | ||
GroupUin = input.GroupUin, | ||
AppId = 7, | ||
BusId = 102, | ||
fileId = input.FileId, | ||
ParentDirectory = input.ParentDirectory, | ||
TargetDirectory = input.TargetDirectory | ||
} | ||
}, false, true); | ||
|
||
var stream = new MemoryStream(); | ||
Serializer.Serialize(stream, packet); | ||
output = new BinaryPacket(stream); | ||
|
||
extraPackets = null; | ||
return true; | ||
} | ||
|
||
protected override bool Parse(SsoPacket input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, out GroupFSMoveEvent output, | ||
out List<ProtocolEvent>? extraEvents) | ||
{ | ||
var payload = input.Payload.ReadBytes(BinaryPacket.Prefix.Uint32 | BinaryPacket.Prefix.WithPrefix); | ||
var packet = Serializer.Deserialize<OidbSvcTrpcTcpResponse<byte[]>>(payload.AsSpan()); | ||
|
||
output = GroupFSMoveEvent.Result((int)packet.ErrorCode); | ||
extraEvents = null; | ||
return true; | ||
} | ||
} |