Skip to content

Commit

Permalink
feat(qq): emit passive messages' send event
Browse files Browse the repository at this point in the history
  • Loading branch information
XxLittleCxX committed Jan 4, 2024
1 parent f6b9c9b commit e897368
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions adapters/qq/src/internal/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions adapters/qq/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,16 @@ export class QQMessageEncoder<C extends Context = Context> 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)
Expand All @@ -260,8 +265,6 @@ export class QQMessageEncoder<C extends Context = Context> 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 = []
Expand Down

0 comments on commit e897368

Please sign in to comment.