fix:多账号login添加时延进行间隔

This commit is contained in:
KirDeer 2023-08-28 21:17:27 +08:00 committed by shanmite
parent 8addc9078d
commit c238c27d7d
2 changed files with 12 additions and 3 deletions

View File

@ -22,11 +22,10 @@ async function login(num) {
log.info("cookie", cookie); log.info("cookie", cookie);
if (await 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;
} }
} catch (error) { } catch (error) {
if (error?.message?.includes('Cannot find module')) { if (error?.message?.includes('Cannot find module')) {
log.error('请先运行 yarn add @catlair/blogin'); log.error('请先运行 npm add @catlair/blogin');
return; return;
} }
log.error(error); log.error(error);

12
main.js
View File

@ -16,6 +16,9 @@ const metainfo = [
let multiple_account = []; let multiple_account = [];
/**循环等待时间 */ /**循环等待时间 */
let loop_wait = 0; let loop_wait = 0;
/**账号状态标记 1正常 -1失效 */
// eslint-disable-next-line no-unused-vars
let ck_flag = 0
/** /**
* @returns {Promise<string>} 错误信息 * @returns {Promise<string>} 错误信息
@ -38,7 +41,11 @@ async function main() {
if (err_msg) { if (err_msg) {
return err_msg return err_msg
} else { } else {
await delay(acco.WAIT); if(ck_flag===1){
await delay(acco.WAIT);
} else {
await delay(3 * 1000);
}
} }
} }
@ -58,6 +65,7 @@ async function main() {
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tlogin 扫码登录更新CK\n\tupdate 检查更新\n\thelp 帮助信息"; 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 { 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");
ck_flag = 1;
switch (mode) { switch (mode) {
case 'start': case 'start':
log.info('抽奖', '开始运行'); log.info('抽奖', '开始运行');
@ -95,8 +103,10 @@ async function main() {
} }
} else { } else {
log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出') log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出')
ck_flag = -1;
if (mode === "login") { if (mode === "login") {
log.info('登陆', '开始扫码'); log.info('登陆', '开始扫码');
await delay(6 * 1000);
await login(NUMBER); await login(NUMBER);
} }
} }