Skip to content

Commit

Permalink
fix: ChatGPT 黑白名单忘了做
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsuk1ko committed Dec 16, 2022
1 parent 01c83b3 commit 557a3d6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 2022

### 12-17 v3.1.2

- 修复 ChatGPT 黑白名单不生效问题
- 优化 ChatGPT 回答多余字符过滤

### 12-17 v3.1.1

- 修复 ChatGPT prompt 可能含有非文本内容的问题
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cq-picsearcher-bot",
"version": "3.1.1",
"version": "3.1.2",
"description": "二次元搜图机器人",
"main": "index.js",
"private": true,
Expand Down
14 changes: 14 additions & 0 deletions src/plugin/chatgpt.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import AxiosProxy from '../utils/axiosProxy.mjs';
import emitter from '../utils/emitter.mjs';
import { retryAsync } from '../utils/retry.mjs';

let blackGroup = new Set();
let whiteGroup = new Set();

emitter.onConfigLoad(() => {
blackGroup = new Set(global.config.bot.chatgpt.blackGroup);
whiteGroup = new Set(global.config.bot.chatgpt.whiteGroup);
});

export default async context => {
const config = global.config.bot.chatgpt;
if (!config.enable) return false;

if (context.group_id) {
if (blackGroup.has(context.group_id)) return false;
if (whiteGroup.size && !whiteGroup.has(context.group_id)) return false;
}

if (!config.apiKey) {
global.replyMsg(context, '未配置 APIKey', false, true);
return false;
Expand Down

0 comments on commit 557a3d6

Please sign in to comment.