mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-22 19:10:53 +08:00
新增指令更新抽卡记录
This commit is contained in:
parent
16cb65184a
commit
36a300bb28
27
CHANGELOG.md
27
CHANGELOG.md
@ -1,25 +1,14 @@
|
|||||||
# 1.1.8
|
# 1.1.9
|
||||||
|
* 优化部分代码以及配置
|
||||||
|
* 新增指令`#更新抽卡记录`
|
||||||
|
*必须绑定stoken
|
||||||
|
* 默认配置文件位于****xiaoyao-cvs-plugin/defSet/config/config.yaml****
|
||||||
|
*后续叠加配置数据会在此文件中增加
|
||||||
|
# 1.1.2~1.1.8
|
||||||
* 新增指令`#ck查询`
|
* 新增指令`#ck查询`
|
||||||
* 可查询当前cookie绑定状态的签到信息以及米游币信息数据
|
* 可查询当前cookie绑定状态的签到信息以及米游币信息数据
|
||||||
# 1.1.7
|
|
||||||
* 新增指令`#米币查询`
|
* 新增指令`#米币查询`
|
||||||
* 新增`道具图鉴`图鉴数据
|
* 新增`道具图鉴`图鉴数据
|
||||||
* 修正米游币签到逻辑
|
|
||||||
* 补充指令`原神签到`
|
|
||||||
* 由于原神签到有提示验证码问题可能导致签到不了
|
|
||||||
* 补充指令 `原神签到`以及`米社原神全部签到`进行二次签到避免漏签
|
|
||||||
# 1.1.6
|
|
||||||
* 通过发送token以及devId给机器人实现绑定
|
|
||||||
* 格式支持`ai=*;ci=*;oi=*;ct=***********;si=**************;bi=***********;devId=***********`
|
|
||||||
* 新增指令`#云原神签到`可进行云原神签到
|
|
||||||
* 新增指令`#云原神查询`可查询当前绑定token的剩余时间
|
|
||||||
* 新增云原神自动签到
|
|
||||||
* 新增`云原神帮助`
|
|
||||||
# 1.1.5
|
|
||||||
* 体力模板列表更改为转发形式更具体呈现效果
|
|
||||||
* 新增自动签到配置
|
|
||||||
*可在`xiaoyao-cvs-plugin/config/config.yaml`中修改是否启用自动签到
|
|
||||||
# 1.1.2~1.1.4
|
|
||||||
* 新增指令`#米游币全部签到`
|
* 新增指令`#米游币全部签到`
|
||||||
*为所有存在的stoken进行社区米游币签到
|
*为所有存在的stoken进行社区米游币签到
|
||||||
* 新增指令`#米社全部签到`
|
* 新增指令`#米社全部签到`
|
||||||
@ -57,4 +46,4 @@
|
|||||||
*可以通过`#体力模板设置随机`来恢复之前的状态
|
*可以通过`#体力模板设置随机`来恢复之前的状态
|
||||||
* 增加`#**图鉴`用于查看逍遥全图鉴
|
* 增加`#**图鉴`用于查看逍遥全图鉴
|
||||||
* 增加`#图鉴更新`用于获取图鉴数据
|
* 增加`#图鉴更新`用于获取图鉴数据
|
||||||
* 增加`#图鉴插件(强制)更新`用于插件包更新
|
* 增加`#图鉴插件(强制)更新`用于插件包更新
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
} from "../components/Changelog.js";
|
} from "../components/Changelog.js";
|
||||||
import {
|
import {
|
||||||
rule as userRule,
|
rule as userRule,
|
||||||
userInfo
|
userInfo,gclog
|
||||||
} from "./user.js"
|
} from "./user.js"
|
||||||
import {
|
import {
|
||||||
rule as signRule,
|
rule as signRule,
|
||||||
@ -33,11 +33,11 @@ import {
|
|||||||
cookiesDocHelp,
|
cookiesDocHelp,
|
||||||
signlist,yunSignlist,yunAllSign,
|
signlist,yunSignlist,yunAllSign,
|
||||||
allMysSign,yunSign,sendyunTime,yuntoken,yunHelp,
|
allMysSign,yunSign,sendyunTime,yuntoken,yunHelp,
|
||||||
allSign,bbsSeach
|
allSign,bbsSeach,delSign
|
||||||
} from "./sign.js"
|
} from "./sign.js"
|
||||||
export {
|
export {
|
||||||
updateRes,yunSignlist,
|
updateRes,yunSignlist,delSign,
|
||||||
signlist,
|
signlist,gclog,
|
||||||
updateMiaoPlugin,userInfo,
|
updateMiaoPlugin,userInfo,
|
||||||
sign,bbsSeach,
|
sign,bbsSeach,
|
||||||
versionInfo,yunAllSign,
|
versionInfo,yunAllSign,
|
||||||
|
82
apps/user.js
82
apps/user.js
@ -6,7 +6,7 @@ import {
|
|||||||
Data
|
Data
|
||||||
} from "../components/index.js";
|
} from "../components/index.js";
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import lodash from 'lodash';
|
||||||
import Common from "../components/Common.js";
|
import Common from "../components/Common.js";
|
||||||
import {
|
import {
|
||||||
isV3
|
isV3
|
||||||
@ -23,25 +23,32 @@ export const rule = {
|
|||||||
reg: "^#*(ck|stoken|cookie|cookies|签到)查询$",
|
reg: "^#*(ck|stoken|cookie|cookies|签到)查询$",
|
||||||
describe: "用户个人信息查询"
|
describe: "用户个人信息查询"
|
||||||
},
|
},
|
||||||
|
gclog: {
|
||||||
|
reg: "^#*更新抽卡记录$",
|
||||||
|
describe: "更新抽卡记录"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export async function userInfo(e,{render}){
|
const _path = process.cwd();
|
||||||
let user=new User(e);
|
export async function userInfo(e, {
|
||||||
|
render
|
||||||
|
}) {
|
||||||
|
let user = new User(e);
|
||||||
e.reply("正在获取角色信息请稍等...")
|
e.reply("正在获取角色信息请稍等...")
|
||||||
let sumData=await user.getCkData()
|
let sumData = await user.getCkData()
|
||||||
let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
||||||
let day = moment(new Date()).format("yyyy年MM月DD日 HH:mm") + " " + week[new Date().getDay()];
|
let day = moment(new Date()).format("yyyy年MM月DD日 HH:mm") + " " + week[new Date().getDay()];
|
||||||
if(Object.keys(sumData).length==0){
|
if (Object.keys(sumData).length == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let ck="";
|
let ck = "";
|
||||||
if(e.cookie){
|
if (e.cookie) {
|
||||||
ck= user.getCookieMap(e.cookie);
|
ck = user.getCookieMap(e.cookie);
|
||||||
ck=ck.get("ltuid")
|
ck = ck.get("ltuid")
|
||||||
}
|
}
|
||||||
return await Common.render(`user/userInfo`, {
|
return await Common.render(`user/userInfo`, {
|
||||||
uid: e.user_id,
|
uid: e.user_id,
|
||||||
ltuid:ck||e.user_id,
|
ltuid: ck || e.user_id,
|
||||||
save_id:e.user_id,
|
save_id: e.user_id,
|
||||||
day,
|
day,
|
||||||
sumData
|
sumData
|
||||||
}, {
|
}, {
|
||||||
@ -50,4 +57,55 @@ export async function userInfo(e,{render}){
|
|||||||
scale: 1.2
|
scale: 1.2
|
||||||
})
|
})
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function gclog(e) {
|
||||||
|
let user = new User(e);
|
||||||
|
await user.cookie(e)
|
||||||
|
if(!e.cookies){
|
||||||
|
e.reply("暂未绑定stoken\n请先绑定stoken")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let miHoYoApi = new MihoYoApi(e);
|
||||||
|
let kkbody = await miHoYoApi.getbody("原神");
|
||||||
|
const objData = await miHoYoApi.getUserInfo(kkbody)
|
||||||
|
let data = objData.data
|
||||||
|
e.region = e.uid[0] == 5 ? "cn_qd01" : "cn_gf01"
|
||||||
|
let authkeyrow = await miHoYoApi.authkey(data);
|
||||||
|
let authkey=authkeyrow.data["authkey"]
|
||||||
|
let postdata = {
|
||||||
|
'authkey_ver': '1',
|
||||||
|
'sign_type': '2',
|
||||||
|
'auth_appid': 'webview_gacha',
|
||||||
|
'init_type': '301',
|
||||||
|
'gacha_id': 'fecafa7b6560db5f3182222395d88aaa6aaac1bc',
|
||||||
|
'timestamp': Math.floor(Date.now() / 1000), //当前时间搓
|
||||||
|
'lang': 'zh-cn',
|
||||||
|
'device_type': 'mobile',
|
||||||
|
'plat_type': 'ios',
|
||||||
|
'region': e.region,
|
||||||
|
'authkey': encodeURIComponent(authkey),
|
||||||
|
'game_biz': 'hk4e_cn',
|
||||||
|
'gacha_type': "301",
|
||||||
|
'page': 1,
|
||||||
|
'size': 5,
|
||||||
|
'end_id': 0,
|
||||||
|
}
|
||||||
|
let url = `https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog?`
|
||||||
|
for (let item of Object.keys(postdata)) {
|
||||||
|
url += `${item}=${postdata[item]}&`
|
||||||
|
}
|
||||||
|
let plyurl = url.substring(0, url.length - 1);
|
||||||
|
e.msg=plyurl
|
||||||
|
if(isV3){
|
||||||
|
let gclog= (await import(`file:///${_path}/plugins/genshin/model/gachaLog.js`)).default
|
||||||
|
await (new gclog(e)).logUrl()
|
||||||
|
} else {
|
||||||
|
let {
|
||||||
|
bing
|
||||||
|
} = (await import(`file:///${_path}/lib/app/gachaLog.js`))
|
||||||
|
e.isPrivate = true;
|
||||||
|
await bing(e)
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -12,15 +12,20 @@ import {
|
|||||||
isV3
|
isV3
|
||||||
} from '../../components/Changelog.js';
|
} from '../../components/Changelog.js';
|
||||||
import fetch from "node-fetch"
|
import fetch from "node-fetch"
|
||||||
|
|
||||||
const APP_VERSION = "2.35.2";
|
const APP_VERSION = "2.35.2";
|
||||||
|
const mhyVersion = "2.11.1";
|
||||||
const salt = "ZSHlXeQUBis52qD1kEgKt5lUYed4b7Bb";
|
const salt = "ZSHlXeQUBis52qD1kEgKt5lUYed4b7Bb";
|
||||||
const salt2="t0qEgfub6cvueAPgR5m9aQWWVciEer7v";
|
const salt2 = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v";
|
||||||
const saltWeb="N50pqm7FSy2AkFz2B3TqtuZMJ5TOl3Ep";
|
const saltWeb = "N50pqm7FSy2AkFz2B3TqtuZMJ5TOl3Ep";
|
||||||
|
const oldsalt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9";
|
||||||
//b253c83ab2609b1b600eddfe974df47b
|
//b253c83ab2609b1b600eddfe974df47b
|
||||||
const DEVICE_ID = utils.randomString(32).toUpperCase();
|
const DEVICE_ID = utils.randomString(32).toUpperCase();
|
||||||
const DEVICE_NAME = utils.randomString(_.random(1, 10));
|
const DEVICE_NAME = utils.randomString(_.random(1, 10));
|
||||||
const _path = process.cwd();
|
const _path = process.cwd();
|
||||||
let YamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
|
let YamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
|
||||||
|
let web_api = `https://api-takumi.mihoyo.com`
|
||||||
|
let hk4_api = `https://hk4e-api.mihoyo.com`;
|
||||||
// 米游社的版块
|
// 米游社的版块
|
||||||
const boards = {
|
const boards = {
|
||||||
honkai3rd: {
|
honkai3rd: {
|
||||||
@ -82,7 +87,7 @@ const boards = {
|
|||||||
url: "https://bbs.mihoyo.com/zzz/"
|
url: "https://bbs.mihoyo.com/zzz/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let web_api = `https://api-takumi.mihoyo.com`
|
|
||||||
export default class MihoYoApi {
|
export default class MihoYoApi {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
@ -95,7 +100,7 @@ export default class MihoYoApi {
|
|||||||
let data = this.getStoken(this.e.user_id);
|
let data = this.getStoken(this.e.user_id);
|
||||||
if (data) {
|
if (data) {
|
||||||
this.cookies = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
this.cookies = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
||||||
this.e.cookies=this.cookies
|
this.e.cookies = this.cookies
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Data.createDir("", YamlDataUrl, false);
|
Data.createDir("", YamlDataUrl, false);
|
||||||
@ -114,44 +119,46 @@ export default class MihoYoApi {
|
|||||||
// 获取账号信息
|
// 获取账号信息
|
||||||
const objData = await this.getUserInfo(kkbody)
|
const objData = await this.getUserInfo(kkbody)
|
||||||
let data = objData.data
|
let data = objData.data
|
||||||
if (data?.list?.length == 0||!data?.list) {
|
if (data?.list?.length == 0 || !data?.list) {
|
||||||
return {
|
return {
|
||||||
message: `未绑定${name}信息`
|
message: `未绑定${name}信息`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let message = `\n${name}共计${data.list.length}个账号\n`;
|
let message = `\n${name}共计${data.list.length}个账号\n`;
|
||||||
let upData=[];
|
let upData = [];
|
||||||
for (let item of data.list) {
|
for (let item of data.list) {
|
||||||
item.upName=name
|
item.upName = name
|
||||||
let objshuj = await this.isPostSign(kkbody, item.game_uid, item.region)
|
let objshuj = await this.isPostSign(kkbody, item.game_uid, item.region)
|
||||||
item.total_sign_day=objshuj?.data?.total_sign_day
|
item.total_sign_day = objshuj?.data?.total_sign_day
|
||||||
if(objshuj?.data?.is_sign){
|
if (objshuj?.data?.is_sign) {
|
||||||
item.is_sign=true;
|
item.is_sign = true;
|
||||||
// console.log(objshuj)
|
// console.log(objshuj)
|
||||||
message+=`游戏id:${item.nickname}-${item.game_uid}:今日已签到~\n`;
|
message += `游戏id:${item.nickname}-${item.game_uid}:今日已签到~\n`;
|
||||||
}else{
|
} else {
|
||||||
objshuj=(await this.postSign(kkbody, item.game_uid, item.region))
|
objshuj = (await this.postSign(kkbody, item.game_uid, item.region))
|
||||||
if(objshuj?.data?.gt){
|
if (objshuj?.data?.gt) {
|
||||||
item.is_sign=false;
|
item.is_sign = false;
|
||||||
message+=`游戏id:${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到`;
|
message += `游戏id:${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到`;
|
||||||
}else{
|
} else {
|
||||||
item.total_sign_day++;
|
item.total_sign_day++;
|
||||||
item.is_sign=true;
|
item.is_sign = true;
|
||||||
message += `游戏id:${item.nickname}-${item.game_uid}:${objshuj.message=="OK"?"签到成功":objshuj.message}\n`
|
message +=
|
||||||
|
`游戏id:${item.nickname}-${item.game_uid}:${objshuj.message=="OK"?"签到成功":objshuj.message}\n`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//获取签到信息和奖励信息
|
//获取签到信息和奖励信息
|
||||||
const SignInfo = await this.getSignInfo(kkbody)
|
const SignInfo = await this.getSignInfo(kkbody)
|
||||||
if (SignInfo) {
|
if (SignInfo) {
|
||||||
let awards= SignInfo.data.awards[item.total_sign_day-1];
|
let awards = SignInfo.data.awards[item.total_sign_day - 1];
|
||||||
item.awards=awards.name+"*"+awards.cnt
|
item.awards = awards.name + "*" + awards.cnt
|
||||||
}
|
}
|
||||||
upData.push(item)
|
upData.push(item)
|
||||||
await utils.randomSleepAsync();
|
await utils.randomSleepAsync();
|
||||||
}
|
}
|
||||||
// 签到操作
|
// 签到操作
|
||||||
return {
|
return {
|
||||||
message,upData
|
message,
|
||||||
|
upData
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Bot.logger.mark(`error.message`, error.message)
|
Bot.logger.mark(`error.message`, error.message)
|
||||||
@ -159,8 +166,10 @@ export default class MihoYoApi {
|
|||||||
}
|
}
|
||||||
async forumSign(forumId) {
|
async forumSign(forumId) {
|
||||||
const url = `https://bbs-api.mihoyo.com/apihub/app/api/signIn`;
|
const url = `https://bbs-api.mihoyo.com/apihub/app/api/signIn`;
|
||||||
this.forumId=forumId;
|
this.forumId = forumId;
|
||||||
let res = await superagent.post(url).set(this._getHeader()).send(JSON.stringify({gids:forumId*1})).timeout(10000);
|
let res = await superagent.post(url).set(this._getHeader()).send(JSON.stringify({
|
||||||
|
gids: forumId * 1
|
||||||
|
})).timeout(10000);
|
||||||
let resObj = JSON.parse(res.text);
|
let resObj = JSON.parse(res.text);
|
||||||
// Bot.logger.mark(`ForumSign: ${res.text}`);
|
// Bot.logger.mark(`ForumSign: ${res.text}`);
|
||||||
return resObj;
|
return resObj;
|
||||||
@ -173,7 +182,7 @@ export default class MihoYoApi {
|
|||||||
}
|
}
|
||||||
// 获取签到状态和奖励信息
|
// 获取签到状态和奖励信息
|
||||||
async getSignInfo(board) {
|
async getSignInfo(board) {
|
||||||
let url=`${web_api}/event/luna/home?lang=zh-cn&`
|
let url = `${web_api}/event/luna/home?lang=zh-cn&`
|
||||||
if (board.name == "原神") {
|
if (board.name == "原神") {
|
||||||
url = `${web_api}/event/bbs_sign_reward/home?`
|
url = `${web_api}/event/bbs_sign_reward/home?`
|
||||||
}
|
}
|
||||||
@ -244,14 +253,11 @@ export default class MihoYoApi {
|
|||||||
let reward_msg = item.msg;
|
let reward_msg = item.msg;
|
||||||
url = `https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/ackNotification?id=${reward_id}`;
|
url = `https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/ackNotification?id=${reward_id}`;
|
||||||
res = await superagent.post(url).set(this.getyunHeader()).timeout(10000);
|
res = await superagent.post(url).set(this.getyunHeader()).timeout(10000);
|
||||||
let log_msg = `\n领取奖励,ID:${reward_id},Msg:${reward_msg.msg}`;
|
let log_msg = `\n领取奖励,ID:${reward_id},Msg:${reward_msg}`;
|
||||||
Bot.logger.info(log_msg)
|
Bot.logger.info(log_msg)
|
||||||
sendMSg += log_msg
|
sendMSg += log_msg
|
||||||
}
|
}
|
||||||
// log_msg="\n\n"+(await this.logyunGenshen()).log_msg
|
|
||||||
// sendMSg += log_msg
|
|
||||||
resObj.sendMSg = sendMSg;
|
resObj.sendMSg = sendMSg;
|
||||||
// Bot.logger.info(log_msg)
|
|
||||||
return resObj;
|
return resObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +273,8 @@ export default class MihoYoApi {
|
|||||||
|
|
||||||
async stoken(cookie, e) {
|
async stoken(cookie, e) {
|
||||||
this.e = e;
|
this.e = e;
|
||||||
let datalist=this.getStoken(e.user_id) || {}
|
let datalist = this.getStoken(e.user_id) || {}
|
||||||
if (Object.keys(datalist).length>0){
|
if (Object.keys(datalist).length > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const map = this.getCookieMap(cookie);
|
const map = this.getCookieMap(cookie);
|
||||||
@ -306,10 +312,10 @@ export default class MihoYoApi {
|
|||||||
stoken: data.data.list[0].token,
|
stoken: data.data.list[0].token,
|
||||||
ltoken: data.data.list[1].token,
|
ltoken: data.data.list[1].token,
|
||||||
uid: e.uid,
|
uid: e.uid,
|
||||||
userId:e.user_id,
|
userId: e.user_id,
|
||||||
is_sign:true
|
is_sign: true
|
||||||
}
|
}
|
||||||
gsCfg.saveBingStoken(e.user_id,datalist)
|
gsCfg.saveBingStoken(e.user_id, datalist)
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -340,24 +346,26 @@ export default class MihoYoApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//社区签到ds
|
//社区签到ds
|
||||||
get_ds2(q="",b){
|
get_ds2(q = "", b) {
|
||||||
let n = salt2
|
let n = salt2
|
||||||
let i = Math.floor(Date.now() / 1000)
|
let i = Math.floor(Date.now() / 1000)
|
||||||
let r = _.random(100001,200000)
|
let r = _.random(100001, 200000)
|
||||||
let add = `&b=${b}&q=${q}`
|
let add = `&b=${b}&q=${q}`
|
||||||
let c= md5("salt=" + n + "&t=" + i + "&r=" + r + add)
|
let c = md5("salt=" + n + "&t=" + i + "&r=" + r + add)
|
||||||
return `${i},${r},${c}`
|
return `${i},${r},${c}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 米游币任务的 headers
|
// 米游币任务的 headers
|
||||||
_getHeader() {
|
_getHeader() {
|
||||||
const randomStr = utils.randomString(6);
|
const randomStr = utils.randomString(6);
|
||||||
const timestamp = Math.floor(Date.now() / 1000)
|
const timestamp = Math.floor(Date.now() / 1000)
|
||||||
let sign = md5(`salt=${salt}&t=${timestamp}&r=${randomStr}`);
|
let sign = md5(`salt=${salt}&t=${timestamp}&r=${randomStr}`);
|
||||||
let ds=`${timestamp},${randomStr},${sign}`
|
let ds = `${timestamp},${randomStr},${sign}`
|
||||||
if(this.forumId){
|
if (this.forumId) {
|
||||||
ds = this.get_ds2("",JSON.stringify({gids:this.forumId*1}));
|
ds = this.get_ds2("", JSON.stringify({
|
||||||
this.forumId="";
|
gids: this.forumId * 1
|
||||||
|
}));
|
||||||
|
this.forumId = "";
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
'Cookie': this.cookies,
|
'Cookie': this.cookies,
|
||||||
@ -395,7 +403,48 @@ export default class MihoYoApi {
|
|||||||
"User-Agent": "okhttp/3.14.9"
|
"User-Agent": "okhttp/3.14.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//一个奇怪的请求头
|
||||||
|
getHeader() {
|
||||||
|
return {
|
||||||
|
'x-rpc-app_version': mhyVersion,
|
||||||
|
'User-Agent': `Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1`,
|
||||||
|
'x-rpc-client_type': '5',
|
||||||
|
'Referer': 'https://webstatic.mihoyo.com/',
|
||||||
|
'Origin': 'https://webstatic.mihoyo.com',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
old_version_get_ds_token() {
|
||||||
|
let n = 'N50pqm7FSy2AkFz2B3TqtuZMJ5TOl3Ep'
|
||||||
|
let i = Math.floor(Date.now() / 1000)
|
||||||
|
let r = utils.randomString(6)
|
||||||
|
let c = md5('salt=' + n + '&t=' + i + '&r=' + r)
|
||||||
|
return i + ',' + r + ',' + c
|
||||||
|
}
|
||||||
|
async authkey(e) {
|
||||||
|
let url = `${web_api}/binding/api/genAuthKey`;
|
||||||
|
let HEADER = this.getHeader();
|
||||||
|
HEADER['Cookie'] = this.cookies
|
||||||
|
HEADER['DS'] = this.old_version_get_ds_token()
|
||||||
|
HEADER['User-Agent'] = 'okhttp/4.8.0'
|
||||||
|
HEADER['x-rpc-app_version'] = '2.35.2'
|
||||||
|
HEADER['x-rpc-sys_version'] = '12'
|
||||||
|
HEADER['x-rpc-client_type'] = '5'
|
||||||
|
HEADER['x-rpc-channel'] = 'mihoyo'
|
||||||
|
HEADER['x-rpc-device_id'] = utils.randomString(32).toUpperCase();
|
||||||
|
HEADER['x-rpc-device_name'] = utils.randomString(_.random(1, 10));
|
||||||
|
HEADER['x-rpc-device_model'] = 'Mi 10'
|
||||||
|
HEADER['Referer'] = 'https://app.mihoyo.com'
|
||||||
|
HEADER['Host'] = 'api-takumi.mihoyo.com'
|
||||||
|
let data = {
|
||||||
|
'auth_appid': 'webview_gacha',
|
||||||
|
'game_biz': 'hk4e_cn',
|
||||||
|
'game_uid': this.e.uid * 1,
|
||||||
|
'region': this.e.region,
|
||||||
|
}
|
||||||
|
let res = await superagent.post(url).set(HEADER).send(JSON.stringify(data));
|
||||||
|
let resObj = JSON.parse(res.text);
|
||||||
|
return resObj
|
||||||
|
}
|
||||||
getCookieMap(cookie) {
|
getCookieMap(cookie) {
|
||||||
let cookiePattern = /^(\S+)=(\S+)$/;
|
let cookiePattern = /^(\S+)=(\S+)$/;
|
||||||
let cookieArray = cookie.replace(/\s*/g, "").split(";");
|
let cookieArray = cookie.replace(/\s*/g, "").split(";");
|
||||||
@ -412,14 +461,14 @@ export default class MihoYoApi {
|
|||||||
try {
|
try {
|
||||||
let ck = fs.readFileSync(file, 'utf-8')
|
let ck = fs.readFileSync(file, 'utf-8')
|
||||||
ck = YAML.parse(ck)
|
ck = YAML.parse(ck)
|
||||||
if(ck?.uid){
|
if (ck?.uid) {
|
||||||
let datalist={};
|
let datalist = {};
|
||||||
ck.userId=this.e.user_id
|
ck.userId = this.e.user_id
|
||||||
datalist[ck.uid]=ck;
|
datalist[ck.uid] = ck;
|
||||||
ck=datalist
|
ck = datalist
|
||||||
gsCfg.saveBingStoken(this.e.user_id,datalist)
|
gsCfg.saveBingStoken(this.e.user_id, datalist)
|
||||||
}
|
}
|
||||||
return ck[this.e.uid]||{}
|
return ck[this.e.uid] || {}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ export function randomString(length){
|
|||||||
let randomStr = '';
|
let randomStr = '';
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
randomStr += _.sample('abcdefghijklmnopqrstuvwxyz0123456789');
|
randomStr += _.sample('abcdefghijklmnopqrstuvwxyz0123456789');
|
||||||
// randomStr += _.sample('dWCcD2FsOUXEstC5f9xubswZxEeoBOTc');
|
|
||||||
}
|
}
|
||||||
return randomStr;
|
return randomStr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user