From ae84796a8cc74dca081e57dc4f3e4aeeb1aeaed8 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Tue, 16 May 2023 19:47:01 +0800 Subject: [PATCH] [fix] lottery request delay --- plugin/Lottery/Lottery.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin/Lottery/Lottery.php b/plugin/Lottery/Lottery.php index 4e53ae9..b600def 100644 --- a/plugin/Lottery/Lottery.php +++ b/plugin/Lottery/Lottery.php @@ -22,6 +22,8 @@ use Bhp\Plugin\Plugin; use Bhp\TimeLock\TimeLock; use Bhp\Request\Request; use Bhp\User\User; +use function Amp\delay; + class Lottery extends BasePlugin { @@ -174,6 +176,7 @@ class Lottery extends BasePlugin */ protected function getLotteryInfo(int $lottery_id): array { + delay(3); $user = User::parseCookie(); $url = 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/detail_by_lid'; $payload = [ @@ -183,7 +186,10 @@ class Lottery extends BasePlugin $response = Request::getJson(true, 'pc', $url, $payload); // 抽奖不存在 - if ($response['code'] === -9999 || $response['code'] === 4000014) { + if ($response['code'] === -9999 || $response['code'] === 4000014 || $response['code'] === -412) { +// if ($response['code'] === -412) { +// Log::warning("抽奖:请求被拦截,暂定无效请求"); +// } return [ 'status' => -9999, ];