Skip to content

Commit

Permalink
[OneBot] Fixed Query of ReplySegment.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Feb 11, 2024
1 parent 1504f10 commit 78e6b6f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Lagrange.OneBot/Core/Message/Entity/ReplySegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MessageRecord>();
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
{
Expand Down

0 comments on commit 78e6b6f

Please sign in to comment.