Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(qq): add event-id support to <passive> #234

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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