refactor: 重命名 imageServerBaseUrl 为 imageServerPublicIp

This commit is contained in:
sliverp
2026-02-03 14:17:17 +08:00
parent 3c140f5e92
commit 1a5b866f20
5 changed files with 19 additions and 18 deletions

View File

@@ -83,7 +83,7 @@ export const qqbotPlugin: ChannelPlugin<ResolvedQQBotAccount> = {
clientSecret,
clientSecretFile: input.tokenFile,
name: input.name,
imageServerBaseUrl: input.imageServerBaseUrl,
imageServerPublicIp: input.imageServerPublicIp,
});
},
},

View File

@@ -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 } : {}),
},
},
},

View File

@@ -98,15 +98,16 @@ export async function startGateway(ctx: GatewayContext): Promise<void> {
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;

View File

@@ -29,14 +29,14 @@ interface QQBotChannelConfig {
clientSecret?: string;
clientSecretFile?: string;
name?: string;
imageServerBaseUrl?: string;
imageServerPublicIp?: string;
accounts?: Record<string, {
enabled?: boolean;
appId?: string;
clientSecret?: string;
clientSecretFile?: string;
name?: string;
imageServerBaseUrl?: string;
imageServerPublicIp?: string;
}>;
}

View File

@@ -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;
}
/**