Skip to content

Commit 37b66a0

Browse files
committed
feat: 添加上传私聊文件的 API
1 parent 97b5e45 commit 37b66a0

File tree

10 files changed

+77
-0
lines changed

10 files changed

+77
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.Params;
2+
3+
4+
namespace EleCho.GoCqHttpSdk.Action
5+
{
6+
public class CqUploadPrivateFileAction : CqAction
7+
{
8+
public CqUploadPrivateFileAction(long userId, string file, string name)
9+
{
10+
UserId = userId;
11+
File = file;
12+
Name = name;
13+
}
14+
15+
public override CqActionType ActionType => CqActionType.UploadPrivateFile;
16+
17+
public long UserId { get; set; }
18+
public string File { get; set; }
19+
public string Name { get; set; }
20+
21+
internal override CqActionParamsModel GetParamsModel()
22+
{
23+
return new CqUploadPrivateFileActionParamsModel(UserId, File, Name);
24+
}
25+
}
26+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma warning disable IDE1006 // Naming Styles
2+
3+
4+
namespace EleCho.GoCqHttpSdk.Action.Model.Params
5+
{
6+
internal class CqUploadPrivateFileActionParamsModel : CqActionParamsModel
7+
{
8+
public CqUploadPrivateFileActionParamsModel(long user_id, string file, string name)
9+
{
10+
this.user_id = user_id;
11+
this.file = file;
12+
this.name = name;
13+
}
14+
15+
public long user_id { get; set; }
16+
public string file { get; set; }
17+
public string name { get; set; }
18+
}
19+
}

src/EleCho.GoCqHttpSdk/Action/Model/ResultData/CqActionResultDataModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ internal class CqActionResultDataModel
8383
GetWordSlices => dataValue.Deserialize<CqGetWordSlicesActionResultDataModel>(JsonHelper.Options),
8484
OcrImage => dataValue.Deserialize<CqOcrImageActionResultDataModel>(JsonHelper.Options),
8585

86+
UploadPrivateFile => dataValue.Deserialize<CqUploadPrivateFileActionResultDataModel>(JsonHelper.Options),
8687
UploadGroupFile => dataValue.Deserialize<CqUploadGroupFileActionResultDataModel>(JsonHelper.Options),
8788
DeleteGroupFile => dataValue.Deserialize<CqDeleteGroupFileActionResultDataModel>(JsonHelper.Options),
8889
CreateGroupFileFolder => dataValue.Deserialize<CqCreateGroupFolderActionResultDataModel>(JsonHelper.Options),
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace EleCho.GoCqHttpSdk.Action.Model.ResultData
2+
{
3+
internal class CqUploadPrivateFileActionResultDataModel : CqActionResultDataModel
4+
{
5+
// no data
6+
}
7+
}

src/EleCho.GoCqHttpSdk/Action/Result/CqActionResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ internal static CqActionResult CreateActionResultFromActionType(string actionTyp
116116
GetGroupFileSystemInfo => new CqGetGroupFileSystemInformationActionResult(),
117117
GetGroupRootFiles => new CqGetGroupRootFilesActionResult(),
118118
GetGroupFilesByFolder => new CqGetGroupFilesByFolderActionResult(),
119+
UploadPrivateFile => new CqUploadPrivateFileActionResult(),
119120

120121

121122
_ => throw new NotImplementedException()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.ResultData;
2+
3+
namespace EleCho.GoCqHttpSdk.Action
4+
{
5+
/// <summary>
6+
/// <inheritdoc/>
7+
/// </summary>
8+
public record class CqUploadPrivateFileActionResult : CqActionResult
9+
{
10+
internal CqUploadPrivateFileActionResult()
11+
{ }
12+
13+
internal override void ReadDataModel(CqActionResultDataModel? model)
14+
{
15+
16+
}
17+
}
18+
}

src/EleCho.GoCqHttpSdk/Enumeration/CqActionType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ public enum CqActionType
6161
GetGroupRootFiles,
6262
GetGroupFilesByFolder,
6363
GetGroupFileUrl,
64+
UploadPrivateFile,
6465
}
6566
}

src/EleCho.GoCqHttpSdk/Enumeration/CqEnum.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ internal static class CqEnum
188188
CqActionType.GetGroupFileSystemInformation => GetGroupFileSystemInfo,
189189
CqActionType.GetGroupRootFiles => GetGroupRootFiles,
190190
CqActionType.GetGroupFilesByFolder => GetGroupFilesByFolder,
191+
CqActionType.UploadPrivateFile => UploadPrivateFile,
191192

192193
_ => throw new ArgumentException($"Unknown Action type: {type}")
193194
};

src/EleCho.GoCqHttpSdk/Extension/CqActionSessionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ public static class CqActionSessionExtensions
184184
=> session.InvokeActionAsync<CqGetGroupRootFilesAction, CqGetGroupRootFilesActionResult>(new CqGetGroupRootFilesAction(groupId));
185185
public static Task<CqGetGroupFilesByFolderActionResult?> GetGroupFilesByFolderAsync(this ICqActionSession session, long groupId, string folderId)
186186
=> session.InvokeActionAsync<CqGetGroupFilesByFolderAction, CqGetGroupFilesByFolderActionResult>(new CqGetGroupFilesByFolderAction(groupId, folderId));
187+
public static Task<CqUploadPrivateFileActionResult?> UploadPrivateFileAsync(this ICqActionSession session, long userId, string file, string name)
188+
=> session.InvokeActionAsync<CqUploadPrivateFileAction, CqUploadPrivateFileActionResult>(new CqUploadPrivateFileAction(userId, file, name));
187189

188190

189191

src/EleCho.GoCqHttpSdk/Utils/Consts.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public static class ActionType
141141
public const string GetGroupFileSystemInfo = "get_group_file_system_info";
142142
public const string GetGroupRootFiles = "get_group_root_files";
143143
public const string GetGroupFilesByFolder = "get_group_files_by_folder";
144+
public const string UploadPrivateFile = "upload_private_file";
144145

145146
}
146147

0 commit comments

Comments
 (0)