From aef330a8f36173f2e8b9c01123c1468252241ae6 Mon Sep 17 00:00:00 2001
From: Lkeme <19500576+lkeme@users.noreply.github.com>
Date: Wed, 18 Mar 2020 14:32:06 +0800
Subject: [PATCH] [fix] Curl fixes #21
---
CHANGELOG.md | 23 +++++++++++-
DOC.md | 50 +++++++++++++-------------
README.md | 6 ++--
src/core/App.php | 4 +--
src/core/Curl.php | 19 +++++-----
src/core/Log.php | 2 +-
src/plugin/AnchorRaffle.php | 2 +-
src/plugin/Barrage.php | 7 ++--
src/plugin/GiftHeart.php | 1 -
src/plugin/GroupSignIn.php | 2 +-
src/plugin/GuardRaffle.php | 3 +-
src/plugin/Heart.php | 11 ++++--
src/plugin/Judge.php | 2 +-
src/plugin/Live.php | 8 +----
src/plugin/ManGa.php | 2 +-
src/plugin/MasterSite.php | 12 ++-----
src/plugin/MaterialObject.php | 9 +++--
src/plugin/PkRaffle.php | 2 +-
src/plugin/{Sleep.php => Schedule.php} | 4 +--
src/plugin/Silver.php | 8 +++--
src/plugin/Silver2Coin.php | 2 +-
src/plugin/StormRaffle.php | 5 ++-
src/plugin/User.php | 8 +----
src/plugin/ZoneTcpClient.php | 2 +-
src/util/TimeLock.php | 13 +++++--
25 files changed, 114 insertions(+), 93 deletions(-)
rename src/plugin/{Sleep.php => Schedule.php} (94%)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 995d4b3..4c91809 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,28 @@
# Release Notes
# 本项目Log
-## v0.3.0.200316 alpha (2020-03-169)
+## v0.3.0.200318 alpha (2020-03-18)
+
+### Added
+- 添加日常任务定时执行(AM10:00)
+-
+
+### Changed
+- Sleep->Schedule
+- 优化异常通知
+- 优化异常重试数
+- 优化弹幕获取
+- 优化银瓜子宝箱
+-
+
+### Fixed
+- 修复日志回调
+- 修复response为null
+- 修复PC端心跳
+- 修复部分已知
+-
+
+## v0.3.0.200316 alpha (2020-03-16)
### Added
- 添加异常处理(通知)
diff --git a/DOC.md b/DOC.md
index e472de0..779b2ff 100644
--- a/DOC.md
+++ b/DOC.md
@@ -2,7 +2,7 @@

