🐛 fix(plugin): resolve issue causing incorrect message formatting in bot responses

This commit is contained in:
Jerry 2026-01-07 18:33:40 +08:00
parent 27609a7c80
commit a57c9b2c55
3 changed files with 23 additions and 22 deletions

View File

@ -141,7 +141,7 @@ class UserConfigManager {
/** /**
* 清除用户配置缓存 * 清除用户配置缓存
* @param {string} userId - 用户QQ号如果不传则清除所有缓存 * @param {string|null} userId - 用户QQ号如果不传则清除所有缓存
*/ */
clearCache(userId) { clearCache(userId) {
if (userId) { if (userId) {

View File

@ -39,7 +39,7 @@ async function init() {
await fsp.copyFile(pluginDefaultFile, configFile); await fsp.copyFile(pluginDefaultFile, configFile);
logger.mark(`[crystelf-plugin] 默认配置复制成功: ${configFile}`); logger.mark(`[crystelf-plugin] 默认配置复制成功: ${configFile}`);
} catch (copyError) { } catch (copyError) {
logger.warn(`[crystelf-plugin] 复制默认配置失败,创建空配置: ${copyError.message}`); logger.warn(`[crystelf-plugin] 复制默认配置失败,创建空配置: ${copyError}`);
await fc.writeJSON(configFile, {}); await fc.writeJSON(configFile, {});
} }
} }
@ -47,7 +47,7 @@ async function init() {
try { try {
pluginFiles = (await fsp.readdir(pluginConfigPath)).filter((f) => f.endsWith('.json')); pluginFiles = (await fsp.readdir(pluginConfigPath)).filter((f) => f.endsWith('.json'));
} catch (error) { } catch (error) {
logger.warn(`[crystelf-plugin] 读取默认配置目录失败: ${error.message}`); logger.warn(`[crystelf-plugin] 读取默认配置目录失败: ${error}`);
} }
// 复制缺失的配置文件 // 复制缺失的配置文件
@ -61,7 +61,7 @@ async function init() {
await fsp.copyFile(pluginFilePath, dataFilePath); await fsp.copyFile(pluginFilePath, dataFilePath);
logger.mark(`[crystelf-plugin] 配置文件缺失,已复制: ${file}`); logger.mark(`[crystelf-plugin] 配置文件缺失,已复制: ${file}`);
} catch (copyError) { } catch (copyError) {
logger.warn(`[crystelf-plugin] 复制配置文件失败 ${file}: ${copyError.message}`); logger.warn(`[crystelf-plugin] 复制配置文件失败 ${file}: ${copyError}`);
} }
} }
} }
@ -99,6 +99,7 @@ async function init() {
await fc.writeJSON(filePath, data); await fc.writeJSON(filePath, data);
} catch (mergeError) { } catch (mergeError) {
logger.error('[crystelf-plugin]合并配置失败..'); logger.error('[crystelf-plugin]合并配置失败..');
logger.error(mergeError);
// 忽略合并错误,使用现有数据 // 忽略合并错误,使用现有数据
} }
@ -137,7 +138,7 @@ function watchConfigs() {
const data = await fc.readJSON(filePath); const data = await fc.readJSON(filePath);
const name = path.basename(file, '.json'); const name = path.basename(file, '.json');
configCache[name] = data; configCache[name] = data;
logger.info(`[crystelf-plugin] 配置热更新: ${file}`); logger.info(`[crystelf-plugin] 配置热更新: ${file}`);
} catch (e) { } catch (e) {
logger.warn(`[crystelf-plugin] 热更新读取失败 ${file}:`, e); logger.warn(`[crystelf-plugin] 热更新读取失败 ${file}:`, e);
} }
@ -176,7 +177,7 @@ const configControl = {
await fc.writeJSON(filePath, value); await fc.writeJSON(filePath, value);
logger.mark(`[crystelf-plugin] 创建新配置文件: ${filePath}`); logger.mark(`[crystelf-plugin] 创建新配置文件: ${filePath}`);
} catch (writeError) { } catch (writeError) {
logger.error(`[crystelf-plugin] 创建配置文件失败: ${writeError.message}`); logger.error(`[crystelf-plugin] 创建配置文件失败: ${writeError}`);
throw writeError; throw writeError;
} }
} }
@ -199,7 +200,7 @@ const configControl = {
// 写入配置文件 // 写入配置文件
await fc.writeJSON(filePath, value); await fc.writeJSON(filePath, value);
} catch (error) { } catch (error) {
logger.error(`[crystelf-plugin] 设置配置失败 ${key}: ${error.message}`); logger.error(`[crystelf-plugin] 设置配置失败 ${key}: ${error}`);
throw error; throw error;
} }
} }
@ -216,7 +217,7 @@ const configControl = {
// 直接写入配置文件 // 直接写入配置文件
await fc.writeJSON(filePath, value); await fc.writeJSON(filePath, value);
} catch (error) { } catch (error) {
logger.error(`[crystelf-plugin] 保存配置文件失败 ${filePath}: ${error.message}`); logger.error(`[crystelf-plugin] 保存配置文件失败 ${filePath}: ${error}`);
throw error; throw error;
} }
} }

BIN
resources/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB