diff --git a/src/channel.ts b/src/channel.ts index 42a9036..819cc3a 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -83,7 +83,7 @@ export const qqbotPlugin: ChannelPlugin = { clientSecret, clientSecretFile: input.tokenFile, name: input.name, - imageServerBaseUrl: input.imageServerBaseUrl, + imageServerPublicIp: input.imageServerPublicIp, }); }, }, diff --git a/src/config.ts b/src/config.ts index dadcdf2..2b65118 100644 --- a/src/config.ts +++ b/src/config.ts @@ -63,7 +63,7 @@ export function resolveQQBotAccount( dmPolicy: qqbot?.dmPolicy, allowFrom: qqbot?.allowFrom, systemPrompt: qqbot?.systemPrompt, - imageServerBaseUrl: qqbot?.imageServerBaseUrl, + imageServerPublicIp: qqbot?.imageServerPublicIp, }; appId = qqbot?.appId ?? ""; } else { @@ -98,7 +98,7 @@ export function resolveQQBotAccount( clientSecret, secretSource, systemPrompt: accountConfig.systemPrompt, - imageServerBaseUrl: accountConfig.imageServerBaseUrl || process.env.QQBOT_IMAGE_SERVER_BASE_URL, + imageServerPublicIp: accountConfig.imageServerPublicIp || process.env.QQBOT_IMAGE_SERVER_PUBLIC_IP, config: accountConfig, }; } @@ -109,7 +109,7 @@ export function resolveQQBotAccount( export function applyQQBotAccountConfig( cfg: MoltbotConfig, accountId: string, - input: { appId?: string; clientSecret?: string; clientSecretFile?: string; name?: string; imageServerBaseUrl?: string } + input: { appId?: string; clientSecret?: string; clientSecretFile?: string; name?: string; imageServerPublicIp?: string } ): MoltbotConfig { const next = { ...cfg }; @@ -126,7 +126,7 @@ export function applyQQBotAccountConfig( ? { clientSecretFile: input.clientSecretFile } : {}), ...(input.name ? { name: input.name } : {}), - ...(input.imageServerBaseUrl ? { imageServerBaseUrl: input.imageServerBaseUrl } : {}), + ...(input.imageServerPublicIp ? { imageServerPublicIp: input.imageServerPublicIp } : {}), }, }; } else { @@ -147,7 +147,7 @@ export function applyQQBotAccountConfig( ? { clientSecretFile: input.clientSecretFile } : {}), ...(input.name ? { name: input.name } : {}), - ...(input.imageServerBaseUrl ? { imageServerBaseUrl: input.imageServerBaseUrl } : {}), + ...(input.imageServerPublicIp ? { imageServerPublicIp: input.imageServerPublicIp } : {}), }, }, }, diff --git a/src/gateway.ts b/src/gateway.ts index fff94fc..98b84ac 100644 --- a/src/gateway.ts +++ b/src/gateway.ts @@ -98,15 +98,16 @@ export async function startGateway(ctx: GatewayContext): Promise { throw new Error("QQBot not configured (missing appId or clientSecret)"); } - // 如果配置了公网 URL,启动图床服务器 + // 如果配置了公网 IP,启动图床服务器 let imageServerBaseUrl: string | null = null; - if (account.imageServerBaseUrl) { - // 使用用户配置的公网地址作为 baseUrl - await ensureImageServer(log, account.imageServerBaseUrl); - imageServerBaseUrl = account.imageServerBaseUrl; + if (account.imageServerPublicIp) { + // 内部组装完整 URL + const publicBaseUrl = `http://${account.imageServerPublicIp}:${IMAGE_SERVER_PORT}`; + await ensureImageServer(log, publicBaseUrl); + imageServerBaseUrl = publicBaseUrl; log?.info(`[qqbot:${account.accountId}] Image server enabled with URL: ${imageServerBaseUrl}`); } else { - log?.info(`[qqbot:${account.accountId}] Image server disabled (no imageServerBaseUrl configured)`); + log?.info(`[qqbot:${account.accountId}] Image server disabled (no imageServerPublicIp configured)`); } let reconnectAttempts = 0; diff --git a/src/onboarding.ts b/src/onboarding.ts index 6310ba1..401c074 100644 --- a/src/onboarding.ts +++ b/src/onboarding.ts @@ -29,14 +29,14 @@ interface QQBotChannelConfig { clientSecret?: string; clientSecretFile?: string; name?: string; - imageServerBaseUrl?: string; + imageServerPublicIp?: string; accounts?: Record; } diff --git a/src/types.ts b/src/types.ts index e185263..00e8a42 100644 --- a/src/types.ts +++ b/src/types.ts @@ -19,8 +19,8 @@ export interface ResolvedQQBotAccount { secretSource: "config" | "file" | "env" | "none"; /** 系统提示词 */ systemPrompt?: string; - /** 图床服务器公网地址 */ - imageServerBaseUrl?: string; + /** 图床服务器公网 IP(内部自动组装成 http://IP:18765) */ + imageServerPublicIp?: string; config: QQBotAccountConfig; } @@ -37,8 +37,8 @@ export interface QQBotAccountConfig { allowFrom?: string[]; /** 系统提示词,会添加在用户消息前面 */ systemPrompt?: string; - /** 图床服务器公网地址,用于发送图片,例如 http://your-ip:18765 */ - imageServerBaseUrl?: string; + /** 图床服务器公网 IP,用于发送图片,例如 1.2.3.4(内部自动组装成 http://IP:18765) */ + imageServerPublicIp?: string; } /**