From 8bdbd623b328222fde32176a01349af44f571009 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Wed, 12 Apr 2023 20:03:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20at=E9=83=BD=E8=A2=AB=E6=8C=A4=E5=88=B0?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=9C=80=E5=89=8D=E9=9D=A2=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LowerNode.md | 36 ------------------------------------ Redis.md | 8 -------- apps/entertainment.js | 2 +- apps/management.js | 1 - utils/config.js | 2 +- utils/dalle.js | 5 ++--- utils/face.js | 4 ++++ utils/randomMessage.js | 1 - utils/tts.js | 2 +- utils/uploadRecord.js | 10 +++++++++- 10 files changed, 18 insertions(+), 53 deletions(-) delete mode 100644 LowerNode.md delete mode 100644 Redis.md diff --git a/LowerNode.md b/LowerNode.md deleted file mode 100644 index 1233068..0000000 --- a/LowerNode.md +++ /dev/null @@ -1,36 +0,0 @@ -## 本页面已过时 - -### Node.js >= 14 (并且 <18)时的安装方法 - -**如果不是 CentOS 7, RHEL 7, Ubuntu 18 请自行搜索并升级你的 Node.js 版本!** - -**此教程是为了因 glibc 不支持升级 Node.js 的Linux发行版准备的。** -1. 进入 Yunzai 根目录 -2. 安装依赖 -``` -pnpm install -w undici chatgpt showdown mathjax-node delay uuid remark strip-markdown node-fetch @waylaidwanderer/chatgpt-api keyv-file -``` -**若使用API模式,chatgpt的版本号注意要大于4.2.0** - -若不使用浏览器模式,可以不安装`random puppeteer-extra-plugin-recaptcha puppeteer-extra puppeteer-extra-plugin-stealth`这几个 - -3. 克隆项目 -``` -git clone https://github.com/ikechan8370/chatgpt-plugin.git ./plugins/chatgpt-plugin -``` -4. 修改配置 - -修改 Yunzai根目录/node_modules/.pnpm/chatgpt\@4.1.0/node_modules/chatgpt/build/index.js - -**此处 chatgpt\@4.1.0 路径不是绝对的!请根据自己安装的版本进行替换!** - -**将 // src/fetch.ts 部分修改成如下样子,其他部分不要动** -``` -// src/fetch.ts -import fetch from 'node-fetch'; -globalThis.fetch = fetch; -``` - -再编辑`Yunzai根目录/plugins/chatgpt-plugin/config/config.js`文件,根据其中的注释修改必要配置项。 - ---- diff --git a/Redis.md b/Redis.md deleted file mode 100644 index 199e7d5..0000000 --- a/Redis.md +++ /dev/null @@ -1,8 +0,0 @@ -## 本插件使用的一些redis键值说明 - -### 官方(API3/浏览器模式) -* CHATGPT:QQ_CONVERSATION:123456789 qq号为123456789的人当前正在使用哪个对话 -* CHATGPT:CONVERSATION_LAST_MESSAGE_ID:26001339-9043-435d-8394-c553a3109fdf id为`26001339-9043-435d-8394-c553a3109fdf`的对话,最后一条用户发出的消息的id -* CHATGPT:CONVERSATION_LAST_MESSAGE_PROMPT:26001339-9043-435d-8394-c553a3109fdf id为`26001339-9043-435d-8394-c553a3109fdf`的对话,最后一条用户发出的消息的内容(问题) -* CHATGPT:CONVERSATION_CREATE_TIME:26001339-9043-435d-8394-c553a3109fdf id为`26001339-9043-435d-8394-c553a3109fdf`的对话创建时间 -* CHATGPT:CONVERSATION_LENGTH:26001339-9043-435d-8394-c553a3109fdf id为`26001339-9043-435d-8394-c553a3109fdf`的对话当前长度(不计分支) diff --git a/apps/entertainment.js b/apps/entertainment.js index 105098f..9502190 100644 --- a/apps/entertainment.js +++ b/apps/entertainment.js @@ -6,7 +6,7 @@ import fs from 'fs' import { emojiRegex, googleRequestUrl } from '../utils/emoj/index.js' import fetch from 'node-fetch' import { mkdirs } from '../utils/common.js' -import uploadRecord from "../utils/uploadRecord.js"; +import uploadRecord from '../utils/uploadRecord.js' let useSilk = false try { diff --git a/apps/management.js b/apps/management.js index 6834fd0..5b2ebe6 100644 --- a/apps/management.js +++ b/apps/management.js @@ -1,6 +1,5 @@ import plugin from '../../../lib/plugins/plugin.js' import { Config } from '../utils/config.js' -import { BingAIClient } from '@waylaidwanderer/chatgpt-api' import { exec } from 'child_process' import { checkPnpm, formatDuration, parseDuration, getPublicIP } from '../utils/common.js' import SydneyAIClient from '../utils/SydneyAIClient.js' diff --git a/utils/config.js b/utils/config.js index 6e8100e..1275e4f 100644 --- a/utils/config.js +++ b/utils/config.js @@ -85,7 +85,7 @@ const defaultConfig = { viewHost: '', chatViewWidth: 1280, chatViewBotName: '', - version: 'v2.5.0' + version: 'v2.5.1' } const _path = process.cwd() let config = {} diff --git a/utils/dalle.js b/utils/dalle.js index 8151673..9311581 100644 --- a/utils/dalle.js +++ b/utils/dalle.js @@ -1,7 +1,7 @@ import { Configuration, OpenAIApi } from 'openai' -import {Config, defaultOpenAIAPI, defaultOpenAIReverseProxy, officialChatGPTAPI} from './config.js' +import { Config, defaultOpenAIAPI, defaultOpenAIReverseProxy } from './config.js' import fs from 'fs' -import {isCN, mkdirs} from './common.js' +import { isCN, mkdirs } from './common.js' let proxy if (Config.proxy) { try { @@ -47,7 +47,6 @@ export async function createImage (prompt, n = 1, size = '512x512') { } export async function imageVariation (imageUrl, n = 1, size = '512x512') { - let basePath = Config.openAiBaseUrl if (Config.openAiBaseUrl && Config.proxy && !Config.openAiForceUseReverse) { // 如果配了proxy,而且有反代,但是没开启强制反代 diff --git a/utils/face.js b/utils/face.js index 76d5b45..d65d3d2 100644 --- a/utils/face.js +++ b/utils/face.js @@ -489,6 +489,10 @@ export async function convertFaces (msg, handleAt = false, e) { if (!foundFace) { if (handleAt && msg[i] === '@') { foundAt = true + if (tmpMsg) { + msgs.push(tmpMsg) + tmpMsg = '' + } continue } if (handleAt && foundAt) { diff --git a/utils/randomMessage.js b/utils/randomMessage.js index a19456c..20841b8 100644 --- a/utils/randomMessage.js +++ b/utils/randomMessage.js @@ -1,6 +1,5 @@ import { Config } from './config.js' import { ChatGPTAPI } from 'chatgpt' -import { getMessageById, upsertMessage } from './common.js' import fetch from 'node-fetch' let proxy if (Config.proxy) { diff --git a/utils/tts.js b/utils/tts.js index 7641ad8..e3ed6bf 100644 --- a/utils/tts.js +++ b/utils/tts.js @@ -1,7 +1,7 @@ import { Config } from './config.js' import fetch from 'node-fetch' import _ from 'lodash' -import {wrapTextByLanguage} from "./common.js"; +import { wrapTextByLanguage } from './common.js' let proxy if (Config.proxy) { try { diff --git a/utils/uploadRecord.js b/utils/uploadRecord.js index 7bfaa8e..dae9c38 100644 --- a/utils/uploadRecord.js +++ b/utils/uploadRecord.js @@ -1,4 +1,4 @@ -import Contactable, { core } from 'oicq' +// import Contactable, { core } from 'oicq' import querystring from 'querystring' import fetch from 'node-fetch' import fs from 'fs' @@ -7,6 +7,14 @@ import util from 'util' import stream from 'stream' import crypto from 'crypto' import child_process from 'child_process' +let module +try { + module = await import('oicq') +} catch (err) { + module = await import('icqq') +} +const { core } = module +const Contactable = module.default // import { pcm2slk } from 'node-silk' let errors = {} let pcm2slk