Skip to content

Commit

Permalink
feat(qq): add event-id support to <passive>
Browse files Browse the repository at this point in the history
  • Loading branch information
XxLittleCxX committed Jan 25, 2024
1 parent 92c471b commit d2d4444
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion 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 @@ -57,12 +61,16 @@ export class QQGuildMessageEncoder<C extends Context = Context> 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)
Expand Down Expand Up @@ -167,7 +175,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.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)
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 d2d4444

Please sign in to comment.