Skip to content

Commit

Permalink
[OneBot] [Breaking Change] Completely change type of MessageId
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Feb 12, 2024
1 parent e90131a commit fdbb935
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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 int MessageId { get; set; } = (int)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, string rawMessage, BotGroupMember member, uint messageId) : OneBotEntityBase(selfId, "message")
public class OneBotGroupMsg(uint selfId, uint groupUin, List<OneBotSegment> message, string rawMessage, 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 int MessageId { get; set; } = (int)messageId;
[JsonPropertyName("message_id")] public int MessageId { get; set; } = messageId;

[JsonPropertyName("group_id")] public uint GroupId { get; set; } = groupUin;

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 @@ -23,7 +23,7 @@ public class MessageRecord

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

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

static MessageRecord()
{
Expand Down Expand Up @@ -57,12 +57,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());
}
}

0 comments on commit fdbb935

Please sign in to comment.