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,11 +367,12 @@ 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 {}
|
||||
}
|
||||
|
@ -16,56 +16,57 @@ const RETRY_OPTIONS = {
|
||||
minTimeout: 5000,
|
||||
maxTimeout: 10000
|
||||
};
|
||||
const nameData=["原神","崩坏3","崩坏2","未定事件簿"];
|
||||
const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"];
|
||||
/** 配置文件 */
|
||||
export default class user {
|
||||
constructor(e) {
|
||||
this.e=e;
|
||||
this.stokenPath=`./plugins/${plugin}/data/yaml/`
|
||||
this.yunPath=`./plugins/${plugin}/data/yunToken/`;
|
||||
this.e = e;
|
||||
this.stokenPath = `./plugins/${plugin}/data/yaml/`
|
||||
this.yunPath = `./plugins/${plugin}/data/yunToken/`;
|
||||
this.getyunToken(this.e)
|
||||
}
|
||||
async getCkData(){
|
||||
let sumData={};
|
||||
async getCkData() {
|
||||
let sumData = {};
|
||||
await this.cookie(this.e)
|
||||
this.miHoYoApi = new MihoYoApi(this.e);
|
||||
if(this.e.yuntoken){
|
||||
if (this.e.yuntoken) {
|
||||
let yunres = await this.miHoYoApi.logyunGenshen();
|
||||
let yundata = yunres.data
|
||||
if(yunres.retcode===0){
|
||||
sumData["云原神"]={
|
||||
"今日可获取":yundata?.coin?.coin_num,
|
||||
"免费时长":yundata?.free_time?.free_time,
|
||||
"总时长":yundata.total_time
|
||||
if (yunres.retcode === 0) {
|
||||
sumData["云原神"] = {
|
||||
"今日可获取": yundata?.coin?.coin_num,
|
||||
"免费时长": yundata?.free_time?.free_time,
|
||||
"总时长": yundata.total_time
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.e.cookies){
|
||||
if (this.e.cookies) {
|
||||
let mysres = await this.miHoYoApi.getTasksList();
|
||||
if(mysres.retcode===0){
|
||||
sumData["米游社"]={
|
||||
"米游币任务":mysres.data.can_get_points!=0?"未完成":"已完成",
|
||||
"米游币余额":mysres.data.total_points,
|
||||
"今日剩余可获取":mysres.data.can_get_points
|
||||
if (mysres.retcode === 0) {
|
||||
sumData["米游社"] = {
|
||||
"米游币任务": mysres.data.can_get_points != 0 ? "未完成" : "已完成",
|
||||
"米游币余额": mysres.data.total_points,
|
||||
"今日剩余可获取": mysres.data.can_get_points
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(this.e.cookie){
|
||||
for(let name of nameData){
|
||||
if (this.e.cookie) {
|
||||
for (let name of nameData) {
|
||||
let resSign = await this.miHoYoApi.honkai3rdSignTask(name);
|
||||
if(resSign?.upData){
|
||||
if (resSign?.upData) {
|
||||
// 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":""
|
||||
sumData[item.upName+""+num]={
|
||||
"uid":item.game_uid,
|
||||
"游戏昵称":item.nickname,
|
||||
"等级":item.level,
|
||||
"今日签到":item.is_sign?"已签到":"未签到",
|
||||
"累计签到":item.total_sign_day+"天",
|
||||
"今天奖励":item.awards
|
||||
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" : ""
|
||||
sumData[item.upName + "" + num] = {
|
||||
"uid": item.game_uid,
|
||||
"游戏昵称": item.nickname,
|
||||
"等级": item.level,
|
||||
"今日签到": item.is_sign ? "已签到" : "未签到",
|
||||
"累计签到": item.total_sign_day + "天",
|
||||
"今天奖励": item.awards
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,16 +100,17 @@ 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);
|
||||
let miHoYoApi = new MihoYoApi(this.e);
|
||||
if (!cookie) {
|
||||
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)) {
|
||||
@ -124,7 +126,7 @@ export default class user {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
async getcookiesDoc() {
|
||||
async getcookiesDoc() {
|
||||
return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").cookiesDoc
|
||||
}
|
||||
async getCookie(e) {
|
||||
|
Loading…
Reference in New Issue
Block a user