diff --git a/global.json b/global.json
index 7ab026e..8716f28 100644
--- a/global.json
+++ b/global.json
@@ -1,4 +1,6 @@
{
+ "minDelay": 1000,
+ "maxDelay": 5000,
"sendMail": false,
"mailConfig": {
"user":"",
diff --git a/src/config.js b/src/config.js
index 8a06af3..68a602d 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,7 +1,7 @@
const { exit } = require("process")
const fs = require("fs")
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.AckNotificationURL = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/ackNotification'
diff --git a/src/index.js b/src/index.js
index ac7cfec..7d98f5f 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,6 +1,6 @@
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");
@@ -20,6 +20,8 @@ const nodemailer = require("nodemailer");
}
});
}
+ var minDelay = globalConfig.minDelay
+ var maxDelay = globalConfig.maxDelay
var configs = getConfigs();
log.info(`正在检测配置有效性`)
checkConfigs(configs)
@@ -53,6 +55,9 @@ const nodemailer = require("nodemailer");
} else {
log.error("签到失败")
}
+ var delay = Math.round(Math.random() * (maxDelay - minDelay) + minDelay)
+ log.info(`暂停:${delay}毫秒`)
+ await sleep(delay);
}
if (globalConfig.sendMail == true) {
diff --git a/src/logger.js b/src/util.js
similarity index 81%
rename from src/logger.js
rename to src/util.js
index 4148b31..044bb2b 100644
--- a/src/logger.js
+++ b/src/util.js
@@ -17,4 +17,10 @@ exports.log = {
logContent += `[error] ${content}
`
baseLogger.error(content)
}
-}
\ No newline at end of file
+}
+
+exports.sleep = function (delay) {
+ return new Promise((resolve) => {
+ setTimeout(resolve, delay)
+ })
+ }
\ No newline at end of file