Skip to content

Commit

Permalink
feat(qq): add event-id support to <passive> (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
XxLittleCxX authored Jan 29, 2024
1 parent 5c0b8d6 commit 1bd24ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions adapters/qq/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class QQGuildMessageEncoder<C extends Context = Context> extends MessageE
private filename: string
fileUrl: string
private passiveId: string
private passiveEventId: string
reference: string
private retry = false
// 先文后图
Expand Down Expand Up @@ -42,6 +43,9 @@ export class QQGuildMessageEncoder<C extends Context = Context> 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)
}
Expand All @@ -63,6 +67,9 @@ export class QQGuildMessageEncoder<C extends Context = Context> 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)
Expand Down Expand Up @@ -167,7 +174,8 @@ export class QQGuildMessageEncoder<C extends Context = Context> 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)
Expand Down Expand Up @@ -381,7 +389,7 @@ export class QQMessageEncoder<C extends Context = Context> 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()
Expand Down
1 change: 1 addition & 0 deletions adapters/qq/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export namespace Message {
}
image?: string
msg_id?: string
event_id?: string
markdown?: Markdown
}
export interface Request {
Expand Down

0 comments on commit 1bd24ac

Please sign in to comment.