fix:登录跳过执行正常状态的账号

This commit is contained in:
KirDeer 2023-08-28 20:27:33 +08:00 committed by shanmite
parent 288851b491
commit 8addc9078d
3 changed files with 11 additions and 12 deletions

View File

@ -122,7 +122,7 @@ buvid3亦可不填 使用随机生成值
acount 查看帐号信息 acount 查看帐号信息
clear 清理动态和关注 clear 清理动态和关注
update 检查更新 update 检查更新
login 扫码登录自动更新CK login 扫码登录更新CK
help 帮助信息 help 帮助信息
``` ```

View File

@ -1,7 +1,6 @@
const { readFileSync, writeFileSync } = require('fs'); const { readFileSync, writeFileSync } = require('fs');
const { log } = require("./utils"); const { log, env_file} = require("./utils");
const path = require('path'); const env_path = env_file
const env_path = path.join(path.resolve(__dirname, '..'), "env.js")
/* /*
* 扫码登陆 * 扫码登陆
@ -21,7 +20,7 @@ async function login(num) {
const cookie = `${loginInfo.cookie}`; const cookie = `${loginInfo.cookie}`;
log.info("账号UID", uid); log.info("账号UID", uid);
log.info("cookie", cookie); log.info("cookie", cookie);
if (replaceCookie(env_path, uid, cookie)) { if (await replaceCookie(env_path, uid, cookie)) {
log.info("说明",`账号${num}已进行cookie自动更新如未能生效请手动复制在env.js内替换。路径${env_path}`); log.info("说明",`账号${num}已进行cookie自动更新如未能生效请手动复制在env.js内替换。路径${env_path}`);
return; return;
} }

14
main.js
View File

@ -1,5 +1,4 @@
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir, clearLotteryInfo } = require("./lib/utils"); const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir, clearLotteryInfo } = require("./lib/utils");
const {lottery_loop_wait} = require("./lib/data/config");
const metainfo = [ const metainfo = [
` _ _ _ _____ _ _ `, ` _ _ _ _____ _ _ `,
@ -55,9 +54,9 @@ async function main() {
log.info('main', '当前为第' + NUMBER + '个账号'); log.info('main', '当前为第' + NUMBER + '个账号');
log._cache.length = 0 log._cache.length = 0
const mode = process.env.lottery_mode;
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tlogin 扫码登录更新CK\n\tupdate 检查更新\n\thelp 帮助信息";
if (await checkCookie(NUMBER)) { if (await checkCookie(NUMBER)) {
const mode = process.env.lottery_mode;
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require("./lib/data/config"); const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require("./lib/data/config");
switch (mode) { switch (mode) {
case 'start': case 'start':
@ -81,9 +80,7 @@ async function main() {
} }
break; break;
case 'login': case 'login':
log.info('登陆', '开始扫码'); log.info('登录状态', '正常,跳过扫码');
loop_wait = lottery_loop_wait;
await login(NUMBER);
break; break;
case 'help': case 'help':
return help_msg return help_msg
@ -98,7 +95,10 @@ async function main() {
} }
} else { } else {
log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出') log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出')
return if (mode === "login") {
log.info('登陆', '开始扫码');
await login(NUMBER);
}
} }
} else { } else {
return '请查看README文件, 在env.js指定位置填入cookie' return '请查看README文件, 在env.js指定位置填入cookie'