Skip to content

Commit

Permalink
fix message_id type uint to int
Browse files Browse the repository at this point in the history
  • Loading branch information
NepPure committed Jan 16, 2024
1 parent 592761d commit 3e1f2eb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Lagrange.OneBot/Core/Entity/Action/OneBotGetMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
namespace Lagrange.OneBot.Core.Entity.Action.Response;

[Serializable]
public class OneBotGetMessageResponse(DateTime time, string messageType, uint messageId, List<OneBotSegment> message)
public class OneBotGetMessageResponse(DateTime time, string messageType, int messageId, List<OneBotSegment> 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();

Expand Down
4 changes: 2 additions & 2 deletions Lagrange.OneBot/Core/Entity/Message/OneBotGroupMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace Lagrange.OneBot.Core.Entity.Message;

[Serializable]
public class OneBotGroupMsg(uint selfId, uint groupUin, List<OneBotSegment> message, BotGroupMember member, uint messageId) : OneBotEntityBase(selfId, "message")
public class OneBotGroupMsg(uint selfId, uint groupUin, List<OneBotSegment> 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;

Expand Down
2 changes: 1 addition & 1 deletion Lagrange.OneBot/Core/Entity/Message/OneBotPrivateMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
6 changes: 3 additions & 3 deletions Lagrange.OneBot/Database/MessageRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MessageRecord

public List<IMessageEntity> Entities { get; set; } = [];

public uint MessageHash { get; set; }
public int MessageHash { get; set; }

public static explicit operator MessageChain(MessageRecord record)
{
Expand Down Expand Up @@ -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());
}
}
18 changes: 18 additions & 0 deletions Lagrange.OneBot/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net7.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
</Project>

0 comments on commit 3e1f2eb

Please sign in to comment.