add random delay (fix #1)
This commit is contained in:
parent
2ed58716bf
commit
5c8a9eb55e
@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
"minDelay": 1000,
|
||||||
|
"maxDelay": 5000,
|
||||||
"sendMail": false,
|
"sendMail": false,
|
||||||
"mailConfig": {
|
"mailConfig": {
|
||||||
"user":"",
|
"user":"",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const { exit } = require("process")
|
const { exit } = require("process")
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const { default: axios } = require("axios")
|
const { default: axios } = require("axios")
|
||||||
const { log } = require("./logger")
|
const { log } = require("./util")
|
||||||
|
|
||||||
exports.ListNotificationURL = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/listNotifications?is_sort=true&source=NotificationSourceUnknown&status=NotificationStatusUnread&type=NotificationTypePopup'
|
exports.ListNotificationURL = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/listNotifications?is_sort=true&source=NotificationSourceUnknown&status=NotificationStatusUnread&type=NotificationTypePopup'
|
||||||
exports.AckNotificationURL = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/ackNotification'
|
exports.AckNotificationURL = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/ackNotification'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const { getConfigs, checkConfigs, makeHeader, ListNotification, AckNotification, Wallet, SendLog, AppVersion, getGlobalConfig } = require("./config")
|
const { getConfigs, checkConfigs, makeHeader, ListNotification, AckNotification, Wallet, SendLog, AppVersion, getGlobalConfig } = require("./config")
|
||||||
|
|
||||||
const { log, addLogContent, getLogs } = require("./logger");
|
const { log, addLogContent, getLogs, sleep } = require("./util");
|
||||||
|
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
|
|
||||||
@ -20,6 +20,8 @@ const nodemailer = require("nodemailer");
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
var minDelay = globalConfig.minDelay
|
||||||
|
var maxDelay = globalConfig.maxDelay
|
||||||
var configs = getConfigs();
|
var configs = getConfigs();
|
||||||
log.info(`正在检测配置有效性`)
|
log.info(`正在检测配置有效性`)
|
||||||
checkConfigs(configs)
|
checkConfigs(configs)
|
||||||
@ -53,6 +55,9 @@ const nodemailer = require("nodemailer");
|
|||||||
} else {
|
} else {
|
||||||
log.error("签到失败")
|
log.error("签到失败")
|
||||||
}
|
}
|
||||||
|
var delay = Math.round(Math.random() * (maxDelay - minDelay) + minDelay)
|
||||||
|
log.info(`暂停:${delay}毫秒`)
|
||||||
|
await sleep(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalConfig.sendMail == true) {
|
if (globalConfig.sendMail == true) {
|
||||||
|
@ -17,4 +17,10 @@ exports.log = {
|
|||||||
logContent += `<strong style="color: red">[error]</strong> ${content}<br>`
|
logContent += `<strong style="color: red">[error]</strong> ${content}<br>`
|
||||||
baseLogger.error(content)
|
baseLogger.error(content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.sleep = function (delay) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, delay)
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user