Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Lagrange.OneBot/Message/Entity/ReplySegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ public override SegmentBase FromEntity(MessageChain chain, IMessageEntity entity
{
if (entity is not ForwardEntity forward || Realm is null) throw new ArgumentException("The entity is not a forward entity.");

var id = Realm.Do(realm => realm.All<MessageRecord>()
.FirstOrDefault(record => record.Id == MessageRecord.CalcMessageHash(forward.MessageId, forward.Sequence))?
.Id);
int? id;
if (chain.IsGroup)
Copy link

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the group vs. private chat ID resolution logic into a dedicated helper method to reduce complexity in FromEntity.

Copilot uses AI. Check for mistakes.

{
id = MessageRecord.CalcMessageHash(forward.MessageId, forward.Sequence);
}
else
{
id = Realm.Do(realm => realm.All<MessageRecord>()
.FirstOrDefault(record => record.FromUinLong == chain.FriendUin
&& record.ClientSequenceLong == forward.ClientSequence)?
.Id);
}

return !id.HasValue
? new ReplySegment { MessageId = 0.ToString() }
: new ReplySegment { MessageId = id.Value.ToString() };
return new ReplySegment { MessageId = (id ?? 0).ToString() };
}
}