mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
修正V3ck查询多号无法识别问题,补充多个stoken添加逻辑具体待测
This commit is contained in:
parent
6981780856
commit
001fccb53b
19
apps/sign.js
19
apps/sign.js
@ -122,7 +122,8 @@ export async function mysSign(e) {
|
|||||||
}
|
}
|
||||||
let iscount = "";
|
let iscount = "";
|
||||||
let miHoYoApi = new MihoYoApi(e);
|
let miHoYoApi = new MihoYoApi(e);
|
||||||
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0) {
|
let stokens=await miHoYoApi.getStoken(e.user_id)
|
||||||
|
if (!stokens) {
|
||||||
e.reply("未读取到stoken请检查cookies是否包含login_ticket、以及云崽是否为最新版本V3、V2兼容")
|
e.reply("未读取到stoken请检查cookies是否包含login_ticket、以及云崽是否为最新版本V3、V2兼容")
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -231,7 +232,8 @@ export async function bbsSeach(e){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let miHoYoApi = new MihoYoApi(e);
|
let miHoYoApi = new MihoYoApi(e);
|
||||||
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0) {
|
let stokens=await miHoYoApi.getStoken(e.user_id)
|
||||||
|
if (!stokens) {
|
||||||
let cookiesDoc = await getcookiesDoc()
|
let cookiesDoc = await getcookiesDoc()
|
||||||
await replyMsg(e, "未读取到stoken请检查cookies是否包含login_ticket,请先绑定stoken再查询~\n"+cookiesDoc);
|
await replyMsg(e, "未读取到stoken请检查cookies是否包含login_ticket,请先绑定stoken再查询~\n"+cookiesDoc);
|
||||||
return true;
|
return true;
|
||||||
@ -291,8 +293,8 @@ async function cookie(e) {
|
|||||||
e.reply("cookie失效请重新绑定~【教程】\n" + cookiesDoc)
|
e.reply("cookie失效请重新绑定~【教程】\n" + cookiesDoc)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
let stokens=miHoYoApi.getStoken(e.user_id)
|
||||||
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length != 0) {
|
if (!stokens) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
|
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
|
||||||
@ -347,8 +349,10 @@ export async function allMysSign() {
|
|||||||
let stoken = await gsCfg.getBingStoken();
|
let stoken = await gsCfg.getBingStoken();
|
||||||
let isPushSign = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isPushSign
|
let isPushSign = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isPushSign
|
||||||
//获取需要签到的用户
|
//获取需要签到的用户
|
||||||
for (let data of stoken) {
|
for (let dataUid of stoken) {
|
||||||
let user_id = data.qq;
|
for(let uuId in dataUid){
|
||||||
|
let data=dataUid[uuId]
|
||||||
|
let user_id = data.userId;
|
||||||
let e = {
|
let e = {
|
||||||
user_id,
|
user_id,
|
||||||
isTask: true
|
isTask: true
|
||||||
@ -363,12 +367,13 @@ export async function allMysSign() {
|
|||||||
}
|
}
|
||||||
if (msg.includes("OK")) { //签到成功并且不是已签到的才推送
|
if (msg.includes("OK")) { //签到成功并且不是已签到的才推送
|
||||||
// msg = msg.replace("签到成功", "自动签到成功");
|
// msg = msg.replace("签到成功", "自动签到成功");
|
||||||
utils.relpyPrivate(user_id, msg + "\n自动签到成功");
|
utils.relpyPrivate(user_id, msg + "uid:"+uuId+"\n自动签到成功");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await mysSign(e);
|
await mysSign(e);
|
||||||
await utils.sleepAsync(10000);
|
await utils.sleepAsync(10000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Bot.logger.mark(`米社米币签到任务完成`);
|
Bot.logger.mark(`米社米币签到任务完成`);
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -148,9 +148,7 @@ class GsCfg {
|
|||||||
const res = await Promise.all(promises)
|
const res = await Promise.all(promises)
|
||||||
res.forEach((v,index) => {
|
res.forEach((v,index) => {
|
||||||
let tmp = YAML.parse(v)
|
let tmp = YAML.parse(v)
|
||||||
tmp["qq"]=files[index].split(".")[0]*1
|
|
||||||
ck.push(tmp)
|
ck.push(tmp)
|
||||||
|
|
||||||
})
|
})
|
||||||
return ck
|
return ck
|
||||||
}
|
}
|
||||||
@ -170,7 +168,11 @@ 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
|
let login_ticket;
|
||||||
|
if(!ck[item].isMain){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
login_ticket=ck[item]?.login_ticket
|
||||||
ck=ck[item].ck
|
ck=ck[item].ck
|
||||||
return {ck,item,login_ticket};
|
return {ck,item,login_ticket};
|
||||||
}
|
}
|
||||||
@ -187,7 +189,18 @@ class GsCfg {
|
|||||||
fs.writeFileSync(file, yaml, 'utf8')
|
fs.writeFileSync(file, yaml, 'utf8')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
saveBingStoken(userId, data) {
|
||||||
|
let file = `./plugins/${plugin}/data/yaml/${userId}.yaml`
|
||||||
|
console.log(data)
|
||||||
|
console.log(file)
|
||||||
|
if (lodash.isEmpty(data)) {
|
||||||
|
fs.existsSync(file) && fs.unlinkSync(file)
|
||||||
|
} else {
|
||||||
|
let yaml = YAML.stringify(data)
|
||||||
|
|
||||||
|
fs.writeFileSync(file, yaml, 'utf8')
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 原神角色id转换角色名字
|
* 原神角色id转换角色名字
|
||||||
*/
|
*/
|
||||||
|
@ -266,11 +266,10 @@ export default class MihoYoApi {
|
|||||||
|
|
||||||
async stoken(cookie, e) {
|
async stoken(cookie, e) {
|
||||||
this.e = e;
|
this.e = e;
|
||||||
let stokens=Object.values(this.getStoken(e.user_id))
|
let datalist=this.getStoken(e.user_id)
|
||||||
if (stokens.length != 0) {
|
if (datalist){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let datalist={};
|
|
||||||
const map = this.getCookieMap(cookie);
|
const map = this.getCookieMap(cookie);
|
||||||
let loginTicket = map.get("login_ticket");
|
let loginTicket = map.get("login_ticket");
|
||||||
const loginUid = map.get("login_uid") ? map.get("login_uid") : map.get("ltuid");
|
const loginUid = map.get("login_uid") ? map.get("login_uid") : map.get("ltuid");
|
||||||
@ -307,18 +306,18 @@ 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:this.e.user_id,
|
||||||
is_sign:true
|
is_sign:true
|
||||||
}
|
}
|
||||||
// gsCfg.saveBingStoken(e.user_id,datalist)
|
gsCfg.saveBingStoken(e.user_id,datalist)
|
||||||
let yamlStr = YAML.stringify(datalist);
|
// let yamlStr = YAML.stringify(datalist);
|
||||||
fs.writeFileSync(`${YamlDataUrl}/${e.user_id}.yaml`, yamlStr, 'utf8');
|
// fs.writeFileSync(`${YamlDataUrl}/${e.user_id}.yaml`, yamlStr, 'utf8');
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
).catch(function(err) {
|
).catch(function(err) {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
// console.log(datalist);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/** 米游社 api headers */
|
/** 米游社 api headers */
|
||||||
@ -415,7 +414,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)
|
||||||
return ck
|
if(ck?.uid){
|
||||||
|
let datalist={};
|
||||||
|
ck.userId=this.e.user_id
|
||||||
|
datalist[ck.uid]=ck;
|
||||||
|
ck=datalist
|
||||||
|
gsCfg.saveBingStoken(this.e.user_id,datalist)
|
||||||
|
}
|
||||||
|
return ck[this.e.uid]
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
@ -16,56 +16,57 @@ const RETRY_OPTIONS = {
|
|||||||
minTimeout: 5000,
|
minTimeout: 5000,
|
||||||
maxTimeout: 10000
|
maxTimeout: 10000
|
||||||
};
|
};
|
||||||
const nameData=["原神","崩坏3","崩坏2","未定事件簿"];
|
const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"];
|
||||||
/** 配置文件 */
|
/** 配置文件 */
|
||||||
export default class user {
|
export default class user {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
this.e=e;
|
this.e = e;
|
||||||
this.stokenPath=`./plugins/${plugin}/data/yaml/`
|
this.stokenPath = `./plugins/${plugin}/data/yaml/`
|
||||||
this.yunPath=`./plugins/${plugin}/data/yunToken/`;
|
this.yunPath = `./plugins/${plugin}/data/yunToken/`;
|
||||||
this.getyunToken(this.e)
|
this.getyunToken(this.e)
|
||||||
}
|
}
|
||||||
async getCkData(){
|
async getCkData() {
|
||||||
let sumData={};
|
let sumData = {};
|
||||||
await this.cookie(this.e)
|
await this.cookie(this.e)
|
||||||
this.miHoYoApi = new MihoYoApi(this.e);
|
this.miHoYoApi = new MihoYoApi(this.e);
|
||||||
if(this.e.yuntoken){
|
if (this.e.yuntoken) {
|
||||||
let yunres = await this.miHoYoApi.logyunGenshen();
|
let yunres = await this.miHoYoApi.logyunGenshen();
|
||||||
let yundata = yunres.data
|
let yundata = yunres.data
|
||||||
if(yunres.retcode===0){
|
if (yunres.retcode === 0) {
|
||||||
sumData["云原神"]={
|
sumData["云原神"] = {
|
||||||
"今日可获取":yundata?.coin?.coin_num,
|
"今日可获取": yundata?.coin?.coin_num,
|
||||||
"免费时长":yundata?.free_time?.free_time,
|
"免费时长": yundata?.free_time?.free_time,
|
||||||
"总时长":yundata.total_time
|
"总时长": yundata.total_time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.e.cookies){
|
if (this.e.cookies) {
|
||||||
let mysres = await this.miHoYoApi.getTasksList();
|
let mysres = await this.miHoYoApi.getTasksList();
|
||||||
if(mysres.retcode===0){
|
if (mysres.retcode === 0) {
|
||||||
sumData["米游社"]={
|
sumData["米游社"] = {
|
||||||
"米游币任务":mysres.data.can_get_points!=0?"未完成":"已完成",
|
"米游币任务": mysres.data.can_get_points != 0 ? "未完成" : "已完成",
|
||||||
"米游币余额":mysres.data.total_points,
|
"米游币余额": mysres.data.total_points,
|
||||||
"今日剩余可获取":mysres.data.can_get_points
|
"今日剩余可获取": mysres.data.can_get_points
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(this.e.cookie){
|
if (this.e.cookie) {
|
||||||
for(let name of nameData){
|
for (let name of nameData) {
|
||||||
let resSign = await this.miHoYoApi.honkai3rdSignTask(name);
|
let resSign = await this.miHoYoApi.honkai3rdSignTask(name);
|
||||||
if(resSign?.upData){
|
if (resSign?.upData) {
|
||||||
// console.log(resSign?.upData)
|
// console.log(resSign?.upData)
|
||||||
for(let item of resSign?.upData){
|
for (let item of resSign?.upData) {
|
||||||
let num= lodash.random(0, 9999);
|
let num = lodash.random(0, 9999);
|
||||||
item.upName=item.upName=="原神"?"ys":item.upName=="崩坏3"?"bh3":item.upName=="崩坏2"?"bh2":item.upName=="未定事件簿"?"wdy":""
|
item.upName = item.upName == "原神" ? "ys" : item.upName == "崩坏3" ? "bh3" : item.upName ==
|
||||||
sumData[item.upName+""+num]={
|
"崩坏2" ? "bh2" : item.upName == "未定事件簿" ? "wdy" : ""
|
||||||
"uid":item.game_uid,
|
sumData[item.upName + "" + num] = {
|
||||||
"游戏昵称":item.nickname,
|
"uid": item.game_uid,
|
||||||
"等级":item.level,
|
"游戏昵称": item.nickname,
|
||||||
"今日签到":item.is_sign?"已签到":"未签到",
|
"等级": item.level,
|
||||||
"累计签到":item.total_sign_day+"天",
|
"今日签到": item.is_sign ? "已签到" : "未签到",
|
||||||
"今天奖励":item.awards
|
"累计签到": item.total_sign_day + "天",
|
||||||
|
"今天奖励": item.awards
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +100,8 @@ export default class user {
|
|||||||
async cookie(e) {
|
async cookie(e) {
|
||||||
let {
|
let {
|
||||||
cookie,
|
cookie,
|
||||||
uid,skuid
|
uid,
|
||||||
|
skuid
|
||||||
} = await this.getCookie(e);
|
} = await this.getCookie(e);
|
||||||
let cookiesDoc = await this.getcookiesDoc();
|
let cookiesDoc = await this.getcookiesDoc();
|
||||||
let miHoYoApi = new MihoYoApi(this.e);
|
let miHoYoApi = new MihoYoApi(this.e);
|
||||||
@ -107,8 +109,8 @@ export default class user {
|
|||||||
e.reply("请先#绑定cookie\n发送【体力帮助】查看配置教程")
|
e.reply("请先#绑定cookie\n发送【体力帮助】查看配置教程")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
let stokens = miHoYoApi.getStoken(e.user_id)
|
||||||
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length != 0) {
|
if (!stokens) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
|
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user