feat(bym): 添加默认配置并优化文件夹创建逻辑

This commit is contained in:
ycxom 2024-12-31 14:22:53 +08:00
parent 3e70ae88dc
commit aec89ef10f
2 changed files with 40 additions and 3 deletions

View file

@ -25,6 +25,26 @@ import pathModule from 'path';
const _path = process.cwd();
const path = _path + "/temp/tp-bq";
const DefaultConfig = {
returnQQ: [],
GroupList: [],
UserList: [],
enableBYM: true,
assistantLabel: ["ChatGPT"],
bymPreset: [],
bymFuckPrompt: "",
blockWords: [],
AutoToDownImg: false,
debug: false
}
if (!fs.existsSync(path)) {
fs.mkdirSync(path, { recursive: true })
}
if (!fs.existsSync(pathModule.join(path, 'pictures'))) {
fs.mkdirSync(pathModule.join(path, 'pictures'), { recursive: true })
}
// 轻微黑名单用户
let RoleFalseUser = []
@ -45,6 +65,19 @@ export class bym extends plugin {
}
]
})
if (typeof Config.assistantLabel === 'string') {
Config.assistantLabel = [Config.assistantLabel]
}
Config.assistantLabel = Config.assistantLabel || DefaultConfig.assistantLabel
Config.returnQQ = Config.returnQQ || DefaultConfig.returnQQ
Config.GroupList = Config.GroupList || DefaultConfig.GroupList
Config.UserList = Config.UserList || DefaultConfig.UserList
Config.enableBYM = Config.enableBYM ?? DefaultConfig.enableBYM
Config.bymPreset = Config.bymPreset || DefaultConfig.bymPreset
Config.bymFuckPrompt = Config.bymFuckPrompt || DefaultConfig.bymFuckPrompt
Config.blockWords = Config.blockWords || DefaultConfig.blockWords
Config.AutoToDownImg = Config.AutoToDownImg ?? DefaultConfig.AutoToDownImg
Config.debug = Config.debug ?? DefaultConfig.debug
}
/** 复读 */
@ -417,11 +450,11 @@ export class bym extends plugin {
let finalMsg = await convertFaces(t, true, e)
logger.info(JSON.stringify(finalMsg))
if (Math.floor(Math.random() * 100) < 10) {
await this.reply(finalMsg, true, {
await e.reply(finalMsg, true, {
recallMsg: RecallMsg ? 10 : 0
})
} else {
await this.reply(finalMsg, false, {
await e.reply(finalMsg, false, {
recallMsg: RecallMsg ? 10 : 0
})
}

View file

@ -16,16 +16,20 @@
"eventsource": "^2.0.2",
"eventsource-parser": "^1.0.0",
"fastify": "^4.18.0",
"file-type": "^19.6.0",
"form-data": "^4.0.0",
"fs": "0.0.1-security",
"https-proxy-agent": "7.0.1",
"js-tiktoken": "^1.0.5",
"keyv": "^4.5.3",
"keyv-file": "^0.2.0",
"lodash": "^4.17.21",
"microsoft-cognitiveservices-speech-sdk": "1.32.0",
"moment": "^2.30.1",
"node-fetch": "^3.3.1",
"openai": "^3.2.1",
"p-timeout": "^6.1.2",
"path": "^0.12.7",
"quick-lru": "6.1.1",
"random": "^4.1.0",
"undici": "^5.21.0",