diff --git a/plugins/adapter/qqguild/src/bot.ts b/plugins/adapter/qqguild/src/bot.ts index 0b9f198afb..8c633cfc2b 100644 --- a/plugins/adapter/qqguild/src/bot.ts +++ b/plugins/adapter/qqguild/src/bot.ts @@ -53,7 +53,15 @@ export class QQGuildBot extends Bot { session.content = (msg.content ?? '') .replace(/<@!(.+)>/, (_, $1) => segment.at($1)) .replace(/<#(.+)>/, (_, $1) => segment.sharp($1)) - session.content = (msg as any as { attachments: any[] }).attachments + const { attachments = [] } = msg as any as { attachments?: any[] } + if (attachments.length > 0) { + session.content += attachments.map((attachment) => { + if (attachment.contentType.startsWith('image')) { + return segment.image(attachment.url) + } + }).join('') + } + session.content = attachments .filter(({ contentType }) => contentType.startsWith('image')) .reduce((content, attachment) => content + segment.image(attachment.url), session.content) return new Session(this, session) diff --git a/plugins/adapter/qqguild/src/ws.ts b/plugins/adapter/qqguild/src/ws.ts index da2b129940..7cb4e00342 100644 --- a/plugins/adapter/qqguild/src/ws.ts +++ b/plugins/adapter/qqguild/src/ws.ts @@ -10,9 +10,8 @@ export class WebSocketClient extends Adapter { async connect(bot: QQGuildBot) { Object.assign(bot, await bot.getSelf()) - bot.resolve() await bot.$innerBot.startClient(bot.config.intents) - bot.$innerBot.on('ready', bot.resolve) + bot.$innerBot.on('ready', bot.resolve.bind(bot)) bot.$innerBot.on('message', msg => { const session = bot.adaptMessage(msg) if (session) {