From 56fe199a01a1ec8806d2d78bda9db69441a98bd2 Mon Sep 17 00:00:00 2001 From: df1050 Date: Sun, 31 Mar 2024 20:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=85=A7=E7=9D=80a50c139=E5=92=8Ca4b5402?= =?UTF-8?q?=E5=9B=9E=E9=80=80=E4=BA=86=E6=9B=B4=E6=94=B9=EF=BC=8C=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E8=A7=A3=E5=86=B3=EF=BC=8C=E5=A4=A7=E6=A6=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EleCho.GoCqHttpSdk/Post/Base/CqMessagePostContext.cs | 7 ------- src/EleCho.GoCqHttpSdk/Post/CqGroupMessagePostContext.cs | 7 ++++++- src/EleCho.GoCqHttpSdk/Post/CqPrivateMessagePostContext.cs | 5 +++++ .../Post/Model/Base/CqMessagePostModel.cs | 2 -- .../Post/Model/CqGroupMessagePostModel.cs | 1 + .../Post/Model/CqPrivateMessagePostModel.cs | 1 + 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/EleCho.GoCqHttpSdk/Post/Base/CqMessagePostContext.cs b/src/EleCho.GoCqHttpSdk/Post/Base/CqMessagePostContext.cs index 0c13277..8fc15c7 100644 --- a/src/EleCho.GoCqHttpSdk/Post/Base/CqMessagePostContext.cs +++ b/src/EleCho.GoCqHttpSdk/Post/Base/CqMessagePostContext.cs @@ -33,12 +33,6 @@ public abstract record class CqMessagePostContext : CqPostContext /// public long UserId { get; internal set; } - /// - /// 发送者 - /// - //对我没初始化但这是个abstract class并且派生类型都初始化了这个所以没问题...吧... -by gdr2333 - public CqMessageSender Sender { get; internal set; } = new CqMessageSender(); - /// /// 消息实例 /// @@ -66,7 +60,6 @@ internal override void ReadModel(CqPostModel model) Message = new CqMessage(msgModel.message.Select(CqMsg.FromModel)); RawMessage = msgModel.raw_message; Font = msgModel.font; - Sender = new CqMessageSender(msgModel.sender); } } } \ No newline at end of file diff --git a/src/EleCho.GoCqHttpSdk/Post/CqGroupMessagePostContext.cs b/src/EleCho.GoCqHttpSdk/Post/CqGroupMessagePostContext.cs index 76571cd..537ec38 100644 --- a/src/EleCho.GoCqHttpSdk/Post/CqGroupMessagePostContext.cs +++ b/src/EleCho.GoCqHttpSdk/Post/CqGroupMessagePostContext.cs @@ -23,7 +23,11 @@ public record class CqGroupMessagePostContext : CqMessagePostContext, IGroupPost /// 匿名对象 /// public CqAnonymousInfomation? Anonymous { get; internal set; } - + /// + /// 发送者 + /// + public CqGroupMessageSender Sender { get; internal set; } = new CqGroupMessageSender(); + internal CqGroupMessagePostContext() { } /// @@ -42,6 +46,7 @@ internal override void ReadModel(CqPostModel model) GroupId = msgModel.group_id; Anonymous = msgModel.anonymous == null ? null : new CqAnonymousInfomation(msgModel.anonymous); + Sender = new CqGroupMessageSender(msgModel.sender); } } } \ No newline at end of file diff --git a/src/EleCho.GoCqHttpSdk/Post/CqPrivateMessagePostContext.cs b/src/EleCho.GoCqHttpSdk/Post/CqPrivateMessagePostContext.cs index 75bf868..ec6777a 100644 --- a/src/EleCho.GoCqHttpSdk/Post/CqPrivateMessagePostContext.cs +++ b/src/EleCho.GoCqHttpSdk/Post/CqPrivateMessagePostContext.cs @@ -25,6 +25,10 @@ public partial record class CqPrivateMessagePostContext : CqMessagePostContext /// 临时会话来源 /// public CqTempSource TempSource { get; internal set; } + /// + /// 发送者 + /// + public CqMessageSender Sender { get; internal set; } = new CqMessageSender(); internal CqPrivateMessagePostContext() { } @@ -44,6 +48,7 @@ internal override void ReadModel(CqPostModel model) PrivateMessageType = CqEnum.GetPrivateMessageType(msgModel.sub_type); TempSource = (CqTempSource)msgModel.temp_source; + Sender = new CqMessageSender(msgModel.sender); } } } \ No newline at end of file diff --git a/src/EleCho.GoCqHttpSdk/Post/Model/Base/CqMessagePostModel.cs b/src/EleCho.GoCqHttpSdk/Post/Model/Base/CqMessagePostModel.cs index 60be26c..dd25a46 100644 --- a/src/EleCho.GoCqHttpSdk/Post/Model/Base/CqMessagePostModel.cs +++ b/src/EleCho.GoCqHttpSdk/Post/Model/Base/CqMessagePostModel.cs @@ -1,7 +1,6 @@ #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. #pragma warning disable IDE1006 // Naming Styles -using EleCho.GoCqHttpSdk.DataStructure.Model; using EleCho.GoCqHttpSdk.Message.DataModel; namespace EleCho.GoCqHttpSdk.Post.Model @@ -17,6 +16,5 @@ internal abstract class CqMessagePostModel : CqPostModel public CqMsgModel[] message { get; set; } public string raw_message { get; set; } public int font { get; set; } - public CqMessageSenderModel sender { get; set; } } } \ No newline at end of file diff --git a/src/EleCho.GoCqHttpSdk/Post/Model/CqGroupMessagePostModel.cs b/src/EleCho.GoCqHttpSdk/Post/Model/CqGroupMessagePostModel.cs index adc76e6..c5202df 100644 --- a/src/EleCho.GoCqHttpSdk/Post/Model/CqGroupMessagePostModel.cs +++ b/src/EleCho.GoCqHttpSdk/Post/Model/CqGroupMessagePostModel.cs @@ -11,5 +11,6 @@ internal class CqGroupMessagePostModel : CqMessagePostModel public long group_id { get; set; } public CqAnonymousInformationModel? anonymous { get; set; } + public CqGroupMessageSenderModel sender { get; set; } } } \ No newline at end of file diff --git a/src/EleCho.GoCqHttpSdk/Post/Model/CqPrivateMessagePostModel.cs b/src/EleCho.GoCqHttpSdk/Post/Model/CqPrivateMessagePostModel.cs index d09aa14..6dc8d3f 100644 --- a/src/EleCho.GoCqHttpSdk/Post/Model/CqPrivateMessagePostModel.cs +++ b/src/EleCho.GoCqHttpSdk/Post/Model/CqPrivateMessagePostModel.cs @@ -13,5 +13,6 @@ internal class CqPrivateMessagePostModel : CqMessagePostModel /// /// public int temp_source { get; set; } + public CqMessageSenderModel sender { get; set; } } } \ No newline at end of file