fix: 设置不存在的角色语音时给提示

This commit is contained in:
ikechan8370 2023-03-05 00:07:01 +08:00
parent a54f87667a
commit c9361c63b4
2 changed files with 7 additions and 2 deletions

View file

@ -381,8 +381,12 @@ export class chatgpt extends plugin {
}
let speaker = _.trimStart(e.msg, '#chatgpt设置语音角色') || '随机'
userSetting.ttsRole = convertSpeaker(speaker)
await redis.set(`CHATGPT:USER:${e.sender.user_id}`, JSON.stringify(userSetting))
await this.reply(`您的默认语音角色已被设置为”${userSetting.ttsRole}`)
if (speakers.indexOf(userSetting.ttsRole) >= 0) {
await redis.set(`CHATGPT:USER:${e.sender.user_id}`, JSON.stringify(userSetting))
await this.reply(`您的默认语音角色已被设置为”${userSetting.ttsRole}`)
} else {
await this.reply(`”抱歉,${userSetting.ttsRole}“我还不认识呢`)
}
}
/**

View file

@ -61,6 +61,7 @@ export async function generateAudio (text, speaker = '随机', language = '中
}
if (response.status > 299) {
logger.info(json)
throw new Error(JSON.stringify(json))
}
let [message, audioInfo, take] = json?.data
logger.info(message, take)