diff --git a/src/core/App.php b/src/core/App.php index 9c96ce8..84d66fd 100644 --- a/src/core/App.php +++ b/src/core/App.php @@ -67,6 +67,7 @@ class App try { call_user_func(array("BiliHelper\\$dir\\" . $taskName, 'run'), []); } catch (\Throwable $e) { + // TODO 多次错误删除tasks_***.json文件 $error_msg = "MSG: {$e->getMessage()} CODE: {$e->getCode()} FILE: {$e->getFile()} LINE: {$e->getLine()}"; Log::error($error_msg); // Notice::push('error', $error_msg); diff --git a/src/plugin/CapsuleLottery.php b/src/plugin/CapsuleLottery.php index fe65cb4..0b0d831 100644 --- a/src/plugin/CapsuleLottery.php +++ b/src/plugin/CapsuleLottery.php @@ -110,8 +110,11 @@ class CapsuleLottery switch ($task['operation']) { // Todo 观看 分享 签到任务 case 'watch': - $interval = self::xliveHeartBeatTask($task['act']->room_id, 999, 999); - self::$interval = $interval == 0 ? 60 : $interval; + // 处理值为空 + if (!is_null($task['act']->room_id)) { + $interval = self::xliveHeartBeatTask($task['act']->room_id, 999, 999); + self::$interval = ($interval == 0 ? 60 : $interval); + } break; case 'draw': // 抽奖次数 > 0 开始抽奖 diff --git a/src/util/AllotTasks.php b/src/util/AllotTasks.php index 283d3f3..f38279b 100644 --- a/src/util/AllotTasks.php +++ b/src/util/AllotTasks.php @@ -24,7 +24,6 @@ trait AllotTasks 'work_completed' => null, ]; - /** * @use 加载json数据 * @return Parser @@ -46,11 +45,8 @@ trait AllotTasks $task = [ 'operation' => $operation, 'act' => $act, - 'time' => false + 'time' => $time ]; - if ($time) { - $task['time'] = $time; - } array_push(static::$tasks, $task); return true; } @@ -67,10 +63,18 @@ trait AllotTasks } // 先进先出 弹出一个任务 $task = array_shift(static::$tasks); + // 如果需要时间限制 if ($task['time']) { + // 如果预计时间为空 或 时间未到 推回队列 if (is_null(static::$work_status['estimated_time']) || time() < intval(static::$work_status['estimated_time'])) { array_unshift(static::$tasks, $task); + } else { + // 不再需要推回时 需要制空 不影响下一个任务操作 + static::$work_status['estimated_time'] = null; } + } else { + // 切换任务 制空 + static::$work_status['estimated_time'] = null; } return $task; }