-
+
@@ -15,30 +15,30 @@ B 站直播实用脚本
|plugin |version |description |
|--------------------|--------------------|--------------------|
-|Login |20.03.16 |账号登录 |
-|Sleep |20.03.16 |休眠控制 |
-|MasterSite |20.03.16 |主站助手 |
-|Daily |20.03.16 |每日礼包 |
-|Heart |20.03.16 |双端心跳 |
-|Task |20.03.16 |每日任务 |
-|Silver |20.03.16 |银瓜子宝箱 |
-|Barrage |20.03.16 |活跃弹幕 |
-|Silver2Coin |20.03.16 |银瓜子换硬币 |
-|GiftSend |20.03.16 |礼物赠送 |
-|Judge |20.03.16 |风纪 |
-|GroupSignIn |20.03.16 |友爱社签到 |
-|ManGa |20.03.16 |漫画签到分享 |
-|GiftHeart |20.03.16 |心跳礼物 |
-|MaterialObject |20.03.16 |实物抽奖 |
-|AloneTcpClient |20.03.16 |独立监控 |
-|ZoneTcpClient |20.03.16 |分区监控 |
-|StormRaffle |20.03.16 |节奏风暴 |
-|GiftRaffle |20.03.16 |活动礼物 |
-|PkRaffle |20.03.16 |大乱斗 |
-|GuardRaffle |20.03.16 |舰长总督 |
-|AnchorRaffle |20.03.16 |天选时刻 |
-|AwardRecord |20.03.16 |获奖通知 |
-|Statistics |20.03.16 |数据统计 |
+|Login |20.03.18 |账号登录 |
+|Schedule |20.03.18 |休眠控制 |
+|MasterSite |20.03.18 |主站助手 |
+|Daily |20.03.18 |每日礼包 |
+|Heart |20.03.18 |双端心跳 |
+|Task |20.03.18 |每日任务 |
+|Silver |20.03.18 |银瓜子宝箱 |
+|Barrage |20.03.18 |活跃弹幕 |
+|Silver2Coin |20.03.18 |银瓜子换硬币 |
+|GiftSend |20.03.18 |礼物赠送 |
+|Judge |20.03.18 |风纪 |
+|GroupSignIn |20.03.18 |友爱社签到 |
+|ManGa |20.03.18 |漫画签到分享 |
+|GiftHeart |20.03.18 |心跳礼物 |
+|MaterialObject |20.03.18 |实物抽奖 |
+|AloneTcpClient |20.03.18 |独立监控 |
+|ZoneTcpClient |20.03.18 |分区监控 |
+|StormRaffle |20.03.18 |节奏风暴 |
+|GiftRaffle |20.03.18 |活动礼物 |
+|PkRaffle |20.03.18 |大乱斗 |
+|GuardRaffle |20.03.18 |舰长总督 |
+|AnchorRaffle |20.03.18 |天选时刻 |
+|AwardRecord |20.03.18 |获奖通知 |
+|Statistics |20.03.18 |数据统计 |
## 打赏赞助
diff --git a/README.md b/README.md
index f342a0d..08d7d5a 100644
--- a/README.md
+++ b/README.md
@@ -3,16 +3,18 @@ B 站直播实用脚本
## 交流
-Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg)
+Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **仅用于BUG提交反馈**
## 公告
-Currently for Personal Edition **0.3.0.200316 alpha**
+Currently for Personal Edition **0.3.0.200318 alpha**
## 文档
* [使用文档 / DOC.md](./DOC.md)
* [更新日志 / CHANGELOG.md](./CHANGELOG.md)
+* [配置文档 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3)
+* [常见问题 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)
## 打赏
diff --git a/src/core/App.php b/src/core/App.php
index 6a03812..0f7f4dc 100644
--- a/src/core/App.php
+++ b/src/core/App.php
@@ -59,7 +59,7 @@ class App
} catch (\Throwable $e) {
$error_msg = "MSG: {$e->getMessage()} CODE: {$e->getCode()} FILE: {$e->getFile()} LINE: {$e->getLine()}";
Log::error($error_msg);
- Notice::push('error', $error_msg);
+ // Notice::push('error', $error_msg);
}
yield new Delayed(1000);
}
@@ -73,7 +73,7 @@ class App
{
$plugins = [
'Login',
- 'Sleep',
+ 'Schedule',
'MasterSite',
'Daily',
'ManGa',
diff --git a/src/core/Curl.php b/src/core/Curl.php
index eab8eda..daf068c 100644
--- a/src/core/Curl.php
+++ b/src/core/Curl.php
@@ -168,28 +168,31 @@ class Curl
self::$async_opt = [];
}
+
/**
* @use 请求中心异常处理
* @param string $url
* @param string $method
* @param array $options
* @return mixed
+ * @throws \Exception
*/
private static function clientHandle(string $url, string $method, array $options)
{
- $max_retry = range(0, 30);
+ $max_retry = range(1, 40);
foreach ($max_retry as $retry) {
try {
- return call_user_func_array([self::$client, $method], [$url, $options]);
+ $response = call_user_func_array([self::$client, $method], [$url, $options]);
+ if (is_null($response) or empty($response)) throw new \Exception("Value IsEmpty");
+ return $response;
} catch (\GuzzleHttp\Exception\RequestException $e) {
- Log::warning("CURl -> RETRY: {$retry} ERROR: {$e->getMessage()} ERRNO: {$e->getCode()}");
// var_dump($e->getRequest());
- if ($e->hasResponse()) {
- var_dump($e->getResponse());
- }
- Log::warning("尝试重试第 {$retry} 次,等待网络恢复...");
- sleep(10);
+ if ($e->hasResponse()) var_dump($e->getResponse());
+ } catch (\Exception $e) {
+ // var_dump($e);
}
+ Log::warning("CURl -> RETRY: {$retry} ERROR: {$e->getMessage()} ERRNO: {$e->getCode()} STATUS: Waiting for recovery!");
+ sleep(15);
}
exit('网络异常,超出最大尝试次数,退出程序~');
}
diff --git a/src/core/Log.php b/src/core/Log.php
index 2c6dd98..67e54e0 100644
--- a/src/core/Log.php
+++ b/src/core/Log.php
@@ -104,7 +104,7 @@ class Log
$url = str_replace('{account}', self::prefix(), getenv('APP_CALLBACK'));
$url = str_replace('{level}', $level, $url);
$url = str_replace('{message}', urlencode($message), $url);
- Curl::get('other', $url);
+ Curl::request('get', $url);
}
}
}
\ No newline at end of file
diff --git a/src/plugin/AnchorRaffle.php b/src/plugin/AnchorRaffle.php
index 571f2cc..d235c40 100644
--- a/src/plugin/AnchorRaffle.php
+++ b/src/plugin/AnchorRaffle.php
@@ -93,7 +93,7 @@ class AnchorRaffle extends BaseRaffle
'room_id' => $room_id,
'raffle_id' => $de_raw['id'],
'raffle_name' => $de_raw['award_name'],
- 'wait' => time() + random_int(5, 25)
+ 'wait' => time() + mt_rand(5, 25)
];
Statistics::addPushList(self::ACTIVE_TITLE);
array_push(self::$wait_list, $data);
diff --git a/src/plugin/Barrage.php b/src/plugin/Barrage.php
index 43f9f5e..8a88d92 100644
--- a/src/plugin/Barrage.php
+++ b/src/plugin/Barrage.php
@@ -32,7 +32,7 @@ class Barrage
];
if (self::privateSendMsg($info)) {
- self::setLock(3600);
+ self::setLock(mt_rand(15, 30) * 60);
return;
}
@@ -42,7 +42,7 @@ class Barrage
/**
* @use 获取随机弹幕
- * @return \Exception|false|mixed|string
+ * @return \Exception|false|mixed|string|null
*/
private static function getMsgInfo()
{
@@ -53,15 +53,12 @@ class Barrage
*/
$punctuations = [',', ',', '。', '!', '.', ';', '——'];
$apis = [
- 'https://api.lwl12.com/hitokoto/v1?encode=realjso',
'https://api.ly522.com/yan.php?format=text',
'https://v1.hitokoto.cn/?encode=text',
'https://api.jysafe.cn/yy/',
- 'https://m.mom1.cn/api/yan/api.php',
'https://api.ooopn.com/yan/api.php?type=text',
'https://api.imjad.cn/hitokoto/',
'https://www.ly522.com/hitokoto/',
- 'https://www.tddiao.online/word/',
'https://api.guoch.xyz/',
'http://www.ooomg.cn/dutang/',
'https://api.gushi.ci/rensheng.txt',
diff --git a/src/plugin/GiftHeart.php b/src/plugin/GiftHeart.php
index d7b9c61..e73da01 100644
--- a/src/plugin/GiftHeart.php
+++ b/src/plugin/GiftHeart.php
@@ -34,7 +34,6 @@ class GiftHeart
/**
* @use 礼物心跳
* @return bool
- * @throws \Exception
*/
private static function giftHeart(): bool
{
diff --git a/src/plugin/GroupSignIn.php b/src/plugin/GroupSignIn.php
index 74394ab..a3f220c 100644
--- a/src/plugin/GroupSignIn.php
+++ b/src/plugin/GroupSignIn.php
@@ -26,7 +26,7 @@ class GroupSignIn
$groups = self::getGroupList();
if (empty($groups)) {
- self::setLock(24 * 60 * 60);
+ self::setLock(self::timing(10));
return;
}
diff --git a/src/plugin/GuardRaffle.php b/src/plugin/GuardRaffle.php
index 35f63aa..bb1b254 100644
--- a/src/plugin/GuardRaffle.php
+++ b/src/plugin/GuardRaffle.php
@@ -31,7 +31,6 @@ class GuardRaffle extends BaseRaffle
* @param int $room_id
* @param array $data
* @return bool
- * @throws \Exception
*/
protected static function parseLotteryInfo(int $room_id, array $data): bool
{
@@ -73,7 +72,7 @@ class GuardRaffle extends BaseRaffle
'room_id' => $room_id,
'raffle_id' => $guard['id'],
'raffle_name' => $raffle_name,
- 'wait' => time() + random_int(5, 25)
+ 'wait' => time() + mt_rand(5, 25)
];
Statistics::addPushList(self::ACTIVE_TITLE);
array_push(self::$wait_list, $data);
diff --git a/src/plugin/Heart.php b/src/plugin/Heart.php
index f71deb1..1be0a74 100644
--- a/src/plugin/Heart.php
+++ b/src/plugin/Heart.php
@@ -34,11 +34,18 @@ class Heart
protected static function webHeart()
{
User::webGetUserInfo();
- $url = 'https://api.live.bilibili.com/relation/v1/Feed/heartBeat';
+ $url = 'https://api.live.bilibili.com/User/userOnlineHeart';
+ $user_info = User::parseCookies();
$payload = [
+ 'csrf' => $user_info['token'],
+ 'csrf_token' => $user_info['token'],
'room_id' => getenv('ROOM_ID'),
+ '_' => time() * 1000,
];
- $data = Curl::post('app', $url, Sign::common($payload));
+ $headers = [
+ 'Referer' => 'https://live.bilibili.com/' . getenv('ROOM_ID')
+ ];
+ $data = Curl::post('app', $url, $payload, $headers);
$data = json_decode($data, true);
if (isset($data['code']) && $data['code']) {
diff --git a/src/plugin/Judge.php b/src/plugin/Judge.php
index 4ac182c..8583ee0 100644
--- a/src/plugin/Judge.php
+++ b/src/plugin/Judge.php
@@ -178,7 +178,7 @@ class Judge
// {"code":25005,"message":"请成为风纪委员后再试","ttl":1}
if (isset($de_raw['code']) && $de_raw['code'] == 25005) {
Log::warning($de_raw['message']);
- self::setLock(24 * 60 * 60);
+ self::setLock(self::timing(10));
return null;
}
if (isset($de_raw['code']) && $de_raw['code']) {
diff --git a/src/plugin/Live.php b/src/plugin/Live.php
index 547c3fd..4899d02 100644
--- a/src/plugin/Live.php
+++ b/src/plugin/Live.php
@@ -21,7 +21,6 @@ class Live
/**
* @use 获取分区列表
* @return array
- * @throws \Exception
*/
public static function fetchLiveAreas(): array
{
@@ -47,7 +46,6 @@ class Live
* @use AREA_ID转ROOM_ID
* @param $area_id
* @return array
- * @throws \Exception
*/
public static function areaToRid($area_id): array
{
@@ -83,7 +81,6 @@ class Live
/**
* @use 获取随机直播房间号
* @return int
- * @throws \Exception
*/
public static function getUserRecommend()
{
@@ -99,7 +96,7 @@ class Live
if ($de_raw['code'] != '0') {
return 23058;
}
- return $de_raw['data'][random_int(1, 29)]['roomid'];
+ return $de_raw['data'][mt_rand(1, 29)]['roomid'];
}
@@ -107,7 +104,6 @@ class Live
* @use 获取直播房间号
* @param $room_id
* @return bool
- * @throws \Exception
*/
public static function getRealRoomID($room_id)
{
@@ -151,7 +147,6 @@ class Live
* @use 钓鱼检测
* @param $room_id
* @return bool
- * @throws \Exception
*/
public static function fishingDetection($room_id): bool
{
@@ -166,7 +161,6 @@ class Live
* @use 访问直播间
* @param $room_id
* @return bool
- * @throws \Exception
*/
public static function goToRoom($room_id): bool
{
diff --git a/src/plugin/ManGa.php b/src/plugin/ManGa.php
index c32d05f..89ecea8 100644
--- a/src/plugin/ManGa.php
+++ b/src/plugin/ManGa.php
@@ -24,7 +24,7 @@ class ManGa
return;
}
if (self::sign() && self::share()) {
- self::setLock(24 * 60 * 60);
+ self::setLock(self::timing(10));
return;
}
self::setLock(3600);
diff --git a/src/plugin/MasterSite.php b/src/plugin/MasterSite.php
index 5004142..68e6408 100644
--- a/src/plugin/MasterSite.php
+++ b/src/plugin/MasterSite.php
@@ -24,7 +24,7 @@ class MasterSite
return;
}
if (self::watchAid() && self::shareAid() && self::coinAdd()) {
- self::setLock(24 * 60 * 60);
+ self::setLock(self::timing(10));
return;
}
self::setLock(3600);
@@ -103,7 +103,6 @@ class MasterSite
/**
* @use 视频投币 TODO : 处理视频投币硬币少于需要投币数
* @return bool
- * @throws \Exception
*/
protected static function coinAdd(): bool
{
@@ -144,14 +143,13 @@ class MasterSite
/**
* @use 获取随机AID
* @return string
- * @throws \Exception
*/
private static function getRandomAid(): string
{
do {
$url = "https://api.bilibili.com/x/web-interface/newlist";
$payload = [
- 'pn' => random_int(1, 1000),
+ 'pn' => mt_rand(1, 1000),
'ps' => 1,
];
$raw = Curl::get('other', $url, $payload);
@@ -168,7 +166,6 @@ class MasterSite
* @use 获取日榜AID
* @param $num
* @return array
- * @throws \Exception
*/
private static function getDayRankingAids($num): array
{
@@ -186,7 +183,7 @@ class MasterSite
$de_raw = json_decode($raw, true);
for ($i = 0; $i < $num; $i++) {
while (true) {
- $rand_num = random_int(1, 100);
+ $rand_num = mt_rand(1, 100);
if (in_array($rand_num, $rand_nums)) {
continue;
} else {
@@ -205,7 +202,6 @@ class MasterSite
/**
* @use 分享视频
* @return bool
- * @throws \Exception
*/
private static function shareAid(): bool
{
@@ -239,7 +235,6 @@ class MasterSite
/**
* @use 观看视频
* @return bool
- * @throws \Exception
*/
private static function watchAid(): bool
{
@@ -307,7 +302,6 @@ class MasterSite
/**
* @use 解析AID到CID
* @return array
- * @throws \Exception
*/
private static function parseAid(): array
{
diff --git a/src/plugin/MaterialObject.php b/src/plugin/MaterialObject.php
index bee0142..81670f0 100644
--- a/src/plugin/MaterialObject.php
+++ b/src/plugin/MaterialObject.php
@@ -34,7 +34,7 @@ class MaterialObject
self::calcAid(470, 770);
$lottery_list = self::fetchLottery();
self::drawLottery($lottery_list);
- self::setLock(random_int(5, 10) * 60);
+ self::setLock(mt_rand(6, 10) * 60);
}
@@ -196,7 +196,6 @@ class MaterialObject
* @param $min
* @param $max
* @return bool
- * @throws \Exception
*/
private static function calcAid($min, $max): bool
{
@@ -206,7 +205,7 @@ class MaterialObject
while (true) {
$middle = round(($min + $max) / 2);
if (self::boxStatus($middle)) {
- if (self::boxStatus($middle + random_int(0, 3))) {
+ if (self::boxStatus($middle + mt_rand(0, 3))) {
$max = $middle;
} else {
$min = $middle;
@@ -218,8 +217,8 @@ class MaterialObject
break;
}
}
- self::$start_aid = $min - random_int(15, 30);
- self::$end_aid = $min + random_int(15, 30);
+ self::$start_aid = $min - mt_rand(15, 30);
+ self::$end_aid = $min + mt_rand(15, 30);
Log::info("实物抽奖起始值[" . self::$start_aid . "],结束值[" . self::$end_aid . "]");
return true;
}
diff --git a/src/plugin/PkRaffle.php b/src/plugin/PkRaffle.php
index 8eadaeb..c7ffe85 100644
--- a/src/plugin/PkRaffle.php
+++ b/src/plugin/PkRaffle.php
@@ -58,7 +58,7 @@ class PkRaffle extends BaseRaffle
'room_id' => $room_id,
'raffle_id' => $pk['id'],
'raffle_name' => '大乱斗',
- 'wait' => time() + random_int(5, 25)
+ 'wait' => time() + mt_rand(5, 25)
];
Statistics::addPushList(self::ACTIVE_TITLE);
array_push(self::$wait_list, $data);
diff --git a/src/plugin/Sleep.php b/src/plugin/Schedule.php
similarity index 94%
rename from src/plugin/Sleep.php
rename to src/plugin/Schedule.php
index e7bfe41..fd73270 100644
--- a/src/plugin/Sleep.php
+++ b/src/plugin/Schedule.php
@@ -15,13 +15,13 @@ use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
-class Sleep
+class Schedule
{
use TimeLock;
// TODO 黑白名单|考虑添加到每个插件内部自动添加|优化RUN逻辑代码
private static $unlock_hour = 24;
private static $unlock_time = 0;
- private static $fillable = ['Login', 'Sleep', 'Daily', 'Judge', 'MasterSite', 'GiftSend', 'Task', 'Silver2Coin', 'GroupSignIn', 'AwardRecord', 'Statistics'];
+ private static $fillable = ['Login', 'Schedule', 'Daily', 'Judge', 'MasterSite', 'GiftSend', 'Task', 'Silver2Coin', 'GroupSignIn', 'AwardRecord', 'Statistics'];
private static $guarded = ['Barrage', 'GiftHeart', 'Heart', 'Silver', 'MaterialObject', 'AloneTcpClient', 'ZoneTcpClient', 'StormRaffle', 'GuardRaffle', 'PkRaffle', 'GiftRaffle', 'AnchorRaffle'];
private static $sleep_section = [];
diff --git a/src/plugin/Silver.php b/src/plugin/Silver.php
index dfb5070..f777807 100644
--- a/src/plugin/Silver.php
+++ b/src/plugin/Silver.php
@@ -44,7 +44,11 @@ class Silver
if (isset($data['code']) && $data['code'] == -10017) {
Log::notice($data['message']);
- self::setLock(24 * 60 * 60);
+ if (User::isMaster()) {
+ self::setLock(self::timing(6));
+ } else {
+ self::setLock(self::timing(10));
+ }
return;
}
@@ -74,7 +78,7 @@ class Silver
'time_end' => self::$task['time_end'],
'time_start' => self::$task['time_start']
];
- $data = Curl::get('app',$url, Sign::common($payload));
+ $data = Curl::get('app', $url, Sign::common($payload));
$data = json_decode($data, true);
if ($data['code'] == -800) {
diff --git a/src/plugin/Silver2Coin.php b/src/plugin/Silver2Coin.php
index 4a50dc4..21cf74c 100644
--- a/src/plugin/Silver2Coin.php
+++ b/src/plugin/Silver2Coin.php
@@ -24,7 +24,7 @@ class Silver2Coin
return;
}
if (self::appSilver2coin() && self::pcSilver2coin()) {
- self::setLock(24 * 60 * 60);
+ self::setLock(self::timing(10));
return;
}
self::setLock(3600);
diff --git a/src/plugin/StormRaffle.php b/src/plugin/StormRaffle.php
index 9eb3a4f..5886523 100644
--- a/src/plugin/StormRaffle.php
+++ b/src/plugin/StormRaffle.php
@@ -51,7 +51,7 @@ class StormRaffle extends BaseRaffle
}
// 过滤抽奖范围
self::$drop_rate = getenv('STORM_DROPRATE') !== "" ? (int)getenv('STORM_DROPRATE') : 0;
- if (random_int(1, 100) <= (int)self::$drop_rate) {
+ if (mt_rand(1, 100) <= (int)self::$drop_rate) {
return false;
}
// 去重
@@ -88,7 +88,6 @@ class StormRaffle extends BaseRaffle
* @use 创建抽奖任务
* @param array $raffles
* @return array
- * @throws \Exception
*/
protected static function createLottery(array $raffles): array
{
@@ -96,7 +95,7 @@ class StormRaffle extends BaseRaffle
$user_info = User::parseCookies();
foreach ($raffles as $raffle) {
self::$attempt = getenv('STORM_ATTEMPT') !== "" ? explode(',', getenv('STORM_ATTEMPT')) : [30, 50];
- $num = random_int((int)self::$attempt[0], (int)self::$attempt[1]);
+ $num = mt_rand((int)self::$attempt[0], (int)self::$attempt[1]);
$payload = [
'id' => $raffle['raffle_id'],
'roomid' => $raffle['room_id'],
diff --git a/src/plugin/User.php b/src/plugin/User.php
index eb397eb..a2ef3fa 100644
--- a/src/plugin/User.php
+++ b/src/plugin/User.php
@@ -10,18 +10,14 @@
namespace BiliHelper\Plugin;
-use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
-use BiliHelper\Util\TimeLock;
use BiliHelper\Core\Config;
-
class User
{
/**
* @use 实名检测
* @return bool
- * @throws \Exception
*/
public static function realNameCheck(): bool
{
@@ -40,7 +36,6 @@ class User
/**
* @use 老爷检测
* @return bool
- * @throws \Exception
*/
public static function isMaster(): bool
{
@@ -57,7 +52,6 @@ class User
/**
* @use 写入用户名
* @return bool
- * @throws \Exception
*/
public static function userInfo(): bool
{
@@ -87,11 +81,11 @@ class User
return json_decode($raw, true);
}
+
/**
* @use Web User
* @param null $room_id
* @return mixed
- * @throws \Exception
*/
public static function webGetUserInfo($room_id = null)
{
diff --git a/src/plugin/ZoneTcpClient.php b/src/plugin/ZoneTcpClient.php
index 9741ba3..9992c25 100644
--- a/src/plugin/ZoneTcpClient.php
+++ b/src/plugin/ZoneTcpClient.php
@@ -310,7 +310,7 @@ class ZoneTcpClient
private static function genHandshakePkg($room_id): string
{
return self::packMsg(json_encode([
- 'uid' => random_int(1000000, 2999999),
+ 'uid' => mt_rand(1000000, 2999999),
'roomid' => intval($room_id),
]), 0x0007);
}
diff --git a/src/util/TimeLock.php b/src/util/TimeLock.php
index 74e2eb9..42a077d 100644
--- a/src/util/TimeLock.php
+++ b/src/util/TimeLock.php
@@ -15,7 +15,6 @@ trait TimeLock
{
public static $lock = 0;
-
/**
* @use 设置时间
* @param int $lock
@@ -25,7 +24,6 @@ trait TimeLock
static::$lock = time() + $lock;
}
-
/**
* @use 获取时间
* @return int
@@ -35,4 +33,15 @@ trait TimeLock
return static::$lock;
}
+ /**
+ * @use 定时
+ * @param int $hour
+ * @return int
+ */
+ public static function timing(int $hour): int
+ {
+ // now today tomorrow yesterday
+ return strtotime('tomorrow') + ($hour * 60 * 60) - time();
+ }
+
}
\ No newline at end of file