Update index_no#.js

This commit is contained in:
夏叶 2022-12-09 14:36:35 +08:00 committed by GitHub
parent 55816b8ccd
commit ddf2714473
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ import plugin from '../../lib/plugins/plugin.js'
import { ChatGPTAPI } from 'chatgpt'
import _ from 'lodash'
const SESSION_TOKEN = ''
const blockWords = '屏蔽词1,屏蔽词2,屏蔽词3'
/**
* 每个对话保留的时长单个对话内ai是保留上下文的超时后销毁对话再次对话创建新的对话
@ -157,6 +158,14 @@ export class chatgpt extends plugin {
utime: new Date(),
num: previousConversation.num + 1
}), { EX: CONVERSATION_PRESERVE_TIME })
// 检索是否有屏蔽词
const blockWord = blockWords.split(',').find(word => response.toLowerCase().includes(word.toLowerCase()))
if (blockWord) {
await this.reply(`返回内容存在敏感词,我不想回答你`, true)
return
}
/** 最后回复消息 */
await this.reply(`${response}`, e.isGroup)
} catch (e) {
@ -164,4 +173,4 @@ export class chatgpt extends plugin {
await this.reply(`与OpenAI通信异常请稍后重试${e}`, true, { recallMsg: e.isGroup ? 10 : 0 })
}
}
}
}