From 78e6b6f170267a9a96ba89b077d32e9766330b65 Mon Sep 17 00:00:00 2001 From: Linwenxuan <116782992+Linwenxuan05@users.noreply.github.com> Date: Sun, 11 Feb 2024 22:43:16 +0800 Subject: [PATCH] [OneBot] Fixed Query of ReplySegment.cs --- Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs b/Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs index e36777589..aba4edd28 100644 --- a/Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs +++ b/Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs @@ -34,10 +34,16 @@ public override SegmentBase FromEntity(MessageChain chain, IMessageEntity entity { if (entity is not ForwardEntity forward || Database is null) throw new ArgumentException("The entity is not a forward entity."); + var collection = Database.GetCollection(); - var target = chain.IsGroup - ? collection.FindOne(x => x.Sequence == forward.Sequence && x.GroupUin == chain.GroupUin) - : collection.FindOne(x => x.Sequence == forward.Sequence && x.FriendUin == chain.FriendUin); + + uint friendUin = chain.FriendUin; // such action is to break the BsonExpression from MessageChain into uint + uint groupUin = chain.GroupUin ?? 0; + + var query = chain.IsGroup + ? collection.Query().Where(x => x.Sequence == forward.Sequence).Where(x => x.GroupUin == groupUin) + : collection.Query().Where(x => x.Sequence == forward.Sequence).Where(x => x.FriendUin == friendUin); + var target = query.First(); return new ReplySegment {