From 6ed37b015f6feb671e9a5bde511fb7efda3e01e8 Mon Sep 17 00:00:00 2001 From: DarkRRb <177549718+DarkRRb@users.noreply.github.com> Date: Sun, 10 Nov 2024 15:45:40 +0800 Subject: [PATCH] [Core] fix message id algorithm --- Lagrange.Core/Internal/Packets/Message/C2CRecallMsg.cs | 2 +- .../Internal/Service/Message/RecallFriendMessageService.cs | 2 +- Lagrange.Core/Message/MessageChain.cs | 4 ++-- Lagrange.OneBot/Core/Notify/NotifyService.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lagrange.Core/Internal/Packets/Message/C2CRecallMsg.cs b/Lagrange.Core/Internal/Packets/Message/C2CRecallMsg.cs index cb0dd3c22..a51c5cdd5 100644 --- a/Lagrange.Core/Internal/Packets/Message/C2CRecallMsg.cs +++ b/Lagrange.Core/Internal/Packets/Message/C2CRecallMsg.cs @@ -24,7 +24,7 @@ internal class C2CRecallMsgInfo [ProtoMember(2)] public uint Random { get; set; } - [ProtoMember(3)] public ulong MessageId { get; set; } // 0x1000000 << 32 | Random + [ProtoMember(3)] public ulong MessageId { get; set; } // 0x01000000 << 32 | Random [ProtoMember(4)] public uint Timestamp { get; set; } diff --git a/Lagrange.Core/Internal/Service/Message/RecallFriendMessageService.cs b/Lagrange.Core/Internal/Service/Message/RecallFriendMessageService.cs index a276b93e6..ba0566b18 100644 --- a/Lagrange.Core/Internal/Service/Message/RecallFriendMessageService.cs +++ b/Lagrange.Core/Internal/Service/Message/RecallFriendMessageService.cs @@ -21,7 +21,7 @@ protected override bool Build(RecallFriendMessageEvent input, BotKeystore keysto { ClientSequence = input.ClientSeq, Random = input.Random, - MessageId = 0x1000000UL << 32 | input.Random, + MessageId = 0x01000000UL << 32 | input.Random, Timestamp = input.Timestamp, Field5 = 0, MessageSequence = input.MessageSeq diff --git a/Lagrange.Core/Message/MessageChain.cs b/Lagrange.Core/Message/MessageChain.cs index eb199f1ea..404f379b9 100644 --- a/Lagrange.Core/Message/MessageChain.cs +++ b/Lagrange.Core/Message/MessageChain.cs @@ -48,7 +48,7 @@ internal MessageChain(uint friendUin, string selfUid, string friendUid, uint tar ClientSequence = clientSequence == 0 ? (uint)Random.Shared.Next(100000000, int.MaxValue) : clientSequence; SelfUid = selfUid; Uid = friendUid; - MessageId = messageId ?? (0x10000000ul << 32) | (uint)Random.Shared.Next(100000000, int.MaxValue); + MessageId = messageId ?? (0x01000000ul << 32) | (uint)Random.Shared.Next(100000000, int.MaxValue); Elements = new List(); Type = type; } @@ -58,7 +58,7 @@ internal MessageChain(uint groupUin) GroupUin = groupUin; Sequence = 0; // unuseful at there ClientSequence = 0; - MessageId = (0x10000000ul << 32) | (uint)Random.Shared.Next(100000000, int.MaxValue); + MessageId = (0x01000000ul << 32) | (uint)Random.Shared.Next(100000000, int.MaxValue); Uid = null; Elements = new List(); } diff --git a/Lagrange.OneBot/Core/Notify/NotifyService.cs b/Lagrange.OneBot/Core/Notify/NotifyService.cs index f76942bb0..85eef152f 100644 --- a/Lagrange.OneBot/Core/Notify/NotifyService.cs +++ b/Lagrange.OneBot/Core/Notify/NotifyService.cs @@ -151,7 +151,7 @@ await service.SendJsonAsync(new OneBotGroupRecall(bot.BotUin) var record = collection.FindOne(Query.And( Query.EQ("FriendUin", new BsonValue(@event.FriendUin)), Query.EQ("ClientSequence", new BsonValue(@event.ClientSequence)), - Query.EQ("MessageId", new BsonValue(0x1000000L << 32 | @event.Random)) + Query.EQ("MessageId", new BsonValue(0x01000000L << 32 | @event.Random)) )); await service.SendJsonAsync(new OneBotFriendRecall(bot.BotUin)