Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
message/message.ts: 解析转发消息中的引用回复
Browse files Browse the repository at this point in the history
  • Loading branch information
SalimTerryLi committed Sep 14, 2022
1 parent 450b84c commit f4cbac0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/message/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export class ForwardMessage implements Forwardable {
time: number
message: MessageElem[]
raw_message: string
source?: Quotable

/** 反序列化一条转发消息 */
static deserialize(serialized: Buffer) {
Expand All @@ -387,6 +388,16 @@ export class ForwardMessage implements Forwardable {
this.parsed = parse(proto[3][1])
this.message = this.parsed.message
this.raw_message = this.parsed.brief
if (this.parsed.quotation) {
const q = this.parsed.quotation
this.source = {
user_id: q[2],
time: q[3],
seq: q[1]?.[0] || q[1],
rand: uuid2rand(q[8]?.[3] || 0),
message: parse(Array.isArray(q[5]) ? q[5] : [q[5]]).brief,
}
}
lock(this, "proto")
lock(this, "parsed")
}
Expand Down

0 comments on commit f4cbac0

Please sign in to comment.