Merge branch 'ikechan8370:v2' into v2

This commit is contained in:
ifeif 2023-09-11 22:57:24 +08:00 committed by GitHub
commit 97fd363a4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
185 changed files with 1543 additions and 7750 deletions

View file

@ -9,7 +9,8 @@ import {
getVoicevoxRoleList,
makeForwardMsg,
parseDuration,
renderUrl
renderUrl,
randomString
} from '../utils/common.js'
import SydneyAIClient from '../utils/SydneyAIClient.js'
import { convertSpeaker, speakers as vitsRoleList } from '../utils/tts.js'
@ -103,6 +104,11 @@ export class ChatgptManagement extends plugin {
fnc: 'useSlackClaudeBasedSolution',
permission: 'master'
},
{
reg: '^#chatgpt切换(Claude2|claude2|claude.ai)$',
fnc: 'useClaudeAISolution',
permission: 'master'
},
{
reg: '^#chatgpt切换星火$',
fnc: 'useXinghuoBasedSolution',
@ -217,6 +223,11 @@ export class ChatgptManagement extends plugin {
reg: '^#(设置|修改)用户密码',
fnc: 'setUserPassword'
},
{
reg: '^#工具箱',
fnc: 'toolsPage',
permission: 'master'
},
{
reg: '^#chatgpt系统(设置|配置|管理)',
fnc: 'adminPage',
@ -846,6 +857,16 @@ azure语音Azure 语音是微软 Azure 平台提供的一项语音服务,
}
}
async useClaudeAISolution () {
let use = await redis.get('CHATGPT:USE')
if (use !== 'claude2') {
await redis.set('CHATGPT:USE', 'claude2')
await this.reply('已切换到基于claude.ai的解决方案')
} else {
await this.reply('当前已经是claude2模式了')
}
}
async useXinghuoBasedSolution () {
let use = await redis.get('CHATGPT:USE')
if (use !== 'xh') {
@ -1246,7 +1267,7 @@ Poe 模式会调用 Poe 中的 Claude-instant 进行对话。需要提供 Cookie
return true
}
const viewHost = Config.serverHost ? `http://${Config.serverHost}/` : `http://${await getPublicIP()}:${Config.serverPort || 3321}/`
await this.reply(`请登录${viewHost + 'admin/settings'}进行系统配置`, true)
await this.reply(`请登录${viewHost}进行系统配置`, true)
}
async userPage (e) {
@ -1255,7 +1276,22 @@ Poe 模式会调用 Poe 中的 Claude-instant 进行对话。需要提供 Cookie
return true
}
const viewHost = Config.serverHost ? `http://${Config.serverHost}/` : `http://${await getPublicIP()}:${Config.serverPort || 3321}/`
await this.reply(`请登录${viewHost + 'admin/dashboard'}进行系统配置`, true)
await this.reply(`请登录${viewHost}进行系统配置`, true)
}
async toolsPage (e) {
if (e.isGroup || !e.isPrivate) {
await this.reply('请私聊发送命令', true)
return true
}
const viewHost = Config.serverHost ? `http://${Config.serverHost}/` : `http://${await getPublicIP()}:${Config.serverPort || 3321}/`
const otp = randomString(6)
await redis.set(
`CHATGPT:SERVER_QUICK`,
otp,
{ EX: 60000 }
)
await this.reply(`请登录http://tools.alcedogroup.com/login?server=${viewHost}&otp=${otp}`, true)
}
async setOpenAIPlatformToken (e) {
@ -1292,7 +1328,7 @@ Poe 模式会调用 Poe 中的 Claude-instant 进行对话。需要提供 Cookie
if (await redis.exists('CHATGPT:USE') != 0) {
redisConfig.useMode = await redis.get('CHATGPT:USE')
}
const filepath = path.join('plugins/chatgpt-plugin/resources', 'view.json')
const filepath = path.join('plugins/chatgpt-plugin/resources/view', 'setting_view.json')
const configView = JSON.parse(fs.readFileSync(filepath, 'utf8'))
const configJson = JSON.stringify({
chatConfig: Config,
@ -1301,7 +1337,7 @@ Poe 模式会调用 Poe 中的 Claude-instant 进行对话。需要提供 Cookie
})
console.log(configJson)
const buf = Buffer.from(configJson)
e.friend.sendFile(buf, `ChatGPT-Plugin Config ${new Date()}.json`)
e.friend.sendFile(buf, `ChatGPT-Plugin Config ${Date.now()}.json`)
return true
}