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 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兼容")
|
||||
return true;
|
||||
}
|
||||
@ -231,7 +232,8 @@ export async function bbsSeach(e){
|
||||
return true;
|
||||
}
|
||||
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()
|
||||
await replyMsg(e, "未读取到stoken请检查cookies是否包含login_ticket,请先绑定stoken再查询~\n"+cookiesDoc);
|
||||
return true;
|
||||
@ -291,8 +293,8 @@ async function cookie(e) {
|
||||
e.reply("cookie失效请重新绑定~【教程】\n" + cookiesDoc)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length != 0) {
|
||||
let stokens=miHoYoApi.getStoken(e.user_id)
|
||||
if (!stokens) {
|
||||
return true;
|
||||
}
|
||||
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
|
||||
@ -347,8 +349,10 @@ export async function allMysSign() {
|
||||
let stoken = await gsCfg.getBingStoken();
|
||||
let isPushSign = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isPushSign
|
||||
//获取需要签到的用户
|
||||
for (let data of stoken) {
|
||||
let user_id = data.qq;
|
||||
for (let dataUid of stoken) {
|
||||
for(let uuId in dataUid){
|
||||
let data=dataUid[uuId]
|
||||
let user_id = data.userId;
|
||||
let e = {
|
||||
user_id,
|
||||
isTask: true
|
||||
@ -363,12 +367,13 @@ export async function allMysSign() {
|
||||
}
|
||||
if (msg.includes("OK")) { //签到成功并且不是已签到的才推送
|
||||
// msg = msg.replace("签到成功", "自动签到成功");
|
||||
utils.relpyPrivate(user_id, msg + "\n自动签到成功");
|
||||
utils.relpyPrivate(user_id, msg + "uid:"+uuId+"\n自动签到成功");
|
||||
}
|
||||
};
|
||||
await mysSign(e);
|
||||
await utils.sleepAsync(10000);
|
||||
}
|
||||
}
|
||||
Bot.logger.mark(`米社米币签到任务完成`);
|
||||
return true
|
||||
}
|
||||
|
@ -148,9 +148,7 @@ class GsCfg {
|
||||
const res = await Promise.all(promises)
|
||||
res.forEach((v,index) => {
|
||||
let tmp = YAML.parse(v)
|
||||
tmp["qq"]=files[index].split(".")[0]*1
|
||||
ck.push(tmp)
|
||||
|
||||
})
|
||||
return ck
|
||||
}
|
||||
@ -170,7 +168,11 @@ class GsCfg {
|
||||
let ck = fs.readFileSync(file, 'utf-8')
|
||||
ck = YAML.parse(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
|
||||
return {ck,item,login_ticket};
|
||||
}
|
||||
@ -187,7 +189,18 @@ class GsCfg {
|
||||
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转换角色名字
|
||||
*/
|
||||
|
@ -266,11 +266,10 @@ export default class MihoYoApi {
|
||||
|
||||
async stoken(cookie, e) {
|
||||
this.e = e;
|
||||
let stokens=Object.values(this.getStoken(e.user_id))
|
||||
if (stokens.length != 0) {
|
||||
let datalist=this.getStoken(e.user_id)
|
||||
if (datalist){
|
||||
return true;
|
||||
}
|
||||
let datalist={};
|
||||
const map = this.getCookieMap(cookie);
|
||||
let loginTicket = map.get("login_ticket");
|
||||
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,
|
||||
ltoken: data.data.list[1].token,
|
||||
uid: e.uid,
|
||||
userId:this.e.user_id,
|
||||
is_sign:true
|
||||
}
|
||||
// gsCfg.saveBingStoken(e.user_id,datalist)
|
||||
let yamlStr = YAML.stringify(datalist);
|
||||
fs.writeFileSync(`${YamlDataUrl}/${e.user_id}.yaml`, yamlStr, 'utf8');
|
||||
gsCfg.saveBingStoken(e.user_id,datalist)
|
||||
// let yamlStr = YAML.stringify(datalist);
|
||||
// fs.writeFileSync(`${YamlDataUrl}/${e.user_id}.yaml`, yamlStr, 'utf8');
|
||||
return true;
|
||||
});
|
||||
}
|
||||
).catch(function(err) {
|
||||
return false;
|
||||
});
|
||||
// console.log(datalist);
|
||||
return true;
|
||||
}
|
||||
/** 米游社 api headers */
|
||||
@ -415,7 +414,14 @@ export default class MihoYoApi {
|
||||
try {
|
||||
let ck = fs.readFileSync(file, 'utf-8')
|
||||
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) {
|
||||
return {}
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ export default class user {
|
||||
// console.log(resSign?.upData)
|
||||
for (let item of resSign?.upData) {
|
||||
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 ==
|
||||
"崩坏2" ? "bh2" : item.upName == "未定事件簿" ? "wdy" : ""
|
||||
sumData[item.upName + "" + num] = {
|
||||
"uid": item.game_uid,
|
||||
"游戏昵称": item.nickname,
|
||||
@ -99,7 +100,8 @@ export default class user {
|
||||
async cookie(e) {
|
||||
let {
|
||||
cookie,
|
||||
uid,skuid
|
||||
uid,
|
||||
skuid
|
||||
} = await this.getCookie(e);
|
||||
let cookiesDoc = await this.getcookiesDoc();
|
||||
let miHoYoApi = new MihoYoApi(this.e);
|
||||
@ -107,8 +109,8 @@ export default class user {
|
||||
e.reply("请先#绑定cookie\n发送【体力帮助】查看配置教程")
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length != 0) {
|
||||
let stokens = miHoYoApi.getStoken(e.user_id)
|
||||
if (!stokens) {
|
||||
return true;
|
||||
}
|
||||
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
|
||||
|
Loading…
Reference in New Issue
Block a user