Skip to content

Commit 97b5e45

Browse files
committed
feat: 添加了文件相关的 API
1 parent 1a4cda6 commit 97b5e45

File tree

72 files changed

+1406
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1406
-181
lines changed

README.md

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -276,68 +276,4 @@ Action 在 go-cqhttp 中的 JSON 格式与消息类似, 它为参数抽出了一
276276

277277
如果你有什么好的想法, 也可以直接提交一个 PR, 我们一起来完善这个项目吧!
278278

279-
> 球球了, 有问题请直接提出来, 不要犹豫, 咱真的很需要用户意见, 尤其是如何提升这个库的 "优雅程度".
280-
281-
### 📚 编写规范
282-
283-
下面是编写时可能提供帮助的一些规范:
284-
285-
> 虽然库的有些内部代码真的很丑(例如命名), 但这是为了外部访问的便捷而做出的妥协, 实属无奈之举.
286-
287-
#### 🗂️ 各个文件夹的内容
288-
289-
- `/Action` : 用户要使用到的各种 CqAction
290-
- `/Action/Sender` : 用来发送 CqAction 的各个协议实现
291-
- `/Action/Model/Params` : CqAction 进行调用时所需要的具体参数 (用户不可见)
292-
- `/Action/Result` : 用户要使用到的各种 CqActionResult
293-
- `/Action/Result/Model/Data` : CqActionResult 返回时要读取的具体数据 (用户不可见)
294-
- `/DataStructure` : CqAction 参数或返回数据中所使用到的各种结构
295-
- `/DataStructure/Model` : CqAction 参数或返回数据中所使用到的各种结构的实际传输声明 (用户不可见)
296-
- `/Enumeration` : 各种枚举类型
297-
- `/Extension` : 各种拓展方法
298-
- `/JsonConverter` : 程序集所需要使用的 JSON 转换器 (用户不可见)
299-
- `/Message` : 用户会用到的各种消息类型
300-
- `/Message/CqCodeDef` : CQ 码操作类
301-
- `/Message/DataModel` : 消息的实际传输数据模型 (用户不可见)
302-
- `/Message/JsonConverter` : 某些特殊消息需要使用到的 JSON 转换器 (用户不可见)
303-
- `/Post` : 消息上报的各种类型
304-
- `/Utils` : 各种工具类
305-
- `/` : 被用户直接访问, 不需要进行归类的内容
306-
307-
#### 🛠️ 编写步骤
308-
309-
编写一个 Action 的参考步骤:
310-
311-
1. 添加 `CqActionType` 成员
312-
2. 添加 `Consts.ActionType` 成员
313-
3. 在 `CqEnum` 中实现 `CqActionType` 转字符串
314-
4. 编写它的 `CqAction` 类
315-
5. 编写它的 `CqActionParamsModel` 类 (internal, 有一个全参构造函数, 成员名称为原始名称)
316-
6. 编写它的 `CqActionResult` 类 (不能有公开构造函数, 因为用户不能创建它的实例)
317-
7. 编写它的 `CqActionResultDataModel` 类 (internal, 只有 JSON 构造函数, 成员名称为原始名称)
318-
8. 实现 `CqActionResult.FromRaw`
319-
9. 实现 `CqActionResultDataModel.FromRaw`
320-
10. 在 `CqActionSessionExtensions` 中添加对应拓展方法
321-
322-
编写一个 CqMsg 的参考步骤:
323-
324-
1. 添加 `CqMsgType` 成员
325-
2. 编写它的 `CqMsg` 类
326-
3. 编写它的 `CqMsgDataModel` 类 (internal, 一个无参构造函数, 一个全参构造函数)
327-
4. 实现它在 `CqMsgModelConverter` 中的转换
328-
5. 实现它在 `CqCode.ModelChainFromCqCodeString` 中的转换
329-
330-
#### 📃 命名规范
331-
332-
- 尽量将缩写改为全称, 尽量将奇怪的名称改为正常的名称 \
333-
例如: SetGroupBan -> BanGroupMember (禁言群成员)
334-
- 尽量将错误的名称改为正确的名称 \
335-
例如: CheckUrlSafely -> CheckUrlSafety (检查链接安全性)
336-
337-
#### 📎 类型声明提示
338-
339-
- 在原文档中以 `number` 标识的类型, 统一使用 `long`, 否则可能会溢出
340-
- 在原文档中, 消息 ID 有的地方声明为 `int32`, 有的地方声明为 `int64`, 在本库中, 将统一使用 `int64`
341-
342-
343-
279+
> 球球了, 有问题请直接提出来, 不要犹豫, 咱真的很需要用户意见, 尤其是如何提升这个库的 "优雅程度".

