From 332c5958463195ac64ba12fe1e442d13c443fe68 Mon Sep 17 00:00:00 2001 From: zhiyu <542716863@qq.com> Date: Fri, 26 Jan 2024 23:18:50 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=91=98=E8=A6=81=E7=9A=84=E9=A1=BA=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 33 +++++++++++++++++++++++++------- utils/encrypt.js | 49 ------------------------------------------------ 2 files changed, 26 insertions(+), 56 deletions(-) delete mode 100644 utils/encrypt.js diff --git a/apps/tools.js b/apps/tools.js index d891312..bfd5b69 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -15,7 +15,7 @@ import { XHS_CK, RESTRICTION_DESCRIPTION, } from "../constants/constant.js"; -import { dataProcessing, formatBiliInfo, getIdVideo, secondsToTime } from "../utils/common.js"; +import { formatBiliInfo, getIdVideo, secondsToTime } from "../utils/common.js"; import config from "../model/index.js"; import Translate from "../utils/trans-strategy.js"; import * as xBogus from "../utils/x-bogus.cjs"; @@ -345,16 +345,16 @@ export class tools extends plugin { biliInfo.unshift(segment.image(pic)) // 限制视频解析 const durationInMinutes = (curDuration / 60).toFixed(0); - biliInfo.push(`${RESTRICTION_DESCRIPTION}\n当前视频时长约:${ durationInMinutes }分钟,\n大于管理员设置的最大时长 ${ this.biliDuration / 60 } 分钟!`) - e.reply(biliInfo); + biliInfo.push(`${ RESTRICTION_DESCRIPTION }\n当前视频时长约:${ durationInMinutes }分钟,\n大于管理员设置的最大时长 ${ this.biliDuration / 60 } 分钟!`) // 总结 const summary = await this.getBiliSummary(bvid, cid, owner.mid); - summary && e.reply(summary); + summary && biliInfo.push(`\n${ summary }`); + e.reply(biliInfo); return true; } else { // 总结 const summary = await this.getBiliSummary(bvid, cid, owner.mid); - summary && biliInfo.push(`\n${summary}`) + summary && biliInfo.push(`\n${ summary }`); // e.reply(biliInfo); } @@ -441,7 +441,7 @@ export class tools extends plugin { let resReply = ""; // 总体总结 if (summary) { - resReply = `摘要:${ summary }\n` + resReply = `\n摘要:${ summary }\n` } // 分段总结 if (outline) { @@ -983,7 +983,7 @@ export class tools extends plugin { /** * douyin 请求参数 * @param url - * @returns {Promise} + * @returns {Promise} */ async douyinRequest(url) { const params = { @@ -1057,6 +1057,25 @@ export class tools extends plugin { } } + /** + * 判断是否是海外服务器 + * @return {Promise} + */ + async isOverseasServer() { + const isOS = "Yz:rconsole:tools:oversea"; + // 如果第一次使用没有值就设置 + if (!(await redis.exists(isOS))) { + await redis.set( + JSON.stringify({ + os: false, + }), + ); + return true; + } + // 如果有就取出来 + return JSON.parse(redis.get(isOS)).os; + } + /** * 限制用户调用 * @param e diff --git a/utils/encrypt.js b/utils/encrypt.js deleted file mode 100644 index ea34dc8..0000000 --- a/utils/encrypt.js +++ /dev/null @@ -1,49 +0,0 @@ -// AES加密 -import crypto from "crypto"; - -const key = crypto.createHash("sha256").update("rconsole").digest(); - -/** - * AES加密 - * @param ha1 - * @returns {Promise} - */ -async function ha12store(ha1) { - // IV.E - const iv = crypto.randomBytes(16); - const c = crypto.createCipheriv("aes-256-cbc", key, iv); - let e = c.update(ha1, "binary", "hex"); - e += c.final("hex"); - return iv.toString("hex") + "." + e; -} - -/** - * AES解密 - * @param passstore - * @returns {Promise} - */ -async function store2ha1(passstore) { - try { - const parts = passstore.split("."); - if (parts.length === 2) { - // 新的加密方式 with IV: IV.E - const c = crypto.createDecipheriv("aes-256-cbc", key, Buffer.from(parts[0], "hex")); - let d = c.update(parts[1], "hex", "binary"); - d += c.final("binary"); - return d; - } else { - // 旧加密方式 without IV: E - const c = crypto.createDecipher("aes192", key); - let d = c.update(passstore, "hex", "binary"); - d += c.final("binary"); - return d; - } - } catch (e) { - console.error( - "在[default]部分设置的passwordSecret无法解密信息。请确保所有节点的passwordSecret相同。如果您更改了密码保密信息,可能需要重新添加用户。", - e, - ); - } -} - -export { ha12store, store2ha1 };