Merge pull request #13 from varxiaye/main

回复内容增加屏蔽词检索,防止回复敏感内容
This commit is contained in:
ikechan8370 2022-12-09 17:10:30 +08:00 committed by GitHub
commit 676baffa20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

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是保留上下文的超时后销毁对话再次对话创建新的对话
@ -156,6 +157,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) {