diff --git a/apps/gachalog.js b/apps/gachalog.js index 4c6566e..3da2a17 100644 --- a/apps/gachalog.js +++ b/apps/gachalog.js @@ -55,11 +55,6 @@ export class GachaLog extends ZZZPlugin { await this.reply(reply_msg); } async startGachaLog() { - const uid = await this.getUID(); - if (/^(1[0-9])[0-9]{8}/i.test(uid)) { - await this.reply('抽卡记录相应功能只支持国服'); - return false; - } const allowGroup = _.get(settings.getConfig('gacha'), 'allow_group', false); const whiteList = _.get(settings.getConfig('gacha'), 'white_list', []); const blackList = _.get(settings.getConfig('gacha'), 'black_list', []); @@ -118,7 +113,9 @@ export class GachaLog extends ZZZPlugin { return false; } const key = getQueryVariable(msg, 'authkey'); - if (!key) { + const region = getQueryVariable(msg, 'region'); + const game_biz = getQueryVariable(msg, 'game_biz'); + if (!key && !region && !game_biz) { await this.reply('抽卡链接格式错误,请重新发起%抽卡链接', false, { at: true, recallMsg: 100, @@ -127,12 +124,12 @@ export class GachaLog extends ZZZPlugin { return false; } this.finish('gachaLog'); - this.getLogWithOutUID(key); + this.getLogWithOutUID(key, region, game_biz); } async refreshGachaLog() { const uid = await this.getUID(); if (/^(1[0-9])[0-9]{8}/i.test(uid)) { - await this.reply('抽卡记录相应功能只支持国服'); + await this.reply('国际服不支持此功能'); return false; } if (!uid) return false; @@ -172,7 +169,7 @@ export class GachaLog extends ZZZPlugin { ); return false; } - async getLogWithOutUID(key) { + async getLogWithOutUID(key, region, game_biz) { await this.reply( '抽卡链接解析成功,正在查询抽卡记录,可能耗费一段时间,请勿重复发送', false, @@ -188,7 +185,8 @@ export class GachaLog extends ZZZPlugin { type[0], 1, '0', - '1' + region, + game_biz ); if (log && log.list && log.list.length > 0) { uid = log.list[0].uid; @@ -203,7 +201,7 @@ export class GachaLog extends ZZZPlugin { }); return false; } - const { data, count } = await updateGachaLog(key, uid); + const { data, count } = await updateGachaLog(key, uid, region, game_biz); let msg = []; msg.push(`抽卡记录更新成功,共${Object.keys(data).length}个卡池`); for (const name in data) { @@ -219,10 +217,6 @@ export class GachaLog extends ZZZPlugin { async gachaLogAnalysis() { const uid = await this.getUID(); - if (/^(1[0-9])[0-9]{8}/i.test(uid)) { - await this.reply('抽卡记录相应功能只支持国服'); - return false; - } if (!uid) return false; await this.getPlayerInfo(); await this.reply('正在分析抽卡记录,请稍等', false, { @@ -249,7 +243,7 @@ export class GachaLog extends ZZZPlugin { async getGachaLink() { const uid = await this.getUID(); if (/^(1[0-9])[0-9]{8}/i.test(uid)) { - await this.reply('抽卡记录相应功能只支持国服'); + await this.reply('国际服不支持此功能'); return false; } if (!uid) return false; diff --git a/lib/gacha.js b/lib/gacha.js index 2b87279..1bf383c 100644 --- a/lib/gacha.js +++ b/lib/gacha.js @@ -25,7 +25,7 @@ import { getZZZGachaLogByAuthkey } from './gacha/core.js'; * } * }>} 更新后的抽卡数据 */ -export const updateGachaLog = async (authKey, uid) => { +export const updateGachaLog = async (authKey, uid, region, game_biz) => { // 获取之前的抽卡数据 let previousLog = getGachaLog(uid); if (!previousLog) { @@ -61,7 +61,9 @@ export const updateGachaLog = async (authKey, uid) => { type, type[0], page, - endId + endId, + region, + game_biz ); if (!log || !log?.list || log?.list?.length === 0) { break; diff --git a/lib/gacha/core.js b/lib/gacha/core.js index 523a047..ec37bce 100644 --- a/lib/gacha/core.js +++ b/lib/gacha/core.js @@ -1,4 +1,4 @@ -import { ZZZ_GET_GACHA_LOG_API } from '../mysapi/api.js'; +import { ZZZ_GET_GACHA_LOG_API, ZZZ_GET_GACHA_OS_LOG_API } from '../mysapi/api.js'; import request from '../../utils/request.js'; import { ZZZGachaLogResp } from '../../model/gacha.js'; @@ -18,11 +18,12 @@ export const getZZZGachaLink = async ( initLogGachaBaseType = '2', page = 1, endId = '0', - size = '20' + serverId, + game_biz ) => { - // 暂时直接写死服务器为国服 - const serverId = 'prod_gf_cn'; - const url = ZZZ_GET_GACHA_LOG_API; + const region = serverId || 'prod_gf_cn' + const gamebiz = game_biz || 'nap_cn' + const url = gamebiz == 'nap_global' ? ZZZ_GET_GACHA_OS_LOG_API : ZZZ_GET_GACHA_LOG_API const timestamp = Math.floor(Date.now() / 1000); // 请求参数 const params = new URLSearchParams({ @@ -36,13 +37,13 @@ export const getZZZGachaLink = async ( lang: 'zh-cn', device_type: 'mobile', plat_type: 'ios', - region: serverId, + region: region, authkey: authKey, - game_biz: 'nap_cn', + game_biz: gamebiz, gacha_type: gachaType, real_gacha_type: initLogGachaBaseType, page: page, - size: size, + size: '20', end_id: endId, }); // 完整链接 @@ -63,7 +64,9 @@ export const getZZZGachaLogByAuthkey = async ( gachaType = '2001', initLogGachaBaseType = '2', page = 1, - endId = '0' + endId = '0', + region, + game_biz ) => { // 获取抽卡链接 const link = await getZZZGachaLink( @@ -71,7 +74,9 @@ export const getZZZGachaLogByAuthkey = async ( gachaType, initLogGachaBaseType, page, - endId + endId, + region, + game_biz ); // 发送请求 const response = await request(link, { diff --git a/lib/mysapi/api.js b/lib/mysapi/api.js index d72eaae..410f435 100644 --- a/lib/mysapi/api.js +++ b/lib/mysapi/api.js @@ -14,3 +14,7 @@ export const ZZZ_API = `${NEW_URL}/event/game_record_zzz/api/zzz`, export const PUBLIC_API = 'https://public-operation-nap.mihoyo.com', PUBILC_GACHA_LOG_API = `${PUBLIC_API}/common/gacha_record/api`, ZZZ_GET_GACHA_LOG_API = `${PUBILC_GACHA_LOG_API}/getGachaLog`; + +export const PUBLIC_OS_API = 'https://public-operation-nap-sg.hoyoverse.com', + PUBILC_GACHA_OS_LOG_API = `${PUBLIC_OS_API}/common/gacha_record/api`, + ZZZ_GET_GACHA_OS_LOG_API = `${PUBILC_GACHA_OS_LOG_API}/getGachaLog`; \ No newline at end of file