diff --git a/adapters/qq/src/message.ts b/adapters/qq/src/message.ts index 4bf0ca2b..8ae4db45 100644 --- a/adapters/qq/src/message.ts +++ b/adapters/qq/src/message.ts @@ -2,7 +2,6 @@ import * as QQ from './types' import { Context, Dict, h, MessageEncoder, Quester } from '@satorijs/satori' import { QQBot } from './bot' import FormData from 'form-data' -import { escape } from '@satorijs/element' import { QQGuildBot } from './bot/guild' import { Entry } from '@satorijs/server-temp' @@ -111,7 +110,7 @@ export class QQGuildMessageEncoder extends MessageE async visit(element: h) { const { type, attrs, children } = element if (type === 'text') { - this.content += escape(attrs.content) + this.content += attrs.content } else if (type === 'at') { switch (attrs.type) { case 'all': @@ -297,7 +296,7 @@ export class QQMessageEncoder extends MessageEncode async visit(element: h) { const { type, attrs, children } = element if (type === 'text') { - this.content += escape(attrs.content) + this.content += attrs.content } else if (type === 'image' && attrs.url) { await this.flush() const data = await this.sendFile(type, attrs) @@ -307,6 +306,12 @@ export class QQMessageEncoder extends MessageEncode const data = await this.sendFile(type, attrs) if (data) this.attachedFile = data await this.flush() // text can't send with video + } else if (type === 'br') { + this.content += '\n' + } else if (type === 'p') { + if (!this.content.endsWith('\n')) this.content += '\n' + await this.render(children) + if (!this.content.endsWith('\n')) this.content += '\n' } else if (type === 'button-group') { this.useMarkdown = true this.rows.push([]) diff --git a/adapters/qq/src/types.ts b/adapters/qq/src/types.ts index 75c82dee..80cfc2f3 100644 --- a/adapters/qq/src/types.ts +++ b/adapters/qq/src/types.ts @@ -1233,13 +1233,14 @@ export interface Interaction { timestamp: string guild_id: string channel_id: string - group_open_id: string + group_openid: string + group_member_openid: string chat_type: ChatType data: { resolved: { button_data: string button_id: string - user_id: string + user_id?: string } } version: 1 diff --git a/adapters/qq/src/utils.ts b/adapters/qq/src/utils.ts index 790e9fa2..e9424def 100644 --- a/adapters/qq/src/utils.ts +++ b/adapters/qq/src/utils.ts @@ -192,10 +192,10 @@ export async function adaptSession(bot: QQBot, i session.operatorId = input.d.op_member_openid } else if (input.t === 'INTERACTION_CREATE') { session.type = 'interaction/button' - session.userId = input.d.data.resolved.user_id + session.userId = input.d.group_member_openid ?? input.d.data.resolved.user_id if (input.d.chat_type === QQ.ChatType.GROUP) { - session.guildId = input.d.group_open_id - session.channelId = input.d.group_open_id + session.guildId = input.d.group_openid + session.channelId = input.d.group_openid session.isDirect = false } else if (input.d.chat_type === QQ.ChatType.CHANNEL) { session.channelId = input.d.channel_id