Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit 0213909

Browse files
authored
[OneBot] Fix private chat replies do not have an id (#857)
1 parent 569e33f commit 0213909

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Lagrange.OneBot/Message/Entity/ReplySegment.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,19 @@ public override SegmentBase FromEntity(MessageChain chain, IMessageEntity entity
4141
{
4242
if (entity is not ForwardEntity forward || Realm is null) throw new ArgumentException("The entity is not a forward entity.");
4343

44-
var id = Realm.Do(realm => realm.All<MessageRecord>()
45-
.FirstOrDefault(record => record.Id == MessageRecord.CalcMessageHash(forward.MessageId, forward.Sequence))?
46-
.Id);
44+
int? id;
45+
if (chain.IsGroup)
46+
{
47+
id = MessageRecord.CalcMessageHash(forward.MessageId, forward.Sequence);
48+
}
49+
else
50+
{
51+
id = Realm.Do(realm => realm.All<MessageRecord>()
52+
.FirstOrDefault(record => record.FromUinLong == chain.FriendUin
53+
&& record.ClientSequenceLong == forward.ClientSequence)?
54+
.Id);
55+
}
4756

48-
return !id.HasValue
49-
? new ReplySegment { MessageId = 0.ToString() }
50-
: new ReplySegment { MessageId = id.Value.ToString() };
57+
return new ReplySegment { MessageId = (id ?? 0).ToString() };
5158
}
5259
}

0 commit comments

Comments
 (0)