Skip to content

Commit 452cabb

Browse files
committed
feat: 添加了 GetGroupMemberList 操作
1 parent 626d934 commit 452cabb

31 files changed

+519
-41
lines changed

src/EleCho.GoCqHttpSdk.CommandExecuting/CqCommandExecutePostPlugin.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class CqCommandExecutePostPlugin : CommandLineApp
1919
public bool IgnoreCases { get; set; } = true;
2020
public bool AllowGroupMessage { get; set; } = true;
2121
public bool AllowPrivateMessage { get; set; } = true;
22-
public bool ExecuteNextWhenExecuted { get; set; } = false;
22+
public bool ExecuteNextWhenExecuted { get; set; } = true;
2323

2424
private StringComparison GetStringComparison()
2525
{
@@ -30,7 +30,7 @@ public async Task Execute(CqPostContext context, Func<Task> next)
3030
{
3131
if (context is CqMessagePostContext msgContext && msgContext.Message.Text.StartsWith(Prefix))
3232
{
33-
string commandLine =
33+
string commandLine =
3434
msgContext.Message.Text.Substring(Prefix.Length);
3535

3636
if (AllowGroupMessage && context is CqGroupMessagePostContext groupContext)
@@ -45,9 +45,25 @@ public async Task Execute(CqPostContext context, Func<Task> next)
4545
CqMessage response = new CqMessage($"{rst}");
4646

4747
if (ReplyInvoker)
48-
response.WithHead(new CqReplyMsg(msgContext.MessageId));
49-
if (AtInvoker)
50-
response.WithHead(new CqAtMsg(groupContext.UserId));
48+
{
49+
if (AtInvoker)
50+
{
51+
response.WithHead(new CqAtMsg(groupContext.UserId));
52+
response.WithHead(new CqTextMsg(" "));
53+
response.WithHead(new CqReplyMsg(msgContext.MessageId));
54+
}
55+
else
56+
{
57+
response.WithHead(new CqReplyMsg(msgContext.MessageId));
58+
}
59+
}
60+
else
61+
{
62+
if (AtInvoker)
63+
{
64+
response.WithHead(new CqAtMsg(groupContext.UserId));
65+
}
66+
}
5167

5268
await actionSession.SendGroupMessageAsync(groupContext.GroupId, response);
5369
}

src/EleCho.GoCqHttpSdk.CommandExecuting/EleCho.GoCqHttpSdk.CommandExecuting.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net6.0;net7.0;netcoreapp3.1;netstandard2.0;net462</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<LangVersion>latest</LangVersion>
7-
<Version>1.0.2</Version>
7+
<Version>1.0.4</Version>
88
<Description>EleCho.GoCqHttpSdk 的指令执行拓展</Description>
99
<Copyright>Copyright (c) EleCho 2023</Copyright>
1010
<RepositoryUrl>https://github.com/OrgEleCho/EleCho.GoCqHttpSdk</RepositoryUrl>

src/EleCho.GoCqHttpSdk.MessageMatching/EleCho.GoCqHttpSdk.MessageMatching.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net6.0;net7.0;netcoreapp3.1;netstandard2.0;net462</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<LangVersion>latest</LangVersion>
7-
<Version>1.0.2</Version>
7+
<Version>1.0.3</Version>
88
<Description>EleCho.GoCqHttpSdk 的消息匹配拓展</Description>
99
<Copyright>Copyright (c) EleCho 2023</Copyright>
1010
<RepositoryUrl>https://github.com/OrgEleCho/EleCho.GoCqHttpSdk</RepositoryUrl>

src/EleCho.GoCqHttpSdk/Action/CqGetGroupInformationAction.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ namespace EleCho.GoCqHttpSdk.Action
1313
public class CqGetGroupInformationAction : CqAction
1414
{
1515
/// <summary>
16-
/// 实例化对象
16+
/// 实例化对象 (使用缓存)
1717
/// </summary>
1818
/// <param name="groupId">群号</param>
19-
public CqGetGroupInformationAction(long groupId)
20-
{
21-
GroupId = groupId;
22-
NoCache = false;
23-
}
19+
public CqGetGroupInformationAction(long groupId) : this(groupId, false)
20+
{ }
2421

2522
/// <summary>
2623
/// 实例化对象

src/EleCho.GoCqHttpSdk/Action/CqGetGroupListAction.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,29 @@ public class CqGetGroupListAction : CqAction
1212
/// </summary>
1313
public override CqActionType ActionType => CqActionType.GetGroupList;
1414

15+
/// <summary>
16+
/// 是否不使用缓存
17+
/// </summary>
18+
public bool NoCache { get; set; }
19+
20+
/// <summary>
21+
/// 创建实例 (NoCache = false)
22+
/// </summary>
23+
public CqGetGroupListAction() : this(false)
24+
{ }
25+
26+
/// <summary>
27+
/// 创建实例
28+
/// </summary>
29+
/// <param name="noCache">是否不使用缓存</param>
30+
public CqGetGroupListAction(bool noCache)
31+
{
32+
NoCache = noCache;
33+
}
34+
1535
internal override CqActionParamsModel GetParamsModel()
1636
{
17-
return new CqGetGroupListActionParamsModel();
37+
return new CqGetGroupListActionParamsModel(NoCache);
1838
}
1939
}
2040
}

src/EleCho.GoCqHttpSdk/Action/CqGetGroupMemberInformationAction.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@ namespace EleCho.GoCqHttpSdk.Action
1313
public class CqGetGroupMemberInformationAction : CqAction
1414
{
1515
/// <summary>
16-
/// 实例化对象
16+
/// 实例化对象 (NoCache = false)
1717
/// </summary>
1818
/// <param name="groupId">群号</param>
1919
/// <param name="userId">用户 QQ</param>
20-
public CqGetGroupMemberInformationAction(long groupId, long userId)
21-
{
22-
GroupId = groupId;
23-
UserId = userId;
24-
NoCache = false;
25-
}
20+
public CqGetGroupMemberInformationAction(long groupId, long userId) : this(groupId, userId, false)
21+
{ }
2622

2723
/// <summary>
2824
/// 实例化对象
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using EleCho.GoCqHttpSdk.Action.Model.Params;
2+
3+
namespace EleCho.GoCqHttpSdk.Action
4+
{
5+
/// <summary>
6+
/// 获取群成员列表操作
7+
/// </summary>
8+
public class CqGetGroupMemberListAction : CqAction
9+
{
10+
/// <summary>
11+
/// 操作类型: 获取群成员列表
12+
/// </summary>
13+
public override CqActionType ActionType => CqActionType.GetGroupMemberList;
14+
15+
/// <summary>
16+
/// 群号
17+
/// </summary>
18+
public long GroupId { get; }
19+
20+
/// <summary>
21+
/// 不使用缓存
22+
/// </summary>
23+
public bool NoCache { get; }
24+
25+
/// <summary>
26+
/// 实例化对象 (NoCache = false)
27+
/// </summary>
28+
/// <param name="groupId">群号</param>
29+
public CqGetGroupMemberListAction(long groupId) : this(groupId, false)
30+
{ }
31+
32+
/// <summary>
33+
/// 实例化对象
34+
/// </summary>
35+
/// <param name="groupId">群号</param>
36+
/// <param name="noCache">不使用缓存</param>
37+
public CqGetGroupMemberListAction(long groupId, bool noCache)
38+
{
39+
GroupId = groupId;
40+
NoCache = noCache;
41+
}
42+
43+
internal override CqActionParamsModel GetParamsModel()
44+
{
45+
return new CqGetGroupMemberListActionParamsModel(GroupId, NoCache);
46+
}
47+
}
48+
}

src/EleCho.GoCqHttpSdk/Action/CqGetStrangerInformationAction.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ public CqGetStrangerInformationAction(long userId, bool noCache)
3535
}
3636

3737
/// <summary>
38-
/// 实例化对象
38+
/// 实例化对象 (NoCache = false)
3939
/// </summary>
4040
/// <param name="userId">用户 QQ</param>
41-
public CqGetStrangerInformationAction(long userId)
42-
{
43-
UserId = userId;
44-
NoCache = false;
45-
}
41+
public CqGetStrangerInformationAction(long userId) : this(userId, false)
42+
{ }
4643

4744
internal override CqActionParamsModel GetParamsModel()
4845
{

src/EleCho.GoCqHttpSdk/Action/Model/Params/CqGetGroupListActionParamsModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
{
33
internal class CqGetGroupListActionParamsModel : CqActionParamsModel
44
{
5-
// no param
5+
public CqGetGroupListActionParamsModel(bool no_cache)
6+
{
7+
this.no_cache = no_cache;
8+
}
9+
10+
public bool no_cache { get; set; }
611
}
712
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace EleCho.GoCqHttpSdk.Action.Model.Params
2+
{
3+
internal class CqGetGroupMemberListActionParamsModel : CqActionParamsModel
4+
{
5+
public CqGetGroupMemberListActionParamsModel(long group_id, bool no_cache)
6+
{
7+
this.group_id = group_id;
8+
this.no_cache = no_cache;
9+
}
10+
11+
public long group_id { get; }
12+
public bool no_cache { get; }
13+
}
14+
}

0 commit comments

Comments
 (0)