mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
修正V3版本兼容导致无法签到社区问题
This commit is contained in:
parent
454b18d780
commit
843a3269cf
@ -166,9 +166,10 @@ async function getDataList(name){
|
|||||||
async function cookie(e) {
|
async function cookie(e) {
|
||||||
let cookie, uid;
|
let cookie, uid;
|
||||||
let miHoYoApi = new MihoYoApi(e);
|
let miHoYoApi = new MihoYoApi(e);
|
||||||
|
let skuid;
|
||||||
if (isV3) {
|
if (isV3) {
|
||||||
// console.log(e)
|
// console.log(e)
|
||||||
let skuid = await gsCfg.getBingCookie(e.user_id);
|
skuid= await gsCfg.getBingCookie(e.user_id);
|
||||||
cookie = skuid.ck;
|
cookie = skuid.ck;
|
||||||
uid = skuid.item;
|
uid = skuid.item;
|
||||||
} else {
|
} else {
|
||||||
@ -180,8 +181,12 @@ async function cookie(e) {
|
|||||||
uid = BotConfig.dailyNote[e.user_id].uid;
|
uid = BotConfig.dailyNote[e.user_id].uid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!cookie){
|
||||||
|
e.reply("cookie失效请重新绑定~")
|
||||||
|
return false;
|
||||||
|
}
|
||||||
e.uid = uid;
|
e.uid = uid;
|
||||||
if (!cookie.includes("login_ticket")) {
|
if (!cookie.includes("login_ticket")&&(isV3&&!skuid?.login_ticket)) {
|
||||||
e.reply("米游社登录cookie不完整,请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket")
|
e.reply("米游社登录cookie不完整,请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -145,8 +145,9 @@ class GsCfg {
|
|||||||
let ck = fs.readFileSync(file, 'utf-8')
|
let ck = fs.readFileSync(file, 'utf-8')
|
||||||
ck = YAML.parse(ck)
|
ck = YAML.parse(ck)
|
||||||
for(let item in ck){
|
for(let item in ck){
|
||||||
|
let login_ticket=ck[item]?.login_ticket
|
||||||
ck=ck[item].ck
|
ck=ck[item].ck
|
||||||
return {ck,item};
|
return {ck,item,login_ticket};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {}
|
return {}
|
||||||
|
@ -4,7 +4,13 @@ import _ from 'lodash';
|
|||||||
import superagent from 'superagent';
|
import superagent from 'superagent';
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import YAML from 'yaml'
|
import YAML from 'yaml'
|
||||||
import {Data} from "../../components/index.js";
|
import {
|
||||||
|
Data
|
||||||
|
} from "../../components/index.js";
|
||||||
|
import gsCfg from '../gsCfg.js'
|
||||||
|
import {
|
||||||
|
isV3
|
||||||
|
} from '../../components/Changelog.js';
|
||||||
import fetch from "node-fetch"
|
import fetch from "node-fetch"
|
||||||
const APP_VERSION = "2.2.0";
|
const APP_VERSION = "2.2.0";
|
||||||
const DEVICE_ID = utils.randomString(32).toUpperCase();
|
const DEVICE_ID = utils.randomString(32).toUpperCase();
|
||||||
@ -67,13 +73,16 @@ export default class MihoYoApi {
|
|||||||
return resObj;
|
return resObj;
|
||||||
}
|
}
|
||||||
async stoken(cookie, e) {
|
async stoken(cookie, e) {
|
||||||
this.e=e;
|
this.e = e;
|
||||||
if(Object.keys(this.getStoken(e.user_id)).length != 0){
|
if (Object.keys(this.getStoken(e.user_id)).length != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const map = this.getCookieMap(cookie);
|
const map = this.getCookieMap(cookie);
|
||||||
const loginTicket = map.get("login_ticket");
|
let loginTicket = map.get("login_ticket");
|
||||||
const loginUid = map.get("login_uid");
|
const loginUid = map.get("login_uid") ? map.get("login_uid") : map.get("ltuid");
|
||||||
|
if(isV3){
|
||||||
|
loginTicket=gsCfg.getBingCookie(e.user_id).login_ticket
|
||||||
|
}
|
||||||
const url = "https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?login_ticket=" +
|
const url = "https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?login_ticket=" +
|
||||||
loginTicket + "&token_types=3&uid=" + loginUid;
|
loginTicket + "&token_types=3&uid=" + loginUid;
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
@ -96,7 +105,7 @@ export default class MihoYoApi {
|
|||||||
}
|
}
|
||||||
response.json().then(function(data) {
|
response.json().then(function(data) {
|
||||||
// console.log(data);
|
// console.log(data);
|
||||||
if(!data.data){
|
if (!data.data) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let datalist = {
|
let datalist = {
|
||||||
@ -118,11 +127,11 @@ export default class MihoYoApi {
|
|||||||
_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 data=this.getStoken(this.e.user_id);
|
let data = this.getStoken(this.e.user_id);
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
// iOS sign
|
// iOS sign
|
||||||
let sign = md5(`salt=b253c83ab2609b1b600eddfe974df47b&t=${timestamp}&r=${randomStr}`);
|
let sign = md5(`salt=b253c83ab2609b1b600eddfe974df47b&t=${timestamp}&r=${randomStr}`);
|
||||||
let cookie =`stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
let cookie = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
||||||
return {
|
return {
|
||||||
'Cookie': cookie,
|
'Cookie': cookie,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -140,11 +149,12 @@ export default class MihoYoApi {
|
|||||||
}
|
}
|
||||||
getCookieMap(cookie) {
|
getCookieMap(cookie) {
|
||||||
let cookiePattern = /^(\S+)=(\S+)$/;
|
let cookiePattern = /^(\S+)=(\S+)$/;
|
||||||
let cookieArray = cookie.split("; ");
|
let cookieArray = cookie.replace(/\s*/g,"").split(";");
|
||||||
let cookieMap = new Map();
|
let cookieMap = new Map();
|
||||||
for (let item of cookieArray) {
|
for (let item of cookieArray) {
|
||||||
let entry = cookiePattern.exec(item);
|
let entry = item.split("=");
|
||||||
cookieMap.set(entry[1], entry[2]);
|
if(!entry[0]) continue;
|
||||||
|
cookieMap.set(entry[0], entry[1]);
|
||||||
}
|
}
|
||||||
return cookieMap;
|
return cookieMap;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user