From 1bd24acb323058e7fd391a4e7d37117a066e7380 Mon Sep 17 00:00:00 2001 From: _LittleC_ <26459759+XxLittleCxX@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:50:53 +0800 Subject: [PATCH] feat(qq): add `event-id` support to `` (#234) --- adapters/qq/src/message.ts | 12 ++++++++++-- adapters/qq/src/types.ts | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/adapters/qq/src/message.ts b/adapters/qq/src/message.ts index b0b46dea..196f24f9 100644 --- a/adapters/qq/src/message.ts +++ b/adapters/qq/src/message.ts @@ -15,6 +15,7 @@ export class QQGuildMessageEncoder extends MessageE private filename: string fileUrl: string private passiveId: string + private passiveEventId: string reference: string private retry = false // 先文后图 @@ -42,6 +43,9 @@ export class QQGuildMessageEncoder extends MessageE if (this.options?.session && msg_id) { form.append('msg_id', msg_id) } + if (this.passiveEventId) { + form.append('event_id', this.passiveEventId) + } if (this.file) { form.append('file_image', this.file, this.filename) } @@ -63,6 +67,9 @@ export class QQGuildMessageEncoder extends MessageE message_id: this.reference, }, } : {}), + ...(this.passiveEventId ? { + event_id: this.passiveEventId, + } : {}), } if (isDirect) r = await this.bot.internal.sendDM(this.channelId.split('_')[0], payload) else r = await this.bot.internal.sendMessage(this.channelId, payload) @@ -167,7 +174,8 @@ export class QQGuildMessageEncoder extends MessageE this.reference = attrs.id await this.flush() } else if (type === 'passive') { - this.passiveId = attrs.id + if (attrs.messageId) this.passiveId = attrs.messageId + if (attrs.eventId) this.passiveEventId = attrs.eventId } else if ((type === 'img' || type === 'image') && (attrs.src || attrs.url)) { await this.flush() await this.resolveFile(attrs) @@ -381,7 +389,7 @@ export class QQMessageEncoder extends MessageEncode if (type === 'text') { this.content += attrs.content } else if (type === 'passive') { - this.passiveId = attrs.id + this.passiveId = attrs.messageId this.passiveSeq = Number(attrs.seq) } else if ((type === 'img' || type === 'image') && (attrs.src || attrs.url)) { await this.flush() diff --git a/adapters/qq/src/types.ts b/adapters/qq/src/types.ts index 78722da7..2f1d0e55 100644 --- a/adapters/qq/src/types.ts +++ b/adapters/qq/src/types.ts @@ -388,6 +388,7 @@ export namespace Message { } image?: string msg_id?: string + event_id?: string markdown?: Markdown } export interface Request {