From 8de6eb2e33b6cb07e301b90703b0aeeaa2f7c876 Mon Sep 17 00:00:00 2001 From: Dimole Date: Sat, 18 Jun 2022 20:25:57 +0800 Subject: [PATCH] feat: Support nested MultiMsg (#373) --- lib/client.ts | 4 ++-- lib/internal/contactable.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/client.ts b/lib/client.ts index 547ad80c..9acc7d80 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -311,8 +311,8 @@ export class Client extends BaseClient { return this.pickFriend(this.uin).getVideoUrl(fid, md5) } /** 获取转发消息 */ - getForwardMsg(resid: string) { - return this.pickFriend(this.uin).getForwardMsg(resid) + getForwardMsg(resid: string, fileName?: string) { + return this.pickFriend(this.uin).getForwardMsg(resid, fileName) } /** 制作转发消息 */ makeForwardMsg(fake: Forwardable[], dm = false) { diff --git a/lib/internal/contactable.ts b/lib/internal/contactable.ts index 2719fc97..cc7e7297 100644 --- a/lib/internal/contactable.ts +++ b/lib/internal/contactable.ts @@ -487,10 +487,18 @@ export abstract class Contactable { } /** 下载并解析合并转发 */ - async getForwardMsg(resid: string) { + async getForwardMsg(resid: string, fileName: string = "MultiMsg") { const ret = [] const buf = await this._downloadMultiMsg(String(resid), 2) let a = pb.decode(buf)[2] + if (!Array.isArray(a)) a = [a] + for (let b of a) { + const m_fileName = b[1].toString() + if (m_fileName === fileName) { + a = b + break + } + } if (Array.isArray(a)) a = a[0] a = a[2][1] if (!Array.isArray(a)) a = [a]