From 82ae24848bf5bb97389c11e984e6213bd371495b Mon Sep 17 00:00:00 2001 From: ZeroCal Su <3146312184@qq.com> Date: Mon, 14 Oct 2024 13:04:47 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E7=A7=BB=E9=99=A4=E8=A7=A3?= =?UTF-8?q?=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/Calabash.js | 2 +- apps/Challenge.js | 2 +- apps/Character.js | 2 +- apps/Explore.js | 2 +- apps/Tower.js | 2 +- apps/User.js | 2 +- components/Code.js | 27 +++++++++------------------ package.json | 2 +- 8 files changed, 16 insertions(+), 25 deletions(-) diff --git a/apps/Calabash.js b/apps/Calabash.js index 30e3ddb..d6480cd 100644 --- a/apps/Calabash.js +++ b/apps/Calabash.js @@ -28,7 +28,7 @@ export class Calabash extends plugin { if (!accountList.length) { if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) { - let publicCookie = await waves.getPublicCookie(); + let publicCookie = await waves.pubCookie(); if (!publicCookie) { return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定'); } else { diff --git a/apps/Challenge.js b/apps/Challenge.js index 5a9c80f..cd43fa8 100644 --- a/apps/Challenge.js +++ b/apps/Challenge.js @@ -28,7 +28,7 @@ export class Challenge extends plugin { if (!accountList.length) { if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) { - let publicCookie = await waves.getPublicCookie(); + let publicCookie = await waves.pubCookie(); if (!publicCookie) { return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定'); } else { diff --git a/apps/Character.js b/apps/Character.js index 0bb38a7..6e00187 100644 --- a/apps/Character.js +++ b/apps/Character.js @@ -33,7 +33,7 @@ export class Character extends plugin { if (!accountList.length) { if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) { - let publicCookie = await waves.getPublicCookie(); + let publicCookie = await waves.pubCookie(); if (!publicCookie) { return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定'); } else { diff --git a/apps/Explore.js b/apps/Explore.js index 5c39ed9..b18d68d 100644 --- a/apps/Explore.js +++ b/apps/Explore.js @@ -28,7 +28,7 @@ export class Explore extends plugin { if (!accountList.length) { if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) { - let publicCookie = await waves.getPublicCookie(); + let publicCookie = await waves.pubCookie(); if (!publicCookie) { return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定'); } else { diff --git a/apps/Tower.js b/apps/Tower.js index a30fce2..035187c 100644 --- a/apps/Tower.js +++ b/apps/Tower.js @@ -28,7 +28,7 @@ export class TowerInfo extends plugin { if (!accountList.length) { if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) { - let publicCookie = await waves.getPublicCookie(); + let publicCookie = await waves.pubCookie(); if (!publicCookie) { return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定'); } else { diff --git a/apps/User.js b/apps/User.js index ffc042b..9b98ff6 100644 --- a/apps/User.js +++ b/apps/User.js @@ -28,7 +28,7 @@ export class UserInfo extends plugin { if (!accountList.length) { if (match || await redis.get(`Yunzai:waves:bind:${e.user_id}`)) { - let publicCookie = await waves.getPublicCookie(); + let publicCookie = await waves.pubCookie(); if (!publicCookie) { return await e.reply('当前没有可用的公共Cookie,请使用[~登录]进行绑定'); } else { diff --git a/components/Code.js b/components/Code.js index 777c44d..8a68e59 100644 --- a/components/Code.js +++ b/components/Code.js @@ -150,7 +150,7 @@ class Waves { const response = await axios.post(CONSTANTS.BASE_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } }); if (response.data.code === 200) { - response.data.data = await this.decryptData(response.data.data) + response.data.data = JSON.parse(response.data.data) if (response.data.data === null) { logger.info('获取我的资料失败,返回数据为null'); return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" }; @@ -182,7 +182,7 @@ class Waves { const response = await axios.post(CONSTANTS.ROLE_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } }); if (response.data.code === 200) { - response.data.data = await this.decryptData(response.data.data) + response.data.data = JSON.parse(response.data.data) if (response.data.data === null) { logger.info('获取共鸣者失败,返回数据为null'); return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" }; @@ -214,7 +214,7 @@ class Waves { const response = await axios.post(CONSTANTS.CALABASH_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } }); if (response.data.code === 200) { - response.data.data = await this.decryptData(response.data.data) + response.data.data = JSON.parse(response.data.data) if (response.data.data === null) { logger.info('获取数据坞失败,返回数据为null'); return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" }; @@ -247,7 +247,7 @@ class Waves { const response = await axios.post(CONSTANTS.CHALLENGE_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } }); if (response.data.code === 200) { - response.data.data = await this.decryptData(response.data.data) + response.data.data = JSON.parse(response.data.data) if (response.data.data === null) { logger.info('获取挑战数据失败,返回数据为null'); return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" }; @@ -280,7 +280,7 @@ class Waves { const response = await axios.post(CONSTANTS.EXPLORE_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } }); if (response.data.code === 200) { - response.data.data = await this.decryptData(response.data.data) + response.data.data = JSON.parse(response.data.data) if (response.data.data === null) { logger.info('获取探索数据失败,返回数据为null'); return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" }; @@ -312,7 +312,7 @@ class Waves { const response = await axios.post(CONSTANTS.ROLE_DETAIL_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token } }); if (response.data.code === 200) { - response.data.data = await this.decryptData(response.data.data) + response.data.data = JSON.parse(response.data.data) if (response.data.data === null) { logger.info('获取角色详细信息失败,返回数据为null'); return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" }; @@ -377,11 +377,11 @@ class Waves { const response = await axios.post(CONSTANTS.SELF_TOWER_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token, devcode: '' } }); if (response.data.code === 200) { - response.data.data = await this.decryptData(response.data.data) + response.data.data = JSON.parse(response.data.data) if (response.data.data === null) { const otherResponse = await axios.post(CONSTANTS.OTHER_TOWER_DATA_URL, data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, 'token': token, devcode: '' } }); if (otherResponse.data.code === 200) { - otherResponse.data.data = await this.decryptData(otherResponse.data.data) + otherResponse.data.data = JSON.parse(otherResponse.data.data) if (otherResponse.data.data === null) { logger.info('获取逆境深塔数据失败,返回数据为null'); return { status: false, msg: "官方API返回null,请检查库街区展示是否打开" }; @@ -431,7 +431,7 @@ class Waves { } // 获取公共Cookie - async getPublicCookie() { + async pubCookie() { if (!Config.getConfig().use_public_cookie) return false; const keys = await redis.keys('Yunzai:waves:users:*'); @@ -476,15 +476,6 @@ class Waves { return { status: false, msg: '获取活动列表失败,疑似网络问题,请检查控制台日志' }; } } - - // 解密数据 - async decryptData(value) { - const key = Buffer.from("XSNLFgNCth8j8oJI3cNIdw==", 'base64'); - const encrypted = Buffer.from(value, 'base64'); - const decipher = crypto.createDecipheriv('aes-128-ecb', key, null); - const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]); - return JSON.parse(decrypted.toString('utf8')); - } } export default Waves; \ No newline at end of file diff --git a/package.json b/package.json index 70bbd50..3302680 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "waves-plugin", - "version": "1.4.5", + "version": "1.4.6", "description": "基于 Yunzai 的鸣潮游戏数据查询插件", "main": "index.js", "scripts": {