From a032e7d9cfff3c43c5223e2b834ab2fe353537f8 Mon Sep 17 00:00:00 2001 From: RrOrange <542716863@qq.com> Date: Fri, 7 Apr 2023 22:05:05 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=A2=9E=E5=8A=A0issue?= =?UTF-8?q?=E8=A6=81=E6=B1=82=E7=9A=84=E5=93=94=E5=93=A9=E5=93=94=E5=93=A9?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E8=A7=86=E9=A2=91=E6=97=B6=E9=95=BF=E9=99=90?= =?UTF-8?q?=E5=88=B6(#I6O2OE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 7 +++++++ config/tools.yaml | 4 +++- guoba.support.js | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/tools.js b/apps/tools.js index 0814a03..6e02d9d 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -90,6 +90,8 @@ export class tools extends plugin { this.myProxy = `http://${this.proxyAddr}:${this.proxyPort}`; // 加载哔哩哔哩配置 this.biliSessData = this.toolsConfig.biliSessData; + // 加载哔哩哔哩的限制时长 + this.biliDuration = this.toolsConfig.biliDuration; // 加载gpt配置 this.openaiAccessToken = this.toolsConfig.openaiAccessToken; // 加载gpt客户端 @@ -326,6 +328,11 @@ export class tools extends plugin { // 请求视频信息 const videoInfo = await getVideoInfo(url); const { title, desc, duration, dynamic, stat, aid, cid } = videoInfo; + // 限制时长 + if (duration > this.biliDuration) { + e.reply(`当前视频时长约:${(duration / 60).toFixed(0)}分钟,\n大于管理员设置的最大时长 ${this.biliDuration / 60} 分钟!`); + return true; + } // 视频信息 let { view, danmaku, reply, favorite, coin, share, like } = stat; // 数据处理 diff --git a/config/tools.yaml b/config/tools.yaml index 6d891f7..59cb909 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -6,4 +6,6 @@ translateAppId: '' # 百度翻译APP ID translateSecret: '' # 百度翻译密匙 biliSessData: '' # 哔哩哔哩的SESSDATA -openaiAccessToken: '' # 通过获取:https://chat.openai.com/api/auth/session +biliDuration: 900 # 哔哩哔哩限制的最大视频时长(默认15分钟),单位:秒 + +openaiAccessToken: '' # 通过获取:https://chat.openai.com/api/auth/session \ No newline at end of file diff --git a/guoba.support.js b/guoba.support.js index bb39c3b..9a104e2 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -86,6 +86,17 @@ export function supportGuoba() { placeholder: "请输入哔哩哔哩SESSDATA", }, }, + { + field: "tools.biliDuration", + label: "哔哩哔哩的视频最大限制时长", + bottomHelpMessage: + "超过时长无法解析,保护服务器性能", + component: "Input", + required: false, + componentProps: { + placeholder: "请输入哔哩哔哩的视频最大限制时长(默认15分钟)", + }, + }, { field: "tools.openaiAccessToken", label: "OpenAI的AccessToken",