mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +00:00
移除旧版本渲染和新版本帮助
This commit is contained in:
parent
57416dcd03
commit
6330eeb399
116 changed files with 5 additions and 7613 deletions
46
apps/chat.js
46
apps/chat.js
|
|
@ -1455,7 +1455,7 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
|
||||
async cacheContent(e, use, content, prompt, quote = [], mood = '', suggest = '', imgUrls = []) {
|
||||
let cacheData = { file: '', cacheUrl: Config.cacheUrl, status: '' }
|
||||
let cacheData = { file: '', status: '' }
|
||||
cacheData.file = randomString()
|
||||
const cacheresOption = {
|
||||
method: 'POST',
|
||||
|
|
@ -1497,49 +1497,7 @@ export class chatgpt extends plugin {
|
|||
async renderImage(e, use, content, prompt, quote = [], mood = '', suggest = '', imgUrls = []) {
|
||||
let cacheData = await this.cacheContent(e, use, content, prompt, quote, mood, suggest, imgUrls)
|
||||
const template = use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index'
|
||||
if (!Config.oldview) {
|
||||
if (cacheData.error || cacheData.status != 200) { await this.reply(`出现错误:${cacheData.error || 'server error ' + cacheData.status}`, true) } else { await e.reply(await renderUrl(e, (Config.viewHost ? `${Config.viewHost}/` : `http://127.0.0.1:${Config.serverPort || 3321}/`) + `page/${cacheData.file}?qr=${Config.showQRCode ? 'true' : 'false'}`, { retType: Config.quoteReply ? 'base64' : '', Viewport: { width: parseInt(Config.chatViewWidth), height: parseInt(parseInt(Config.chatViewWidth) * 0.56) }, func: (parseFloat(Config.live2d) && !Config.viewHost) ? 'window.Live2d == true' : '', deviceScaleFactor: parseFloat(Config.cloudDPR) }), e.isGroup && Config.quoteReply) }
|
||||
} else {
|
||||
if (Config.cacheEntry) cacheData.file = randomString()
|
||||
const cacheresOption = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
content: {
|
||||
content: new Buffer.from(content).toString('base64'),
|
||||
prompt: new Buffer.from(prompt).toString('base64'),
|
||||
senderName: e.sender.nickname,
|
||||
style: Config.toneStyle,
|
||||
mood,
|
||||
quote
|
||||
},
|
||||
model: use,
|
||||
bing: use === 'bing',
|
||||
entry: Config.cacheEntry ? cacheData.file : ''
|
||||
})
|
||||
}
|
||||
if (Config.cacheEntry) {
|
||||
fetch(`${Config.cacheUrl}/cache`, cacheresOption)
|
||||
} else {
|
||||
const cacheres = await fetch(`${Config.cacheUrl}/cache`, cacheresOption)
|
||||
if (cacheres.ok) {
|
||||
cacheData = Object.assign({}, cacheData, await cacheres.json())
|
||||
}
|
||||
}
|
||||
await e.reply(await render(e, 'chatgpt-plugin', template, {
|
||||
content: new Buffer.from(content).toString('base64'),
|
||||
prompt: new Buffer.from(prompt).toString('base64'),
|
||||
senderName: e.sender.nickname,
|
||||
quote: quote.length > 0,
|
||||
quotes: quote,
|
||||
cache: cacheData,
|
||||
style: Config.toneStyle,
|
||||
mood,
|
||||
version
|
||||
}, { retType: Config.quoteReply ? 'base64' : '' }), e.isGroup && Config.quoteReply)
|
||||
}
|
||||
if (cacheData.error || cacheData.status != 200) { await this.reply(`出现错误:${cacheData.error || 'server error ' + cacheData.status}`, true) } else { await e.reply(await renderUrl(e, (Config.viewHost ? `${Config.viewHost}/` : `http://127.0.0.1:${Config.serverPort || 3321}/`) + `page/${cacheData.file}?qr=${Config.showQRCode ? 'true' : 'false'}`, { retType: Config.quoteReply ? 'base64' : '', Viewport: { width: parseInt(Config.chatViewWidth), height: parseInt(parseInt(Config.chatViewWidth) * 0.56) }, func: (parseFloat(Config.live2d) && !Config.viewHost) ? 'window.Live2d == true' : '', deviceScaleFactor: parseFloat(Config.cloudDPR) }), e.isGroup && Config.quoteReply) }
|
||||
}
|
||||
|
||||
async sendMessage(prompt, conversation = {}, use, e) {
|
||||
|
|
|
|||
17
apps/help.js
17
apps/help.js
|
|
@ -1,6 +1,6 @@
|
|||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { Config } from '../utils/config.js'
|
||||
import { render, renderUrl } from '../utils/common.js'
|
||||
import { render } from '../utils/common.js'
|
||||
let version = Config.version
|
||||
let helpData = [
|
||||
{
|
||||
|
|
@ -326,25 +326,12 @@ export class help extends plugin {
|
|||
{
|
||||
reg: '^#(chatgpt|ChatGPT)(命令|帮助|菜单|help|说明|功能|指令|使用说明)$',
|
||||
fnc: 'help'
|
||||
},
|
||||
{
|
||||
reg: '^#帮助-',
|
||||
fnc: 'newHelp'
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
async help (e) {
|
||||
if (Config.newhelp && !Config.oldview) {
|
||||
await renderUrl(e, `http://127.0.0.1:${Config.serverPort || 3321}/help/`, { Viewport: { width: 800, height: 600 } })
|
||||
} else {
|
||||
await render(e, 'chatgpt-plugin', 'help/index', { helpData, version })
|
||||
}
|
||||
}
|
||||
|
||||
async newHelp (e) {
|
||||
let use = e.msg.replace(/^#帮助-/, '').toUpperCase().trim()
|
||||
await renderUrl(e, `http://127.0.0.1:${Config.serverPort || 3321}/help/` + use, { Viewport: { width: 800, height: 600 } })
|
||||
await render(e, 'chatgpt-plugin', 'help/index', { helpData, version })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue