From d2d4444f9a7a31680dd3f70977d996786a0aa483 Mon Sep 17 00:00:00 2001 From: LittleC <26459759+XxLittleCxX@users.noreply.github.com> Date: Thu, 25 Jan 2024 23:55:06 +0800 Subject: [PATCH 1/2] feat(qq): add `event-id` support to `` --- adapters/qq/src/message.ts | 11 ++++++++++- adapters/qq/src/types.ts | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/adapters/qq/src/message.ts b/adapters/qq/src/message.ts index b0b46dea..4aee62de 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) } @@ -57,12 +61,16 @@ export class QQGuildMessageEncoder extends MessageE content: this.content, msg_id, image: this.fileUrl, + }, ...(this.reference ? { message_reference: { 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 +175,8 @@ export class QQGuildMessageEncoder extends MessageE this.reference = attrs.id await this.flush() } else if (type === 'passive') { - this.passiveId = attrs.id + if (attrs.id) this.passiveId = attrs.id + if (attrs.eventId) this.passiveEventId = attrs.eventId } else if ((type === 'img' || type === 'image') && (attrs.src || attrs.url)) { await this.flush() await this.resolveFile(attrs) 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 { From fbe13ef667e7b6109823c6470e6e593cd867028b Mon Sep 17 00:00:00 2001 From: LittleC <26459759+XxLittleCxX@users.noreply.github.com> Date: Mon, 29 Jan 2024 21:09:35 +0800 Subject: [PATCH 2/2] feat(qq): rename `` attribute --- adapters/qq/src/message.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/adapters/qq/src/message.ts b/adapters/qq/src/message.ts index 4aee62de..196f24f9 100644 --- a/adapters/qq/src/message.ts +++ b/adapters/qq/src/message.ts @@ -61,7 +61,6 @@ export class QQGuildMessageEncoder extends MessageE content: this.content, msg_id, image: this.fileUrl, - }, ...(this.reference ? { message_reference: { @@ -175,7 +174,7 @@ export class QQGuildMessageEncoder extends MessageE this.reference = attrs.id await this.flush() } else if (type === 'passive') { - if (attrs.id) 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() @@ -390,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()