Skip to content

Commit

Permalink
[Core] fix message id algorithm (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkRRb authored Nov 10, 2024
1 parent b540e05 commit ae400c0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Lagrange.Core/Internal/Packets/Message/C2CRecallMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Lagrange.Core/Message/MessageChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Elem>();
Type = type;
}
Expand All @@ -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<Elem>();
}
Expand Down
2 changes: 1 addition & 1 deletion Lagrange.OneBot/Core/Notify/NotifyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ae400c0

Please sign in to comment.