-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[All] Add RenameGroupFolderOp (#551)
- Loading branch information
Showing
9 changed files
with
141 additions
and
2 deletions.
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
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/Event/Action/GroupFSRenameFolderEvent.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 @@ | ||
namespace Lagrange.Core.Internal.Event.Action; | ||
|
||
internal class GroupFSRenameFolderEvent : ProtocolEvent | ||
{ | ||
public uint GroupUin { get; } | ||
|
||
public string FolderId { get; } = string.Empty; | ||
|
||
public string NewFolderName { get; } = string.Empty; | ||
|
||
public string RetMsg { get; set; } = string.Empty; | ||
|
||
private GroupFSRenameFolderEvent(uint groupUin, string folderId, string newFolderName) : base(true) | ||
{ | ||
GroupUin = groupUin; | ||
FolderId = folderId; | ||
NewFolderName = newFolderName; | ||
} | ||
|
||
private GroupFSRenameFolderEvent(int resultCode, string retMsg) : base(resultCode) | ||
{ | ||
RetMsg = retMsg; | ||
} | ||
|
||
public static GroupFSRenameFolderEvent Create(uint groupUin, string folderId, string newFolderName) => new(groupUin, folderId, newFolderName); | ||
|
||
public static GroupFSRenameFolderEvent Result(int resultCode, string retMsg) => new(resultCode, retMsg); | ||
} |
26 changes: 26 additions & 0 deletions
26
Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0x6D7_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,26 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
|
||
#pragma warning disable CS8618 | ||
// ReSharper disable InconsistentNaming | ||
|
||
/// <summary> | ||
/// Delete Folder | ||
/// </summary> | ||
[ProtoContract] | ||
[OidbSvcTrpcTcp(0x6D7, 2)] | ||
internal class OidbSvcTrpcTcp0x6D7_2 | ||
{ | ||
[ProtoMember(3)] public OidbSvcTrpcTcp0x6D7_2Rename Rename { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTcp0x6D7_2Rename | ||
{ | ||
[ProtoMember(1)] public uint GroupUin { get; set; } | ||
|
||
[ProtoMember(3)] public string FolderId { get; set; } | ||
|
||
[ProtoMember(4)] public string NewFolderName { get; set; } | ||
} |
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
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
43 changes: 43 additions & 0 deletions
43
Lagrange.Core/Internal/Service/Action/GroupFSRenameFolderService.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,43 @@ | ||
using Lagrange.Core.Common; | ||
using Lagrange.Core.Internal.Event; | ||
using Lagrange.Core.Internal.Event.Action; | ||
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.Utility.Extension; | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Service.Action; | ||
|
||
[EventSubscribe(typeof(GroupFSRenameFolderEvent))] | ||
[Service("OidbSvcTrpcTcp.0x6d7_2")] | ||
internal class GroupFSRenameFolderService : BaseService<GroupFSRenameFolderEvent> | ||
{ | ||
protected override bool Build(GroupFSRenameFolderEvent input, BotKeystore keystore, BotAppInfo appInfo, | ||
BotDeviceInfo device, out Span<byte> output, out List<Memory<byte>>? extraPackets) | ||
{ | ||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x6D7_2>(new OidbSvcTrpcTcp0x6D7_2 | ||
{ | ||
Rename = new OidbSvcTrpcTcp0x6D7_2Rename | ||
{ | ||
GroupUin = input.GroupUin, | ||
FolderId = input.FolderId, | ||
NewFolderName = input.NewFolderName | ||
} | ||
}, false, true); | ||
|
||
output = packet.Serialize(); | ||
extraPackets = null; | ||
return true; | ||
} | ||
|
||
protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out GroupFSRenameFolderEvent output, out List<ProtocolEvent>? extraEvents) | ||
{ | ||
var packet = Serializer.Deserialize<OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x6D7Response>>(input); | ||
|
||
output = GroupFSRenameFolderEvent.Result(packet.Body.Rename.Retcode, packet.Body.Rename.RetMsg); | ||
extraEvents = null; | ||
return true; | ||
} | ||
} |
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 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Lagrange.OneBot.Core.Entity.Action; | ||
|
||
[Serializable] | ||
public class OneBotRenameFolder | ||
{ | ||
[JsonPropertyName("group_id")] public uint GroupId { get; set; } | ||
|
||
[JsonPropertyName("folder_id")] public string FolderId { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("new_folder_name")] public string NewFolderName { get; set; } = string.Empty; | ||
} |
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