src/EleCho.GoCqHttpSdk/Action/CqBanGroupAllMembers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public CqBanGroupAllMembersAction(long groupId, bool enable)
3333
/// 是否启用禁言
3434
/// </summary>
3535
public bool Enable { get; set; }
36-
37-
36+
37+
3838
internal override CqActionParamsModel GetParamsModel()
3939
{
4040
return new CqBanGroupAllMembersActionParamsModel(GroupId, Enable);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.Params;
2+
3+
4+
namespace EleCho.GoCqHttpSdk.Action
5+
{
6+
/// <summary>
7+
/// 创建群文件文件夹操作
8+
/// </summary>
9+
public class CqCreateGroupFolderAction : CqAction
10+
{
11+
/// <summary>
12+
/// 实例化
13+
/// </summary>
14+
/// <param name="groupId"></param>
15+
/// <param name="name"></param>
16+
public CqCreateGroupFolderAction(long groupId, string name)
17+
{
18+
GroupId = groupId;
19+
Name = name;
20+
}
21+
22+
/// <summary>
23+
/// 操作类型: 创建群文件夹
24+
/// </summary>
25+
public override CqActionType ActionType => CqActionType.CreateGroupFolder;
26+
27+
/// <summary>
28+
/// 群号
29+
/// </summary>
30+
public long GroupId { get; set; }
31+
32+
/// <summary>
33+
/// 文件夹名称
34+
/// </summary>
35+
public string Name { get; set; }
36+
37+
/// <summary>
38+
/// 文件夹父 ID (仅能为 / )
39+
/// </summary>
40+
public string Parent { get; set; } = "/";
41+
42+
internal override CqActionParamsModel GetParamsModel()
43+
{
44+
return new CqCreateGroupFolderParamsModel(GroupId, Name, Parent);
45+
}
46+
}
47+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.Params;
2+
3+
4+
namespace EleCho.GoCqHttpSdk.Action
5+
{
6+
/// <summary>
7+
/// 删除群文件操作
8+
/// </summary>
9+
public class CqDeleteGroupFileAction : CqAction
10+
{
11+
/// <summary>
12+
/// 实例化
13+
/// </summary>
14+
/// <param name="groupId"></param>
15+
/// <param name="fileId"></param>
16+
/// <param name="busid"></param>
17+
public CqDeleteGroupFileAction(long groupId, string fileId, int busid)
18+
{
19+
GroupId = groupId;
20+
FileId = fileId;
21+
Busid = busid;
22+
}
23+
24+
/// <summary>
25+
/// 操作类型: 删除群文件
26+
/// </summary>
27+
public override CqActionType ActionType => CqActionType.DeleteGroupFile;
28+
29+
/// <summary>
30+
/// 群号
31+
/// </summary>
32+
public long GroupId { get; set; }
33+
34+
/// <summary>
35+
/// 文件 ID, 参考 <see cref="CqGroupUploadedFile"/>
36+
/// </summary>
37+
public string FileId { get; set; }
38+
39+
/// <summary>
40+
/// 文件类型, 参考 <see cref="CqGroupUploadedFile"/>
41+
/// </summary>
42+
public int Busid { get; set; }
43+
44+
internal override CqActionParamsModel GetParamsModel()
45+
{
46+
return new CqDeleteGroupFileActionParamsModel(GroupId, FileId, Busid);
47+
}
48+
}
49+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.Params;
2+
3+
4+
namespace EleCho.GoCqHttpSdk.Action
5+
{
6+
/// <summary>
7+
/// 删除群文件夹操作
8+
/// </summary>
9+
public class CqDeleteGroupFolderAction : CqAction
10+
{
11+
/// <summary>
12+
/// 实例化
13+
/// </summary>
14+
/// <param name="groupId"></param>
15+
/// <param name="folderId"></param>
16+
public CqDeleteGroupFolderAction(long groupId, string folderId)
17+
{
18+
GroupId = groupId;
19+
FolderId = folderId;
20+
}
21+
22+
/// <summary>
23+
/// 操作类型: 删除群文件夹
24+
/// </summary>
25+
public override CqActionType ActionType => CqActionType.DeleteGroupFolder;
26+
27+
/// <summary>
28+
/// 群号
29+
/// </summary>
30+
public long GroupId { get; set; }
31+
32+
/// <summary>
33+
/// 文件夹 ID
34+
/// </summary>
35+
public string FolderId { get; set; }
36+
37+
38+
internal override CqActionParamsModel GetParamsModel()
39+
{
40+
return new CqDeleteGroupFolderActionParamsModel(GroupId, FolderId);
41+
}
42+
}
43+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.Params;
2+
3+
4+
namespace EleCho.GoCqHttpSdk.Action
5+
{
6+
/// <summary>
7+
/// 获取群文件系统信息操作
8+
/// </summary>
9+
public class CqGetGroupFileSystemInformationAction : CqAction
10+
{
11+
/// <summary>
12+
/// 实例化
13+
/// </summary>
14+
/// <param name="groupId"></param>
15+
public CqGetGroupFileSystemInformationAction(long groupId)
16+
{
17+
GroupId = groupId;
18+
}
19+
20+
/// <summary>
21+
/// 操作类型: 获取群文件系统信息
22+
/// </summary>
23+
public override CqActionType ActionType => CqActionType.GetGroupFileSystemInformation;
24+
25+
/// <summary>
26+
/// 群号
27+
/// </summary>
28+
public long GroupId { get; set; }
29+
30+
internal override CqActionParamsModel GetParamsModel()
31+
{
32+
return new CqGetGroupFileSystemInformationActionParamsModel(GroupId);
33+
}
34+
}
35+
}
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 CqGetGroupFileUrlAction : CqAction
7+
{
8+
public CqGetGroupFileUrlAction(long groupId, string fileId, int busid)
9+
{
10+
GroupId = groupId;
11+
FileId = fileId;
12+
Busid = busid;
13+
}
14+
15+
public override CqActionType ActionType => CqActionType.GetGroupFileUrl;
16+
17+
public long GroupId { get; set; }
18+
public string FileId { get; set; }
19+
public int Busid { get; set; }
20+
21+
internal override CqActionParamsModel GetParamsModel()
22+
{
23+
return new CqGetGroupFileUrlActionParamsModel(GroupId, FileId, Busid);
24+
}
25+
}
26+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.Params;
2+
3+
4+
namespace EleCho.GoCqHttpSdk.Action
5+
{
6+
/// <summary>
7+
/// 获取群子目录文件列表操作
8+
/// </summary>
9+
public class CqGetGroupFilesByFolderAction : CqAction
10+
{
11+
/// <summary>
12+
/// 实例化
13+
/// </summary>
14+
/// <param name="groupId"></param>
15+
/// <param name="folderId"></param>
16+
public CqGetGroupFilesByFolderAction(long groupId, string folderId)
17+
{
18+
GroupId = groupId;
19+
FolderId = folderId;
20+
}
21+
22+
/// <summary>
23+
/// 操作类型: 获取群子目录文件列表
24+
/// </summary>
25+
public override CqActionType ActionType => CqActionType.GetGroupFilesByFolder;
26+
27+
/// <summary>
28+
/// 群号
29+
/// </summary>
30+
public long GroupId { get; set; }
31+
32+
/// <summary>
33+
/// 目录 ID
34+
/// </summary>
35+
public string FolderId { get; set; }
36+
37+
internal override CqActionParamsModel GetParamsModel()
38+
{
39+
return new CqGetGroupFilesByFolderActionParamsModel(GroupId, FolderId);
40+
}
41+
}
42+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.Params;
2+
3+
4+
namespace EleCho.GoCqHttpSdk.Action
5+
{
6+
/// <summary>
7+
/// 获取群根目录文件列表操作
8+
/// </summary>
9+
public class CqGetGroupRootFilesAction : CqAction
10+
{
11+
/// <summary>
12+
/// 实例化
13+
/// </summary>
14+
/// <param name="groupId"></param>
15+
public CqGetGroupRootFilesAction(long groupId)
16+
{
17+
GroupId = groupId;
18+
}
19+
20+
21+
/// <summary>
22+
/// 操作类型: 获取群根目录文件列表
23+
/// </summary>
24+
public override CqActionType ActionType => CqActionType.GetGroupRootFiles;
25+
26+
/// <summary>
27+
/// 群号
28+
/// </summary>
29+
public long GroupId { get; set; }
30+
31+
internal override CqActionParamsModel GetParamsModel()
32+
{
33+
return new CqGetGroupRootFilesActionParamsModel(GroupId);
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)