diff --git a/apps/abyss.js b/apps/abyss.js index 6dfb0ec..09d6acd 100644 --- a/apps/abyss.js +++ b/apps/abyss.js @@ -20,12 +20,14 @@ export class Abyss extends ZZZPlugin { }); } async abyss() { - const { api } = await this.getAPI(); + const { api, deviceFp } = await this.getAPI(); await this.getPlayerInfo(); const method = this.e.msg.match(`(上期|往期)`) ? 'zzzChallengePeriod' : 'zzzChallenge'; - const abyssData = await api.getFinalData(method).catch(e => { + const abyssData = await api.getFinalData(method, { + deviceFp, + }).catch(e => { this.reply(e.message); throw e; }); diff --git a/apps/card.js b/apps/card.js index a16a024..62ec20b 100644 --- a/apps/card.js +++ b/apps/card.js @@ -20,22 +20,28 @@ export class Card extends ZZZPlugin { }); } async card() { - const { api } = await this.getAPI(); + const { api, deviceFp } = await this.getAPI(); await this.getPlayerInfo(); - const indexData = await api.getFinalData('zzzIndex').catch(e => { + const indexData = await api.getFinalData('zzzIndex', { + deviceFp, + }).catch(e => { this.reply(e.message); throw e; }); if (!indexData) return false; - let zzzAvatarList = await api.getFinalData('zzzAvatarList').catch(e => { + let zzzAvatarList = await api.getFinalData('zzzAvatarList', { + deviceFp, + }).catch(e => { this.reply(e.message); throw e; }); if (!zzzAvatarList) return false; indexData.avatar_list = zzzAvatarList.avatar_list; - let zzzBuddyList = await api.getFinalData('zzzBuddyList').catch(e => { + let zzzBuddyList = await api.getFinalData('zzzBuddyList', { + deviceFp, + }).catch(e => { this.reply(e.message); throw e; }); diff --git a/apps/deadly.js b/apps/deadly.js index 62d1bde..a38317b 100644 --- a/apps/deadly.js +++ b/apps/deadly.js @@ -20,12 +20,14 @@ export class deadly extends ZZZPlugin { }); } async deadly() { - const { api } = await this.getAPI(); + const { api, deviceFp } = await this.getAPI(); await this.getPlayerInfo(); const method = this.e.msg.match(`(上期|往期)`) ? 'zzzDeadlyPeriod' : 'zzzDeadly'; - const deadlyData = await api.getFinalData(method).catch(e => { + const deadlyData = await api.getFinalData(method, { + deviceFp, + }).catch(e => { this.reply(e.message); throw e; }); diff --git a/apps/monthly.js b/apps/monthly.js index 671a5ae..bbe8e55 100644 --- a/apps/monthly.js +++ b/apps/monthly.js @@ -35,10 +35,11 @@ export class monthly extends ZZZPlugin { } let year = match[3]; let month = match[5]; - const { api } = await this.getAPI(); + const { api, deviceFp } = await this.getAPI(); await this.getPlayerInfo(); const monthlyResponse = await getMonthly( api, + deviceFp, this.getDateString(year, month) ).catch(e => { this.reply(e.message); @@ -60,9 +61,12 @@ export class monthly extends ZZZPlugin { } async monthlyCollect() { - const { api } = await this.getAPI(); + const { api, deviceFp } = await this.getAPI(); await this.getPlayerInfo(); - const collect = await getMonthlyCollect(api).catch(e => { + const collect = await getMonthlyCollect( + api, + deviceFp, + ).catch(e => { this.reply(e.message); throw e; }); diff --git a/apps/note.js b/apps/note.js index e40620f..b9d25e3 100644 --- a/apps/note.js +++ b/apps/note.js @@ -20,9 +20,11 @@ export class Note extends ZZZPlugin { }); } async note() { - const { api } = await this.getAPI(); + const { api, deviceFp } = await this.getAPI(); await this.getPlayerInfo(); - const noteResponse = await api.getFinalData('zzzNote').catch(e => { + const noteResponse = await api.getFinalData('zzzNote', { + deviceFp, + }).catch(e => { this.reply(e.message); throw e; }); diff --git a/apps/panel.js b/apps/panel.js index 7fb8e34..bcd5596 100644 --- a/apps/panel.js +++ b/apps/panel.js @@ -60,11 +60,11 @@ export class Panel extends ZZZPlugin { await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`); return false; } - const { api } = await this.getAPI(); + const { api, deviceFp } = await this.getAPI(); await redis.set(`ZZZ:PANEL:${uid}:LASTTIME`, Date.now()); await this.reply('正在刷新面板列表,请稍候...'); await this.getPlayerInfo(); - const result = await refreshPanelFunction(api).catch(e => { + const result = await refreshPanelFunction(api, deviceFp).catch(e => { this.reply(e.message); throw e; }); diff --git a/lib/avatar.js b/lib/avatar.js index be288cc..123dcbe 100644 --- a/lib/avatar.js +++ b/lib/avatar.js @@ -8,12 +8,15 @@ import settings from './settings.js'; /** * 获取角色基础信息列表 * @param {MysZZZApi} api + * @param {string} deviceFp * @param {boolean} origin 是否返回原始数据 * @returns {Promise} */ -export const getAvatarBasicList = async (api, origin = false) => { +export const getAvatarBasicList = async (api, deviceFp, origin = false) => { // 获取米游社角色列表 - const avatarBaseListData = await api.getFinalData('zzzAvatarList'); + const avatarBaseListData = await api.getFinalData('zzzAvatarList', { + deviceFp, + }); if (!avatarBaseListData) return null; // 是否返回原始数据 if (origin) return avatarBaseListData.avatar_list; @@ -27,17 +30,19 @@ export const getAvatarBasicList = async (api, origin = false) => { /** * 获取角色详细信息列表 * @param {MysZZZApi} api + * @param {string} deviceFp * @returns {Promise} * @param {boolean} origin 是否返回原始数据 */ -export const getAvatarInfoList = async (api, origin = false) => { +export const getAvatarInfoList = async (api, deviceFp, origin = false) => { // 获取角色基础信息列表 - const avatarBaseList = await getAvatarBasicList(api, origin); + const avatarBaseList = await getAvatarBasicList(api, deviceFp, origin); if (!avatarBaseList) return null; // 获取角色详细信息列表 const avatarInfoList = []; for (const item of avatarBaseList) { const data = await api.getFinalData('zzzAvatarInfo', { + deviceFp, query: { id_list: [item.id], }, @@ -90,11 +95,12 @@ export const updatePanelData = (uid, newData) => { /** * 刷新面板 * @param {MysZZZApi} api + * @param {string} deviceFp * @returns {Promise} */ -export const refreshPanel = async api => { +export const refreshPanel = async (api, deviceFp) => { // 获取新数据 - const newData = await getAvatarInfoList(api, true); + const newData = await getAvatarInfoList(api, deviceFp, true); if (!newData) return null; // 合并新旧数据 diff --git a/lib/monthly.js b/lib/monthly.js index a1a258a..7f8eee4 100644 --- a/lib/monthly.js +++ b/lib/monthly.js @@ -22,12 +22,14 @@ export const saveMonthlyNewData = (uid, ...newDatas) => { /** * 获取月度数据 * @param {MysZZZApi} api + * @param {string} deviceFp * @param {string} month * @returns {Promise} */ -export const getMonthly = async (api, month) => { +export const getMonthly = async (api, deviceFp, month) => { // 获取月度数据 const data = await api.getFinalData('zzzMonthly', { + deviceFp, query: { month }, }); saveMonthlyNewData(api.uid, data); @@ -37,11 +39,12 @@ export const getMonthly = async (api, month) => { /** * 月度数据(统计) * @param {MysZZZApi} api + * @param {string} deviceFp * @returns {Promise} */ -export const getMonthlyCollect = async api => { +export const getMonthlyCollect = async (api, deviceFp) => { // 获取当前月度数据 - const currentData = await getMonthly(api, ''); + const currentData = await getMonthly(api, deviceFp, ''); if (!currentData) return null; diff --git a/lib/mysapi.js b/lib/mysapi.js index 2da4f10..0d5a057 100644 --- a/lib/mysapi.js +++ b/lib/mysapi.js @@ -368,13 +368,14 @@ export default class MysZZZApi extends MysApi { } } const device_fp = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:FP`); - if (device_fp) { - data.deviceFp = device_fp; - data.headers['x-rpc-device_fp'] = device_fp; - } const device_id = await redis.get(`ZZZ:DEVICE_FP:${ltuid}:ID`); - if (device_id) { - data.deviceId = device_id; + if (device_fp && device_id) { + data = { + ...data, + deviceFp: device_fp, + deviceId: device_id, + }; + data.headers['x-rpc-device_fp'] = device_fp; data.headers['x-rpc-device_id'] = device_id; } }