feat:国际服 抽卡链接 & 抽卡分析

This commit is contained in:
kissnavel 2025-08-24 22:04:28 +08:00
parent 607b85c922
commit 6c475878a7
4 changed files with 33 additions and 28 deletions

View file

@ -55,11 +55,6 @@ export class GachaLog extends ZZZPlugin {
await this.reply(reply_msg); await this.reply(reply_msg);
} }
async startGachaLog() { 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 allowGroup = _.get(settings.getConfig('gacha'), 'allow_group', false);
const whiteList = _.get(settings.getConfig('gacha'), 'white_list', []); const whiteList = _.get(settings.getConfig('gacha'), 'white_list', []);
const blackList = _.get(settings.getConfig('gacha'), 'black_list', []); const blackList = _.get(settings.getConfig('gacha'), 'black_list', []);
@ -118,7 +113,9 @@ export class GachaLog extends ZZZPlugin {
return false; return false;
} }
const key = getQueryVariable(msg, 'authkey'); 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, { await this.reply('抽卡链接格式错误,请重新发起%抽卡链接', false, {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
@ -127,12 +124,12 @@ export class GachaLog extends ZZZPlugin {
return false; return false;
} }
this.finish('gachaLog'); this.finish('gachaLog');
this.getLogWithOutUID(key); this.getLogWithOutUID(key, region, game_biz);
} }
async refreshGachaLog() { async refreshGachaLog() {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) { if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
await this.reply('抽卡记录相应功能只支持国服'); await this.reply('国际服不支持此功能');
return false; return false;
} }
if (!uid) return false; if (!uid) return false;
@ -172,7 +169,7 @@ export class GachaLog extends ZZZPlugin {
); );
return false; return false;
} }
async getLogWithOutUID(key) { async getLogWithOutUID(key, region, game_biz) {
await this.reply( await this.reply(
'抽卡链接解析成功,正在查询抽卡记录,可能耗费一段时间,请勿重复发送', '抽卡链接解析成功,正在查询抽卡记录,可能耗费一段时间,请勿重复发送',
false, false,
@ -188,7 +185,8 @@ export class GachaLog extends ZZZPlugin {
type[0], type[0],
1, 1,
'0', '0',
'1' region,
game_biz
); );
if (log && log.list && log.list.length > 0) { if (log && log.list && log.list.length > 0) {
uid = log.list[0].uid; uid = log.list[0].uid;
@ -203,7 +201,7 @@ export class GachaLog extends ZZZPlugin {
}); });
return false; return false;
} }
const { data, count } = await updateGachaLog(key, uid); const { data, count } = await updateGachaLog(key, uid, region, game_biz);
let msg = []; let msg = [];
msg.push(`抽卡记录更新成功,共${Object.keys(data).length}个卡池`); msg.push(`抽卡记录更新成功,共${Object.keys(data).length}个卡池`);
for (const name in data) { for (const name in data) {
@ -219,10 +217,6 @@ export class GachaLog extends ZZZPlugin {
async gachaLogAnalysis() { async gachaLogAnalysis() {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
await this.reply('抽卡记录相应功能只支持国服');
return false;
}
if (!uid) return false; if (!uid) return false;
await this.getPlayerInfo(); await this.getPlayerInfo();
await this.reply('正在分析抽卡记录,请稍等', false, { await this.reply('正在分析抽卡记录,请稍等', false, {
@ -249,7 +243,7 @@ export class GachaLog extends ZZZPlugin {
async getGachaLink() { async getGachaLink() {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) { if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
await this.reply('抽卡记录相应功能只支持国服'); await this.reply('国际服不支持此功能');
return false; return false;
} }
if (!uid) return false; if (!uid) return false;

View file

@ -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); let previousLog = getGachaLog(uid);
if (!previousLog) { if (!previousLog) {
@ -61,7 +61,9 @@ export const updateGachaLog = async (authKey, uid) => {
type, type,
type[0], type[0],
page, page,
endId endId,
region,
game_biz
); );
if (!log || !log?.list || log?.list?.length === 0) { if (!log || !log?.list || log?.list?.length === 0) {
break; break;

View file

@ -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 request from '../../utils/request.js';
import { ZZZGachaLogResp } from '../../model/gacha.js'; import { ZZZGachaLogResp } from '../../model/gacha.js';
@ -18,11 +18,12 @@ export const getZZZGachaLink = async (
initLogGachaBaseType = '2', initLogGachaBaseType = '2',
page = 1, page = 1,
endId = '0', endId = '0',
size = '20' serverId,
game_biz
) => { ) => {
// 暂时直接写死服务器为国服 const region = serverId || 'prod_gf_cn'
const serverId = 'prod_gf_cn'; const gamebiz = game_biz || 'nap_cn'
const url = ZZZ_GET_GACHA_LOG_API; const url = gamebiz == 'nap_global' ? ZZZ_GET_GACHA_OS_LOG_API : ZZZ_GET_GACHA_LOG_API
const timestamp = Math.floor(Date.now() / 1000); const timestamp = Math.floor(Date.now() / 1000);
// 请求参数 // 请求参数
const params = new URLSearchParams({ const params = new URLSearchParams({
@ -36,13 +37,13 @@ export const getZZZGachaLink = async (
lang: 'zh-cn', lang: 'zh-cn',
device_type: 'mobile', device_type: 'mobile',
plat_type: 'ios', plat_type: 'ios',
region: serverId, region: region,
authkey: authKey, authkey: authKey,
game_biz: 'nap_cn', game_biz: gamebiz,
gacha_type: gachaType, gacha_type: gachaType,
real_gacha_type: initLogGachaBaseType, real_gacha_type: initLogGachaBaseType,
page: page, page: page,
size: size, size: '20',
end_id: endId, end_id: endId,
}); });
// 完整链接 // 完整链接
@ -63,7 +64,9 @@ export const getZZZGachaLogByAuthkey = async (
gachaType = '2001', gachaType = '2001',
initLogGachaBaseType = '2', initLogGachaBaseType = '2',
page = 1, page = 1,
endId = '0' endId = '0',
region,
game_biz
) => { ) => {
// 获取抽卡链接 // 获取抽卡链接
const link = await getZZZGachaLink( const link = await getZZZGachaLink(
@ -71,7 +74,9 @@ export const getZZZGachaLogByAuthkey = async (
gachaType, gachaType,
initLogGachaBaseType, initLogGachaBaseType,
page, page,
endId endId,
region,
game_biz
); );
// 发送请求 // 发送请求
const response = await request(link, { const response = await request(link, {

View file

@ -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', export const PUBLIC_API = 'https://public-operation-nap.mihoyo.com',
PUBILC_GACHA_LOG_API = `${PUBLIC_API}/common/gacha_record/api`, PUBILC_GACHA_LOG_API = `${PUBLIC_API}/common/gacha_record/api`,
ZZZ_GET_GACHA_LOG_API = `${PUBILC_GACHA_LOG_API}/getGachaLog`; 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`;