From e8973688fda87460874b0140b4b860d370a4a4fc Mon Sep 17 00:00:00 2001 From: LittleC <26459759+XxLittleCxX@users.noreply.github.com> Date: Thu, 4 Jan 2024 23:05:04 +0800 Subject: [PATCH] feat(qq): emit passive messages' `send` event --- adapters/qq/src/internal/group.ts | 2 ++ adapters/qq/src/message.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/adapters/qq/src/internal/group.ts b/adapters/qq/src/internal/group.ts index 27378af0..fb5b7273 100644 --- a/adapters/qq/src/internal/group.ts +++ b/adapters/qq/src/internal/group.ts @@ -20,6 +20,8 @@ export class GroupInternal { return this.http().post<{ group_code: string msg: string + msg_id: string + timestamp: string } & { code: number message: string diff --git a/adapters/qq/src/message.ts b/adapters/qq/src/message.ts index f921b2d8..91c387ea 100644 --- a/adapters/qq/src/message.ts +++ b/adapters/qq/src/message.ts @@ -238,11 +238,16 @@ export class QQMessageEncoder extends MessageEncode const { sendResult: { msg_id } } = await this.bot.internal.sendPrivateMessage(this.session.channelId, data) session.messageId = msg_id } else { - // FIXME: missing message id const resp = await this.bot.internal.sendMessage(this.session.channelId, data) if (resp.msg !== 'success') { this.bot.logger.warn(resp) } + if (resp.msg_id && resp.msg === 'success') { + session.messageId = resp.msg_id + session.timestamp = new Date(resp.timestamp).valueOf() + session.app.emit(session, 'send', session) + this.results.push(session.event.message) + } if (resp.code === 304023 && this.bot.config.intents & QQ.Intents.MESSAGE_AUDIT) { try { const auditData: QQ.MessageAudited = await this.audit(resp.data.message_audit.audit_id) @@ -260,8 +265,6 @@ export class QQMessageEncoder extends MessageEncode this.bot.logger.warn('[response] %s %o', e.response?.status, e.response?.data) } - // this.results.push(session.event.message) - // session.app.emit(session, 'send', session) this.content = '' this.attachedFile = null this.rows = []