Chore: Optimize some code logic and add support for chat context in '锅巴面板' and 'chatgpt帮助' (#310)

* Optimized code logic and added support for chat context in '锅巴面板' and 'chatgpt帮助'

In this commit, I have optimized certain code logic to improve the performance of the application. Additionally, I have added support for chat context in croutons and help, which will enhance the user experience and make the chatbot more user-friendly. This feature will allow users to maintain a better understanding of the conversation flow and context, and will ultimately lead to more successful interactions with the chatbot.

* Update chat.js

---------

Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
This commit is contained in:
Sean Murphy 2023-04-03 11:11:18 +08:00 committed by GitHub
parent 84eabee14d
commit 68bb1f221e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 47 deletions

View file

@ -130,10 +130,33 @@ export class ChatgptManagement extends plugin {
reg: '^#chatgpt查看(Bing|必应|Sydney|悉尼|sydney|bing)设定$',
fnc: 'queryBingPromptPrefix',
permission: 'master'
},
{
/** 命令正则匹配 */
reg: '^#(关闭|打开)群聊上下文',
/** 执行方法 */
fnc: 'enableGroupContext',
permission: 'master'
}
]
})
}
async enableGroupContext (e) {
const re = /#(关闭|打开)/
const match = e.msg.match(re)
//logger.info(match)
if (match) {
const action = match[1]
if (action === '关闭') {
Config.enableGroupContext = false // 关闭
await this.reply('已关闭群聊上下文功能', true)
} else {
Config.enableGroupContext = true // 打开
await this.reply('已打开群聊上下文功能', true)
}
}
return false
}
async turnOnConfirm (e) {
await redis.set('CHATGPT:CONFIRM', 'on')