2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-22 19:10:53 +08:00

修正签到ck会漏部分问题

This commit is contained in:
Ctrlcvs 2022-11-06 22:31:47 +08:00
parent 7ee8fe567b
commit 216bea91c9

View File

@ -1,4 +1,4 @@
import YAML from 'yaml' import YAML from 'yaml'
import chokidar from 'chokidar' import chokidar from 'chokidar'
import miHoYoApi from "../model/mys/mihoyoApi.js" import miHoYoApi from "../model/mys/mihoyoApi.js"
import fs from 'node:fs' import fs from 'node:fs'
@ -87,7 +87,6 @@ export default class user {
async multiSign(forumData) { async multiSign(forumData) {
let upData = [], let upData = [],
message = ''; message = '';
await this.getCookie(this.e);
for (let forum of forumData) { for (let forum of forumData) {
if (!(this.configSign.signlist.includes(forum.name))) { if (!(this.configSign.signlist.includes(forum.name))) {
continue; continue;
@ -97,6 +96,10 @@ export default class user {
message += `**${forum.name}**\n` message += `**${forum.name}**\n`
res = await this.getData("userGameInfo", forum, false) res = await this.getData("userGameInfo", forum, false)
await utils.sleepAsync(3000) //等几毫秒免得请求太频繁了 await utils.sleepAsync(3000) //等几毫秒免得请求太频繁了
if(res.retcode===-100){
message=`用户:${this.e.user_id}cookie失效`
return {message,upData};
}
if (res?.data?.list?.length === 0 || !res?.data?.list) { if (res?.data?.list?.length === 0 || !res?.data?.list) {
message += `签到: 未绑定${forum.name}信息\n`; message += `签到: 未绑定${forum.name}信息\n`;
if (this.allSign) { if (this.allSign) {
@ -349,28 +352,25 @@ export default class user {
let userIdList = []; let userIdList = [];
let dir = './data/MysCookie/' let dir = './data/MysCookie/'
if (isV3) { if (isV3) {
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml')) userIdList = (await gsCfg.getBingAllCk()).ckQQ
userIdList = (files.join(",").replace(/.yaml/g, "").split(","))
} else { } else {
for (let [user_id, cookie] of Object.entries(NoteCookie)) { userIdList=NoteCookie;
userIdList.push(user_id)
}
} }
if (mysTask) { if (mysTask) {
e.reply(`米社自动签到任务进行中,请勿重复触发指令`) e.reply(`米社自动签到任务进行中,请勿重复触发指令`)
return false return false
} }
mysTask = true; mysTask = true;
let userIdkeys=Object.keys(userIdList);
let tips = ['开始米社签到任务'] let tips = ['开始米社签到任务']
let time = userIdList.length * 25 + 5 + (userIdList.length / 3 * 60) let time = userIdkeys.length * 25 + 5 + (userIdkeys.length / 3 * 60)
let finishTime = moment().add(time, 's').format('MM-DD HH:mm:ss') let finishTime = moment().add(time, 's').format('MM-DD HH:mm:ss')
tips.push(`\n签到用户:${userIdList.length}`) tips.push(`\n签到用户:${userIdkeys.length}`)
tips.push(`\n预计需要:${this.countTime(time)}`) tips.push(`\n预计需要:${this.countTime(time)}`)
if (time > 120) { if (time > 120) {
tips.push(`\n完成时间:${finishTime}`) tips.push(`\n完成时间:${finishTime}`)
} }
logger.mark(`签到用户:${userIdList.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`) Bot.logger.mark(`签到用户:${userIdkeys.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`)
if (mul) { if (mul) {
await this.e.reply(tips) await this.e.reply(tips)
if (this.e.msg.includes('force')) this.force = true if (this.e.msg.includes('force')) this.force = true
@ -415,23 +415,14 @@ export default class user {
return msg return msg
} }
} }
for (let qq of userIdList) { for (let qq of userIdkeys) {
let user_id = qq; let user_id = qq;
// let cklist={};
// if(isV3){
// let ck=`${dir}${qq*1}.yaml`
// let cklis=fs.readFileSync(ck, 'utf-8')
// cklist=YAML.parse(cklis)
// }else{
// cklist=NoteCookie[qq*1]
// }
// for(let uid in cklist){
// console.log(item)
// }
let e = { let e = {
user_id, user_id,
qq, qq,
isTask: true isTask: true,
uid:userIdList[qq].uid,
cookie:userIdList[qq].cookie||userIdList[qq].ck,
}; };
if (msg) { if (msg) {
e.msg = msg.replace(/全部|签到|米社/g, ""); e.msg = msg.replace(/全部|签到|米社/g, "");
@ -468,7 +459,7 @@ export default class user {
let mul = e; let mul = e;
Bot.logger.mark(`云原神签到任务开始`); Bot.logger.mark(`云原神签到任务开始`);
let files = fs.readdirSync(this.yunPath).filter(file => file.endsWith('.yaml')) let files = fs.readdirSync(this.yunPath).filter(file => file.endsWith('.yaml'))
let Msg = this.configSign.isCloudSignMsg let isCloudSignMsg = this.configSign.isCloudSignMsg
let userIdList = (files.join(",").replace(/.yaml/g, "").split(",")) let userIdList = (files.join(",").replace(/.yaml/g, "").split(","))
if (cloudTask) { if (cloudTask) {
e.reply(`云原神自动签到任务进行中,请勿重复触发指令`) e.reply(`云原神自动签到任务进行中,请勿重复触发指令`)
@ -482,7 +473,7 @@ export default class user {
if (time > 120) { if (time > 120) {
tips.push(`\n完成时间:${finishTime}`) tips.push(`\n完成时间:${finishTime}`)
} }
logger.mark(`签到用户:${userIdList.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`) Bot.logger.mark(`签到用户:${userIdList.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`)
if (mul) { if (mul) {
await this.e.reply(tips) await this.e.reply(tips)
} else { } else {
@ -501,7 +492,7 @@ export default class user {
Bot.logger.mark(`正在为qq${user_id}云原神签到中...`); Bot.logger.mark(`正在为qq${user_id}云原神签到中...`);
e.msg = "全部" e.msg = "全部"
e.reply = (msg) => { e.reply = (msg) => {
if (!isYunSignMsg || mul) { if (!isCloudSignMsg || mul) {
return; return;
} }
if (msg.includes("领取奖励")) { if (msg.includes("领取奖励")) {
@ -551,7 +542,7 @@ export default class user {
if (time > 120) { if (time > 120) {
tips.push(`\n完成时间:${finishTime}`) tips.push(`\n完成时间:${finishTime}`)
} }
logger.mark(`签到用户:${userIdList.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`) Bot.logger.mark(`签到用户:${userIdList.length}个,预计需要${this.countTime(time)} ${finishTime} 完成`)
if (mul) { if (mul) {
await this.e.reply(tips) await this.e.reply(tips)
if (this.e.msg.includes('force')) this.force = true if (this.e.msg.includes('force')) this.force = true