mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
Merge branch 'v2' of github.com:ikechan8370/chatgpt-plugin into v2
This commit is contained in:
commit
0d5ebc073f
6 changed files with 82 additions and 48 deletions
36
apps/chat.js
36
apps/chat.js
|
|
@ -798,27 +798,9 @@ export class chatgpt extends plugin {
|
|||
})
|
||||
}
|
||||
if (useTTS) {
|
||||
if (Config.ttsSpace && response.length <= Config.ttsAutoFallbackThreshold) {
|
||||
let audioErr = false
|
||||
try {
|
||||
let wav = await generateAudio(response, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
|
||||
await e.reply(segment.record(wav))
|
||||
} catch (err) {
|
||||
await this.reply('合成语音发生错误,我用文本回复你吧')
|
||||
audioErr = true
|
||||
}
|
||||
if (Config.alsoSendText || audioErr) {
|
||||
await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup)
|
||||
if (quotemessage.length > 0) {
|
||||
this.reply(await makeForwardMsg(this.e, quotemessage))
|
||||
}
|
||||
if (Config.enableSuggestedResponses && chatMessage.suggestedResponses) {
|
||||
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await this.reply('你没有配置转语音API或者文字太长了哦,我用文本回复你吧')
|
||||
await this.reply(`${response}`, e.isGroup)
|
||||
// 先把文字回复发出去,避免过久等待合成语音
|
||||
if (Config.alsoSendText) {
|
||||
await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup)
|
||||
if (quotemessage.length > 0) {
|
||||
this.reply(await makeForwardMsg(this.e, quotemessage))
|
||||
}
|
||||
|
|
@ -826,6 +808,18 @@ export class chatgpt extends plugin {
|
|||
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
|
||||
}
|
||||
}
|
||||
// 过滤‘括号’的内容不读,减少违和感
|
||||
let ttsResponse = response.replace(/[((\[{<【《「『【〖【【【“‘'"@][^()()\]}>】》」』】〗】】”’'@]*[))\]}>】》」』】〗】】”’'@]/g, '')
|
||||
if (Config.ttsSpace && ttsResponse.length <= Config.ttsAutoFallbackThreshold) {
|
||||
try {
|
||||
let wav = await generateAudio(ttsResponse, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
|
||||
await e.reply(segment.record(wav))
|
||||
} catch (err) {
|
||||
await this.reply('合成语音发生错误~')
|
||||
}
|
||||
} else {
|
||||
await this.reply('你没有配置转语音API或者文字太长了哦')
|
||||
}
|
||||
} else if (userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
|
||||
// todo use next api of chatgpt to complete incomplete respoonse
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue