防止注入攻击 (#170)

* 修复引用转发,默认bing模式并发

* 开启stream增加稳定性

* fix: remove queue element only in non-bing mode

* 使用chatgpt-api自带的超时逻辑,文字过多时启动切换到图片输出防止被吞

* Update chat.js

* 添加Bing专用的图片输出样式

* 添加chatgpt的新图片模式,临时处理切换api导致的对话异常

* 修改bing样式表

* 为图片添加外部页面缓存

* 为图片模式添加MathJax

* feat: add switch for qrcode

* 防止script攻击

---------

Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
This commit is contained in:
HalcyonAlcedo 2023-02-19 00:44:33 +08:00 committed by GitHub
parent 624e1f6e1a
commit c07503db29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ import { KeyvFile } from 'keyv-file'
import { OfficialChatGPTClient } from '../utils/message.js'
import fetch from 'node-fetch'
import { deleteConversation, getConversations, getLatestMessageIdByConversationId } from '../utils/conversation.js'
import cfg from '../../../lib/config/config.js'
const blockWords = Config.blockWords
/**
@ -273,6 +274,14 @@ export class chatgpt extends plugin {
return false
}
}
if (prompt.indexOf('<script>') != -1)
{
await this.reply('坏人,我要报告给主人', e.isGroup)
Bot.pickUser(cfg.masterQQ[0]).sendMsg(`主人,我在${this.e.group_id ? '群' + this.e.group_id : '私聊' }${e.sender.nickname}使用代码攻击了,请警惕`)
return false
}
const use = await redis.get('CHATGPT:USE')
if (use !== 'bing') {
let randomId = uuid()