[fix] CapsuleLottery fixed #106

This commit is contained in:
Lkeme 2021-08-07 12:18:42 +08:00
parent 0f3569f1f1
commit d6b595db7d
3 changed files with 15 additions and 7 deletions

View File

@ -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);

View File

@ -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 开始抽奖

View File

@ -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;
}