fix: at都被挤到消息最前面的问题

This commit is contained in:
ikechan8370 2023-04-12 20:03:41 +08:00
parent 7bf5996dce
commit 8bdbd623b3
10 changed files with 18 additions and 53 deletions

View file

@ -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`文件,根据其中的注释修改必要配置项。
---

View file

@ -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`的对话当前长度(不计分支)

View file

@ -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 {

View file

@ -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'

View file

@ -85,7 +85,7 @@ const defaultConfig = {
viewHost: '',
chatViewWidth: 1280,
chatViewBotName: '',
version: 'v2.5.0'
version: 'v2.5.1'
}
const _path = process.cwd()
let config = {}

View file

@ -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而且有反代但是没开启强制反代

View file

@ -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) {

View file

@ -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) {

View file

@ -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 {

View file

@ -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