优化 chat.js

This commit is contained in:
ifeif 2023-05-16 14:43:07 +08:00
parent 05732f87f2
commit ab050cf73e

View file

@ -1018,7 +1018,18 @@ export class chatgpt extends plugin {
let mood = 'blandness'
if (!response) {
await e.reply('没有任何回复', true)
return
return false
} else if (response === 'Thanks for this conversation! I\'ve reached my limit, will you hit “New topic,” please?') {
this.reply('当前对话超过上限,已重置对话', false, { at: true })
await redis.del(`CHATGPT:CONVERSATIONS_BING:${e.sender.user_id}`)
return false
} else if (response === 'Unexpected message author.') {
this.reply('无法回答当前话题,已重置对话', false, { at: true })
await redis.del(`CHATGPT:CONVERSATIONS_BING:${e.sender.user_id}`)
return false
} else if (response === 'Throttled: Request is throttled.') {
this.reply('今日对话已达上限')
return false
}
let emotion, emotionDegree
if (Config.ttsMode === 'azure' && (use === 'claude' || use === 'bing') && await AzureTTS.getEmotionPrompt(e)) {
@ -1116,18 +1127,6 @@ export class chatgpt extends plugin {
if (useTTS && response.length <= Config.autoUsePictureThreshold) {
// 缓存数据
this.cacheContent(e, use, response, prompt, quotemessage, mood, chatMessage.suggestedResponses, imgUrls)
if (response === 'Thanks for this conversation! I\'ve reached my limit, will you hit “New topic,” please?') {
this.reply('当前对话超过上限,已重置对话', false, { at: true })
await redis.del(`CHATGPT:CONVERSATIONS_BING:${e.sender.user_id}`)
return false
} else if (response === 'Unexpected message author.') {
this.reply('无法回答当前话题,已重置对话', false, { at: true })
await redis.del(`CHATGPT:CONVERSATIONS_BING:${e.sender.user_id}`)
return false
} else if (response === 'Throttled: Request is throttled.') {
this.reply('今日对话已达上限')
return false
}
// 处理tts输入文本
let ttsResponse, ttsRegex
const regex = /^\/(.*)\/([gimuy]*)$/
@ -1237,18 +1236,6 @@ export class chatgpt extends plugin {
}
} else {
this.cacheContent(e, use, response, prompt, quotemessage, mood, chatMessage.suggestedResponses, imgUrls)
if (response === 'Thanks for this conversation! I\'ve reached my limit, will you hit “New topic,” please?') {
this.reply('当前对话超过上限,已重置对话', false, { at: true })
await redis.del(`CHATGPT:CONVERSATIONS_BING:${e.sender.user_id}`)
return false
} else if (response === 'Unexpected message author.') {
this.reply('无法回答当前话题,已重置对话', false, { at: true })
await redis.del(`CHATGPT:CONVERSATIONS_BING:${e.sender.user_id}`)
return false
} else if (response === 'Throttled: Request is throttled.') {
this.reply('今日对话已达上限')
return false
}
await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup)
if (quotemessage.length > 0) {
this.reply(await makeForwardMsg(this.e, quotemessage.map(msg => `${msg.text} - ${msg.url}`)))