修复bug和旧代码清理 (#553)

* fix: 修复星火api上下文

* 将无星火ck的情况降低为warn

* feat: 添加星火设定自定义代码功能

* 修复星火api模式的一些问题

* 修复导出配置问题

* feat:添加工具箱快捷登录接口

* 添加工具箱快捷登录指令

* 阻止群聊使用快捷登录

* 添加Azure配置支持,修复重复的配置项冲突

* 移除旧版本渲染和新版本帮助

* 添加工具箱

* 更新工具箱替换原有后台

* 更新工具箱适配代码
This commit is contained in:
HalcyonAlcedo 2023-09-08 12:28:02 +08:00 committed by GitHub
parent 043b80ddd4
commit bf761c24da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
183 changed files with 1206 additions and 7675 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'
@ -212,6 +213,11 @@ export class ChatgptManagement extends plugin {
reg: '^#(设置|修改)用户密码',
fnc: 'setUserPassword'
},
{
reg: '^#工具箱',
fnc: 'toolsPage',
permission: 'master'
},
{
reg: '^#chatgpt系统(设置|配置|管理)',
fnc: 'adminPage',
@ -1234,7 +1240,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) {
@ -1243,7 +1249,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) {
@ -1280,7 +1301,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,
@ -1289,7 +1310,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
}