From aec89ef10f8f0ba1c94ccbd81d362a09e3a04ea9 Mon Sep 17 00:00:00 2001 From: ycxom Date: Tue, 31 Dec 2024 14:22:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(bym):=20=E6=B7=BB=E5=8A=A0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=85=8D=E7=BD=AE=E5=B9=B6=E4=BC=98=E5=8C=96=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/bym.js | 39 ++++++++++++++++++++++++++++++++++++--- package.json | 4 ++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/apps/bym.js b/apps/bym.js index 8d5bffa..61c9ac3 100644 --- a/apps/bym.js +++ b/apps/bym.js @@ -16,7 +16,7 @@ import { EditCardTool } from '../utils/tools/EditCardTool.js' import { JinyanTool } from '../utils/tools/JinyanTool.js' import { KickOutTool } from '../utils/tools/KickOutTool.js' import { SetTitleTool } from '../utils/tools/SetTitleTool.js' -import {SerpTool} from '../utils/tools/SerpTool.js' +import { SerpTool } from '../utils/tools/SerpTool.js' import fs from "fs"; import { fileTypeFromBuffer } from 'file-type'; @@ -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 }) } diff --git a/package.json b/package.json index c6bc357..20f7b3a 100644 --- a/package.json +++ b/package.json @@ -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",