From 3e1f2ebb6656c35c62894aeb2b1fcff98f2f46b4 Mon Sep 17 00:00:00 2001 From: NepPure Date: Tue, 16 Jan 2024 18:16:28 +0800 Subject: [PATCH] fix message_id type uint to int --- .../Core/Entity/Action/OneBotGetMessage.cs | 2 +- .../Response/OneBotGetMessageResponse.cs | 6 +++--- .../Core/Entity/Message/OneBotGroupMsg.cs | 4 ++-- .../Core/Entity/Message/OneBotPrivateMsg.cs | 2 +- Lagrange.OneBot/Database/MessageRecord.cs | 6 +++--- .../PublishProfiles/FolderProfile.pubxml | 18 ++++++++++++++++++ 6 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 Lagrange.OneBot/Properties/PublishProfiles/FolderProfile.pubxml diff --git a/Lagrange.OneBot/Core/Entity/Action/OneBotGetMessage.cs b/Lagrange.OneBot/Core/Entity/Action/OneBotGetMessage.cs index 40471b200..b8b1e594d 100644 --- a/Lagrange.OneBot/Core/Entity/Action/OneBotGetMessage.cs +++ b/Lagrange.OneBot/Core/Entity/Action/OneBotGetMessage.cs @@ -5,5 +5,5 @@ namespace Lagrange.OneBot.Core.Entity.Action; [Serializable] public class OneBotGetMessage { - [JsonPropertyName("message_id")] public uint MessageId { get; set; } + [JsonPropertyName("message_id")] public int MessageId { get; set; } } \ No newline at end of file diff --git a/Lagrange.OneBot/Core/Entity/Action/Response/OneBotGetMessageResponse.cs b/Lagrange.OneBot/Core/Entity/Action/Response/OneBotGetMessageResponse.cs index 6e3ce6168..a3297b334 100644 --- a/Lagrange.OneBot/Core/Entity/Action/Response/OneBotGetMessageResponse.cs +++ b/Lagrange.OneBot/Core/Entity/Action/Response/OneBotGetMessageResponse.cs @@ -4,15 +4,15 @@ namespace Lagrange.OneBot.Core.Entity.Action.Response; [Serializable] -public class OneBotGetMessageResponse(DateTime time, string messageType, uint messageId, List message) +public class OneBotGetMessageResponse(DateTime time, string messageType, int messageId, List message) { [JsonPropertyName("time")] public int Time { get; set; } = (int)(time - DateTime.UnixEpoch).TotalSeconds; [JsonPropertyName("message_type")] public string MessageType { get; set; } = messageType; - [JsonPropertyName("message_id")] public uint MessageId { get; set; } = messageId; + [JsonPropertyName("message_id")] public int MessageId { get; set; } = messageId; - [JsonPropertyName("real_id")] public uint RealId { get; set; } = messageId; + [JsonPropertyName("real_id")] public int RealId { get; set; } = messageId; [JsonPropertyName("sender")] public OneBotSender Sender { get; set; } = new(); diff --git a/Lagrange.OneBot/Core/Entity/Message/OneBotGroupMsg.cs b/Lagrange.OneBot/Core/Entity/Message/OneBotGroupMsg.cs index d6a03dc30..38965876e 100644 --- a/Lagrange.OneBot/Core/Entity/Message/OneBotGroupMsg.cs +++ b/Lagrange.OneBot/Core/Entity/Message/OneBotGroupMsg.cs @@ -5,13 +5,13 @@ namespace Lagrange.OneBot.Core.Entity.Message; [Serializable] -public class OneBotGroupMsg(uint selfId, uint groupUin, List message, BotGroupMember member, uint messageId) : OneBotEntityBase(selfId, "message") +public class OneBotGroupMsg(uint selfId, uint groupUin, List message, BotGroupMember member, int messageId) : OneBotEntityBase(selfId, "message") { [JsonPropertyName("message_type")] public string MessageType { get; set; } = "group"; [JsonPropertyName("sub_type")] public string SubType { get; set; } = "normal"; - [JsonPropertyName("message_id")] public uint MessageId { get; set; } = messageId; + [JsonPropertyName("message_id")] public int MessageId { get; set; } = messageId; [JsonPropertyName("group_id")] public uint GroupId { get; set; } = groupUin; diff --git a/Lagrange.OneBot/Core/Entity/Message/OneBotPrivateMsg.cs b/Lagrange.OneBot/Core/Entity/Message/OneBotPrivateMsg.cs index 209c74d30..c03b04cbe 100644 --- a/Lagrange.OneBot/Core/Entity/Message/OneBotPrivateMsg.cs +++ b/Lagrange.OneBot/Core/Entity/Message/OneBotPrivateMsg.cs @@ -10,7 +10,7 @@ public class OneBotPrivateMsg(uint selfId) : OneBotEntityBase(selfId, "message") [JsonPropertyName("sub_type")] public string SubType { get; } = "friend"; - [JsonPropertyName("message_id")] public uint MessageId { get; set; } + [JsonPropertyName("message_id")] public int MessageId { get; set; } [JsonPropertyName("user_id")] public uint UserId { get; set; } diff --git a/Lagrange.OneBot/Database/MessageRecord.cs b/Lagrange.OneBot/Database/MessageRecord.cs index 278526f64..f6cc33458 100644 --- a/Lagrange.OneBot/Database/MessageRecord.cs +++ b/Lagrange.OneBot/Database/MessageRecord.cs @@ -22,7 +22,7 @@ public class MessageRecord public List Entities { get; set; } = []; - public uint MessageHash { get; set; } + public int MessageHash { get; set; } public static explicit operator MessageChain(MessageRecord record) { @@ -51,12 +51,12 @@ public static explicit operator MessageChain(MessageRecord record) MessageHash = CalcMessageHash(chain.MessageId, chain.Sequence) }; - private static uint CalcMessageHash(ulong msgId, uint seq) + private static int CalcMessageHash(ulong msgId, uint seq) { var messageId = BitConverter.GetBytes(msgId); var sequence = BitConverter.GetBytes(seq); byte[] id = [messageId[0], messageId[1], sequence[0], sequence[1]]; - return BitConverter.ToUInt32(id.AsSpan()); + return BitConverter.ToInt32(id.AsSpan()); } } \ No newline at end of file diff --git a/Lagrange.OneBot/Properties/PublishProfiles/FolderProfile.pubxml b/Lagrange.OneBot/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 000000000..69cd946a8 --- /dev/null +++ b/Lagrange.OneBot/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,18 @@ + + + + + Release + Any CPU + bin\Release\net7.0\publish\win-x64\ + FileSystem + <_TargetId>Folder + net7.0 + win-x64 + false + true + false + + \ No newline at end of file