Browse Source

✨ feat: 增加乐跑时间限制

Pchen. 7 months ago
parent
commit
13fd37877f
2 changed files with 11 additions and 0 deletions
  1. 7 0
      apis/Lepao/SingleRun.js
  2. 4 0
      lib/Lepao/Lepao.js

+ 7 - 0
apis/Lepao/SingleRun.js

@@ -28,6 +28,13 @@ class SingleRun extends API {
                 ...BaseStdResponse.ACCESS_DENIED
             })
 
+        let hour = new Date().getHours()
+        if (hour < 7)
+            return res.json({
+                ...BaseStdResponse.ERR,
+                msg: '当前不在有效乐跑时间范围内。请在7:00~24:00发起乐跑'
+            })
+
         // 检查redis是否存在当天乐跑成功记录
         const isSuccess = await Redis.get(`lepaoSuccess:${student_num}`)
         if (isSuccess)

+ 4 - 0
lib/Lepao/Lepao.js

@@ -126,6 +126,10 @@ class Lepao {
             // 晚上10点后提前
             let run_end_time = Math.floor(Date.now() / 1000) - 300 // 提前5分钟
             let hour = new Date().getHours()
+
+            if(hour < 7)
+                throw new Error('当前不在有效乐跑时间范围内。RunForge支持乐跑时间段为7:00~24:00')
+
             if (hour >= 22) {
                 this.logger.info(`${account}当前时间为${hour}点,调整run_end_time提前5小时`)
                 run_end_time -= 18000