[perf] tune-up

This commit is contained in:
Lkeme 2022-02-18 10:31:16 +08:00
parent a406e674b1
commit fa4ae37159
30 changed files with 281 additions and 117 deletions

View File

@ -8,6 +8,25 @@
[comment]: <> (</details>) [comment]: <> (</details>)
## v1.1.0.220218 alpha (2022-02-18)
### Added
-
### Changed
-
### Fixed
-
### Remarks
- 注意文档文件、配置文件有些许改动
-
## v1.0.2.211115 alpha (2021-11-15) ## v1.0.2.211115 alpha (2021-11-15)
### Added ### Added
@ -250,7 +269,7 @@
### Changed ### Changed
- 删除过期活动 - 删除过期活动
- 更新风纪委员 - 更新風機委員
- 更新银瓜子兑换硬币 - 更新银瓜子兑换硬币
- 更新点亮勋章 - 更新点亮勋章
- 更新部分日志打印输出 - 更新部分日志打印输出

View File

@ -16,7 +16,7 @@
<p align="center"> <p align="center">
<img src="https://img.shields.io/badge/Version-1.0.2.211115-orange.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/Version-1.1.0.220218-orange.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/PHP-8.0+-green.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/PHP-8.0+-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge">
@ -67,44 +67,49 @@ Group: [163955623](https://jq.qq.com/?_wv=1027&k=1QMFTUEO) | **请不要来问
以下任务都是按设定周期自动执行,`true`为正常使用,`false`为暂停使用或抛弃。 以下任务都是按设定周期自动执行,`true`为正常使用,`false`为暂停使用或抛弃。
| plugin | status | version | cycle | description | <details open>
|-----------------|--------|----------|--------|---------------------------------------------| <summary>点击展开</summary>
| CheckUpdate | true | 21.11.15 | 待整理 | 程序检查更新 |
| Login | true | 21.11.15 | 待整理 | 账号登录、刷新、维持 | | plugin | status | version | cycle | description |
| Schedule | true | 21.11.15 | 待整理 | 控制插件运行周期 | |-----------------|--------|----------|-------|-------------------------|
| MainSite | true | 21.11.15 | 待整理 | 投币、观看、分享视频 (速升6级不是梦) | | CheckUpdate | true | 22.01.18 | 待整理 | 程序检查更新 |
| DailyBag | true | 21.11.15 | 待整理 | 双端领取日常/周常礼包 | | Login | true | 22.01.18 | 待整理 | 账号登录、刷新、维持 |
| ManGa | true | 21.11.15 | 待整理 | 漫画签到、分享 | | Schedule | true | 22.01.18 | 待整理 | 控制插件运行周期 |
| ActivityLottery | true | 21.11.15 | 待整理 | 主站活动九宫格抽奖 | | MainSite | true | 22.01.18 | 待整理 | 投币、观看、分享视频 (速升6级不是梦) |
| Competition | true | 21.11.15 | 待整理 | 游戏赛事竞猜 | | DailyBag | true | 22.01.18 | 待整理 | 双端领取日常/周常礼包 |
| DoubleHeart | true | 21.11.15 | 待整理 | 双端心跳 (姥爷直播经验) | | ManGa | true | 22.01.18 | 待整理 | 漫画签到、分享 |
| DailyTask | true | 21.11.15 | 待整理 | 直播每日任务(签到、观看) | | ActivityLottery | true | 22.01.18 | 待整理 | 主站活动九宫格抽奖 |
| Barrage | true | 21.11.15 | 待整理 | 保持活跃弹幕 | | Competition | true | 22.01.18 | 待整理 | 游戏赛事竞猜 |
| Silver2Coin | true | 21.11.15 | 待整理 | 银瓜子兑换硬币 | | DoubleHeart | true | 22.01.18 | 待整理 | 双端心跳 (姥爷直播经验) |
| Judge | true | 21.11.15 | 待整理 | 风纪委员投票 | | DailyTask | true | 22.01.18 | 待整理 | 直播每日任务(签到、观看) |
| GiftSend | true | 21.11.15 | 待整理 | 礼物赠送、维持每日勋章亲密度 | | Barrage | true | 22.01.18 | 待整理 | 保持活跃弹幕 |
| GroupSignIn | true | 21.11.15 | 待整理 | 友爱社签到 | | Silver2Coin | true | 22.01.18 | 待整理 | 银瓜子兑换硬币 |
| GiftHeart | true | 21.11.15 | 待整理 | 日常心跳每日礼包礼物 | | Judge | true | 22.01.18 | 待整理 | 風機委員投票 |
| SmallHeart | true | 21.11.15 | 待整理 | 直播挂机每日24个小心心 | | GiftSend | true | 22.01.18 | 待整理 | 礼物赠送、维持每日勋章亲密度 |
| MaterialObject | true | 21.11.15 | 待整理 | 直播金色宝箱实物抽奖 | | GroupSignIn | true | 22.01.18 | 待整理 | 友爱社签到 |
| AloneTcpClient | true | 21.11.15 | 待整理 | 作者的独立直播监控(可支持本项目哦) | | GiftHeart | true | 22.01.18 | 待整理 | 日常心跳每日礼包礼物 |
| ZoneTcpClient | true | 21.11.15 | 待整理 | 官方的分区直播监控 | | SmallHeart | true | 22.01.18 | 待整理 | 直播挂机每日24个小心心 |
| StormRaffle | true | 21.11.15 | 待整理 | 直播节奏风暴抽奖、亿元 | | MaterialObject | true | 22.01.18 | 待整理 | 直播金色宝箱实物抽奖 |
| GiftRaffle | true | 21.11.15 | 待整理 | 直播礼物抽奖 | | AloneTcpClient | true | 22.01.18 | 待整理 | 作者的独立直播监控(可支持本项目哦) |
| PkRaffle | true | 21.11.15 | 待整理 | 直播大乱斗抽奖 | | ZoneTcpClient | true | 22.01.18 | 待整理 | 官方的分区直播监控 |
| GuardRaffle | true | 21.11.15 | 待整理 | 直播大航海抽奖 | | StormRaffle | true | 22.01.18 | 待整理 | 直播节奏风暴抽奖、亿元 |
| AnchorRaffle | true | 21.11.15 | 待整理 | 直播天选时刻抽奖 | | GiftRaffle | true | 22.01.18 | 待整理 | 直播礼物抽奖 |
| GiftRaffle | true | 21.11.15 | 待整理 | 直播礼物抽奖 | | PkRaffle | true | 22.01.18 | 待整理 | 直播大乱斗抽奖 |
| AwardRecord | true | 21.11.15 | 待整理 | 最新的中奖纪录通知 | | GuardRaffle | true | 22.01.18 | 待整理 | 直播大航海抽奖 |
| Forward | true | 21.11.15 | 待整理 | 主站动态抽奖转发 | | AnchorRaffle | true | 22.01.18 | 待整理 | 直播天选时刻抽奖 |
| CapsuleLottery | true | 21.11.15 | 待整理 | 直播扭蛋活动抽奖 | | GiftRaffle | true | 22.01.18 | 待整理 | 直播礼物抽奖 |
| PolishTheMedal | true | 21.11.15 | 待整理 | 每日自动点亮灰色勋章 | | AwardRecord | true | 22.01.18 | 待整理 | 最新的中奖纪录通知 |
| CapsuleLottery | true | 21.11.15 | 待整理 | 直播扭蛋活动抽奖 | | Forward | true | 22.01.18 | 待整理 | 主站动态抽奖转发 |
| VipPrivilege | true | 21.11.15 | 待整理 | 每月领取年度大会员特权(B币券、会员购优惠券) | | CapsuleLottery | true | 22.01.18 | 待整理 | 直播扭蛋活动抽奖 |
| BpConsumption | true | 21.11.15 | 待整理 | 每月消费使用年度大会员特权的B币券 | | PolishTheMedal | true | 22.01.18 | 待整理 | 每日自动点亮灰色勋章 |
| Statistics | true | 21.11.15 | 待整理 | 全局抽奖结果统计 | | CapsuleLottery | true | 22.01.18 | 待整理 | 直播扭蛋活动抽奖 |
| LiveReservation | true | 21.11.15 | 待整理 | 直播预约有奖 | | VipPrivilege | true | 22.01.18 | 待整理 | 每月领取年度大会员特权(B币券、会员购优惠券) |
| Silver | false | 21.03.27 | 待整理 | 直播银瓜子自动开启宝箱 | | BpConsumption | true | 22.01.18 | 待整理 | 每月消费使用年度大会员特权的B币券 |
| Statistics | true | 22.01.18 | 待整理 | 全局抽奖结果统计 |
| LiveReservation | true | 22.01.18 | 待整理 | 直播预约有奖 |
| Silver | false | 21.03.27 | 待整理 | 直播银瓜子自动开启宝箱 |
</details>
## 🖥️星图 ## 🖥️星图

View File

@ -3,8 +3,8 @@ bili_version: 0.0.1
# Android # Android
bili_a: bili_a:
package: "tv.danmaku.bili" package: "tv.danmaku.bili"
version: "6.59.0" version: "6.60.0"
build: "6590300" build: "6600300"
channel: "bili" channel: "bili"
device: "phone" device: "phone"
mobi_app: "android" mobi_app: "android"

View File

@ -134,9 +134,10 @@ content =
[manga] [manga]
enable = false enable = false
; 风纪委员投票|需要实名认证|慎用 ; 風機委員投票|需要实名认证|慎用
[judgement] [judgement]
enable = false enable = false
auto_apply = false
; 大会员权益|年度大会员专享 ; 大会员权益|年度大会员专享
[vip_privilege] [vip_privilege]

View File

@ -5,10 +5,10 @@
"source": "https://github.com/lkeme/BiliHelper-personal", "source": "https://github.com/lkeme/BiliHelper-personal",
"raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json", "raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json",
"purge_url": "https://purge.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json", "purge_url": "https://purge.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json",
"version": "1.0.2.211115", "version": "1.1.0.220218",
"des": "程序有更新,请及时线上查看更新哦~", "des": "程序有更新,请及时线上查看更新哦~",
"time": "2021年11月15日15:40:35", "time": "2022年2月18日10:40:35",
"ini_version": "0.0.1", "ini_version": "0.0.1",
"ini_des": "配置有更新,请及时线上查看更新哦~", "ini_des": "配置有更新,请及时线上查看更新哦~",
"ini_time": "2021年11月15日15:40:35" "ini_time": "2022年2月18日10:40:35"
} }

View File

@ -10,7 +10,6 @@
namespace BiliHelper\Core; namespace BiliHelper\Core;
use BiliHelper\Plugin\Live;
use Throwable; use Throwable;
use Amp\Loop; use Amp\Loop;
use BiliHelper\Script\BaseTask; use BiliHelper\Script\BaseTask;

View File

@ -102,7 +102,7 @@ class Curl
'tasks' => $tasks, 'tasks' => $tasks,
'counter' => 1, 'counter' => 1,
'count' => count($tasks), 'count' => count($tasks),
'concurrency' => count($tasks) < 10 ? count($tasks) : 10 'concurrency' => min(count($tasks), 10)
]; ];
Log::debug("ASYNC: $url"); Log::debug("ASYNC: $url");
$headers = self::getHeaders($os, $headers); $headers = self::getHeaders($os, $headers);
@ -120,10 +120,10 @@ class Curl
'fulfilled' => function ($response, $index) { 'fulfilled' => function ($response, $index) {
$res = $response->getBody(); $res = $response->getBody();
// Log::notice("启动多线程 {$index}"); // Log::notice("启动多线程 {$index}");
array_push(self::$results, [ self::$results[] = [
'content' => $res, 'content' => $res,
'source' => self::$async_opt['tasks'][$index]['source'] 'source' => self::$async_opt['tasks'][$index]['source']
]); ];
self::countedAndCheckEnded(); self::countedAndCheckEnded();
}, },
'rejected' => function ($reason, $index) { 'rejected' => function ($reason, $index) {

View File

@ -76,11 +76,11 @@ class AnchorRaffle extends BaseRaffle
User::setUserFollow($need_follow_uid); User::setUserFollow($need_follow_uid);
User::tagAddUsers($need_follow_uid, self::$group_id); User::tagAddUsers($need_follow_uid, self::$group_id);
// 添加到检测中奖 // 添加到检测中奖
array_push(self::$wait_un_follows, [ self::$wait_un_follows[] = [
'uid' => $need_follow_uid, 'uid' => $need_follow_uid,
'anchor_id' => $anchor_id, 'anchor_id' => $anchor_id,
'time' => $time, 'time' => $time,
]); ];
} }
} }
@ -96,7 +96,7 @@ class AnchorRaffle extends BaseRaffle
if ($wait_un_follow['uid'] == $uid && $wait_un_follow['uid'] == $anchor_id) { if ($wait_un_follow['uid'] == $uid && $wait_un_follow['uid'] == $anchor_id) {
continue; continue;
} }
array_push($new_list, $wait_un_follow); $new_list[] = $wait_un_follow;
} }
self::$wait_un_follows = $new_list; self::$wait_un_follows = $new_list;
} }
@ -113,7 +113,7 @@ class AnchorRaffle extends BaseRaffle
// 如果获取默认关注错误 或者 为空则补全一个 // 如果获取默认关注错误 或者 为空则补全一个
self::$default_follows = User::fetchTagFollowings(); self::$default_follows = User::fetchTagFollowings();
if (empty(self::$default_follows)) { if (empty(self::$default_follows)) {
array_push(self::$default_follows, 1); self::$default_follows[] = 1;
} }
return self::$default_follows; return self::$default_follows;
} }
@ -183,7 +183,7 @@ class AnchorRaffle extends BaseRaffle
]; ];
// Statistics::addPushList($data['raffle_name']); // Statistics::addPushList($data['raffle_name']);
Statistics::addPushList(self::ACTIVE_TITLE); Statistics::addPushList(self::ACTIVE_TITLE);
array_push(self::$wait_list, $data); self::$wait_list[] = $data;
return true; return true;
} }
@ -205,14 +205,14 @@ class AnchorRaffle extends BaseRaffle
'csrf' => getCsrf(), 'csrf' => getCsrf(),
'visit_id' => '' 'visit_id' => ''
]; ];
array_push($tasks, [ $tasks[] = [
'payload' => Sign::common($payload), 'payload' => Sign::common($payload),
'source' => [ 'source' => [
'room_id' => $raffle['room_id'], 'room_id' => $raffle['room_id'],
'raffle_id' => $raffle['raffle_id'], 'raffle_id' => $raffle['raffle_id'],
'raffle_name' => $raffle['raffle_name'] 'raffle_name' => $raffle['raffle_name']
] ]
]); ];
} }
// print_r($results); // print_r($results);
return Curl::async('app', $url, $tasks); return Curl::async('app', $url, $tasks);

View File

@ -59,7 +59,7 @@ class AwardRecord
// 防止异常 // 防止异常
if (!isset($de_raw['data']) || !isset($de_raw['data']['list'])) { if (!isset($de_raw['data']) || !isset($de_raw['data']['list'])) {
Log::warning("获取天选时刻获奖记录错误: " . json_encode($de_raw, JSON_FORCE_OBJECT)); Log::warning("获取天选时刻获奖记录错误: " . json_encode($de_raw, JSON_FORCE_OBJECT));
self::$anchor_lock = time() + 1 * 60 * 60; self::$anchor_lock = time() + 60 * 60;
return; return;
} }
foreach ($de_raw['data']['list'] as $anchor) { foreach ($de_raw['data']['list'] as $anchor) {
@ -75,7 +75,7 @@ class AwardRecord
Log::notice("天选时刻于" . $anchor['end_time'] . "获奖: $info ,请留意查看..."); Log::notice("天选时刻于" . $anchor['end_time'] . "获奖: $info ,请留意查看...");
Notice::push('anchor', $info); Notice::push('anchor', $info);
} }
array_push(self::$anchor_list, $anchor['id']); self::$anchor_list[] = $anchor['id'];
} }
// 处理取关操作 // 处理取关操作
foreach (AnchorRaffle::$wait_un_follows as $wait_un_follow) { foreach (AnchorRaffle::$wait_un_follows as $wait_un_follow) {
@ -108,7 +108,7 @@ class AwardRecord
// 防止异常 // 防止异常
if (!isset($de_raw['data']) || !isset($de_raw['data']['list']) || $de_raw['code']) { if (!isset($de_raw['data']) || !isset($de_raw['data']['list']) || $de_raw['code']) {
Log::warning("获取实物奖励获奖记录错误: " . $de_raw['msg']); Log::warning("获取实物奖励获奖记录错误: " . $de_raw['msg']);
self::$raffle_lock = time() + 1 * 60 * 60; self::$raffle_lock = time() + 60 * 60;
return; return;
} }
foreach ($de_raw['data']['list'] as $raffle) { foreach ($de_raw['data']['list'] as $raffle) {
@ -124,7 +124,7 @@ class AwardRecord
Log::notice("实物奖励于" . $raffle['create_time'] . "获奖: $info ,请留意查看..."); Log::notice("实物奖励于" . $raffle['create_time'] . "获奖: $info ,请留意查看...");
Notice::push('raffle', $info); Notice::push('raffle', $info);
} }
array_push(self::$raffle_list, $raffle['id']); self::$raffle_list[] = $raffle['id'];
} }
self::$raffle_lock = time() + 6 * 60 * 60; self::$raffle_lock = time() + 6 * 60 * 60;
} }

View File

@ -151,7 +151,7 @@ class Competition
foreach ($de_raw['data']['list'] as $question) { foreach ($de_raw['data']['list'] as $question) {
// 判断是否有效 正2分钟 // 判断是否有效 正2分钟
if (($question['contest']['stime'] - 600 - 120) > time()) { if (($question['contest']['stime'] - 600 - 120) > time()) {
array_push($questions, $question); $questions[] = $question;
} }
} }
// 和页面的不匹配 跳出 // 和页面的不匹配 跳出

View File

@ -53,6 +53,10 @@ class DataTreating
// 天选时刻 // 天选时刻
AnchorRaffle::pushToQueue($info); AnchorRaffle::pushToQueue($info);
break; break;
case 'red_pocket':
// 利是包
RedPocketRaffle::pushToQueue($info);
break;
default: default:
break; break;
} }

View File

@ -162,7 +162,7 @@ class Forward
if ($flag) { if ($flag) {
self::$del_dynamic[$did] = $msg; self::$del_dynamic[$did] = $msg;
if (isset($card['origin_user']['info']['uid'])) { if (isset($card['origin_user']['info']['uid'])) {
array_push(self::$un_follows, $card['origin_user']['info']['uid']); self::$un_follows[] = $card['origin_user']['info']['uid'];
} }
} }
} }
@ -261,7 +261,7 @@ class Forward
// 如果获取默认关注错误 或者 为空则补全一个 // 如果获取默认关注错误 或者 为空则补全一个
self::$default_follows = User::fetchTagFollowings(); self::$default_follows = User::fetchTagFollowings();
if (empty(self::$default_follows)) { if (empty(self::$default_follows)) {
array_push(self::$default_follows, 1); self::$default_follows[] = 1;
} }
return self::$default_follows; return self::$default_follows;
} }
@ -275,7 +275,7 @@ class Forward
$data = json(self::$repository); $data = json(self::$repository);
// 给个默认值 // 给个默认值
$data = $data->find("DynamicForward.default", []); $data = $data->find("DynamicForward.default", []);
array_push($data, getConf('auto_reply_text', 'dynamic')); $data[] = getConf('auto_reply_text', 'dynamic');
return $data; return $data;
} }

View File

@ -56,7 +56,7 @@ class GiftRaffle extends BaseRaffle
'wait' => $gift['time_wait'] + time(), 'wait' => $gift['time_wait'] + time(),
]; ];
Statistics::addPushList($data['raffle_name']); Statistics::addPushList($data['raffle_name']);
array_push(self::$wait_list, $data); self::$wait_list[] = $data;
} }
return true; return true;
} }
@ -82,14 +82,14 @@ class GiftRaffle extends BaseRaffle
'csrf' => getCsrf(), 'csrf' => getCsrf(),
'visit_id' => '' 'visit_id' => ''
]; ];
array_push($tasks, [ $tasks[] = [
'payload' => Sign::common($payload), 'payload' => Sign::common($payload),
'source' => [ 'source' => [
'room_id' => $raffle['room_id'], 'room_id' => $raffle['room_id'],
'raffle_id' => $raffle['raffle_id'], 'raffle_id' => $raffle['raffle_id'],
'raffle_name' => $raffle['raffle_name'] 'raffle_name' => $raffle['raffle_name']
] ]
]); ];
} }
// print_r($results); // print_r($results);
return Curl::async('app', $url, $tasks); return Curl::async('app', $url, $tasks);

View File

@ -73,7 +73,7 @@ class GuardRaffle extends BaseRaffle
'wait' => time() + mt_rand(5, 30) 'wait' => time() + mt_rand(5, 30)
]; ];
Statistics::addPushList($data['raffle_name']); Statistics::addPushList($data['raffle_name']);
array_push(self::$wait_list, $data); self::$wait_list[] = $data;
} }
return true; return true;
} }
@ -96,14 +96,14 @@ class GuardRaffle extends BaseRaffle
'csrf' => getCsrf(), 'csrf' => getCsrf(),
'visit_id' => '' 'visit_id' => ''
]; ];
array_push($tasks, [ $tasks[] = [
'payload' => Sign::common($payload), 'payload' => Sign::common($payload),
'source' => [ 'source' => [
'room_id' => $raffle['room_id'], 'room_id' => $raffle['room_id'],
'raffle_id' => $raffle['raffle_id'], 'raffle_id' => $raffle['raffle_id'],
'raffle_name' => $raffle['raffle_name'] 'raffle_name' => $raffle['raffle_name']
] ]
]); ];
} }
// print_r($results); // print_r($results);
return Curl::async('app', $url, $tasks); return Curl::async('app', $url, $tasks);

View File

@ -139,9 +139,10 @@ class Judge
$de_raw = json_decode($raw, true); $de_raw = json_decode($raw, true);
// {"code":0,"message":"0","ttl":1} // {"code":0,"message":"0","ttl":1}
if (isset($de_raw['code']) && $de_raw['code']) { if (isset($de_raw['code']) && $de_raw['code']) {
Log::warning("申请连任失败 $raw"); Log::warning("提交連任申請失敗 $raw");
} else { } else {
Log::notice("申请连任成功 $raw"); Log::notice("提交連任申請成功 $raw");
Notice::push('jury_auto_apply', '提交連任申請成功');
} }
} }
@ -203,8 +204,8 @@ class Judge
// {"code":0,"message":"0","ttl":1,"data":{"case_id":"AC1xx411c7At"}} // {"code":0,"message":"0","ttl":1,"data":{"case_id":"AC1xx411c7At"}}
// {"code":25008,"message":"真给力 , 移交众裁的举报案件已经被处理完了","ttl":1} // {"code":25008,"message":"真给力 , 移交众裁的举报案件已经被处理完了","ttl":1}
// {"code":25014,"message":"25014","ttl":1} // {"code":25014,"message":"25014","ttl":1}
// {"code":25005,"message":"请成为风纪委员后再试","ttl":1} // {"code":25005,"message":"请成为風機委員后再试","ttl":1}
// {"code":25006,"message":"风纪委员资格已过期","ttl":1} // {"code":25006,"message":"風機委員资格已过期","ttl":1}
if (isset($de_raw['code']) && $de_raw['code']) { if (isset($de_raw['code']) && $de_raw['code']) {
switch ($de_raw['code']) { switch ($de_raw['code']) {
case 25005: case 25005:
@ -245,7 +246,7 @@ class Judge
$payload = []; $payload = [];
$raw = Curl::get('pc', $url, $payload, self::$default_headers); $raw = Curl::get('pc', $url, $payload, self::$default_headers);
$de_raw = json_decode($raw, true); $de_raw = json_decode($raw, true);
// {"code":25005,"message":"请成为风纪委员后再试","ttl":1} // {"code":25005,"message":"请成为風機委員后再试","ttl":1}
// {"code":0,"message":"0","ttl":1,"data":{"uname":"","face":"http://i2.hdslb.com/bfs/face/.jpg","case_total":,"term_end":,"status":1}} // {"code":0,"message":"0","ttl":1,"data":{"uname":"","face":"http://i2.hdslb.com/bfs/face/.jpg","case_total":,"term_end":,"status":1}}
if (isset($de_raw['code']) && $de_raw['code']) { if (isset($de_raw['code']) && $de_raw['code']) {
return false; return false;
@ -256,12 +257,17 @@ class Judge
// "apply_status": 0 申请连任后 // "apply_status": 0 申请连任后
// "apply_status": 5 审核连任中 // "apply_status": 5 审核连任中
// "apply_status": 3 连任成功后 // "apply_status": 3 连任成功后
// "apply_status": 4 申请连任失败(?)
// 理论上正常 // 理论上正常
if ($de_raw['data']['status'] == 1) { if ($de_raw['data']['status'] == 1) {
Log::info('你可以参与社区众裁,共创良好环境哦~'); Log::info('你可以參與社區衆裁,共創良好環境哦~');
return true; return true;
} }
// 只是嘗試
if ($de_raw['data']['apply_status'] == -1 && getConf('auto_apply', 'judgement')) {
self::juryApply();
}
return false; return false;
} }

View File

@ -36,7 +36,7 @@ class Live
$areas = range(1, 6); $areas = range(1, 6);
} else { } else {
foreach ($de_raw['data'] as $area) { foreach ($de_raw['data'] as $area) {
array_push($areas, $area['id']); $areas[] = $area['id'];
} }
} }
return $areas; return $areas;
@ -405,7 +405,7 @@ class Live
// 去除永久礼物 // 去除永久礼物
if ($vo['corner_mark'] == '永久') continue; if ($vo['corner_mark'] == '永久') continue;
if ($vo['gift_id'] == $gift_id && $vo['gift_name'] == $gift_name) { if ($vo['gift_id'] == $gift_id && $vo['gift_name'] == $gift_name) {
array_push($new_bag_list, $vo); $new_bag_list[] = $vo;
} }
} }
} }
@ -471,7 +471,7 @@ class Live
if ($de_raw['code'] == 0) { if ($de_raw['code'] == 0) {
foreach ($de_raw['data']['list'] as $room) { foreach ($de_raw['data']['list'] as $room) {
array_push($room_ids, $room['roomid']); $room_ids[] = $room['roomid'];
} }
} }
return $room_ids; return $room_ids;
@ -509,6 +509,38 @@ class Live
return json_decode($raw, true); return json_decode($raw, true);
} }
/**
* @use 直播间抽奖检查
* @param int $room_id
* @return array
*/
public static function getLotteryCheck(int $room_id): array
{
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/lottery/Check';
$payload = [
'roomid' => $room_id,
];
$raw = Curl::get('other', $url, $payload);
return json_decode($raw, true);
}
/**
* @use 获取直播间抽奖信息
* @param int $room_id
* @return array
*/
public static function getLotteryInfoWeb(int $room_id): array
{
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/lottery/getLotteryInfoWeb';
$payload = [
'roomid' => $room_id,
];
$raw = Curl::get('other', $url, $payload);
return json_decode($raw, true);
}
/** /**
* @use 获取用户关注数 * @use 获取用户关注数
* @param int $mid * @param int $mid

View File

@ -518,7 +518,7 @@ class Login
$cookies = []; $cookies = [];
foreach ($headers as $header) { foreach ($headers as $header) {
preg_match_all('/^(.*);/iU', $header, $cookie); preg_match_all('/^(.*);/iU', $header, $cookie);
array_push($cookies, $cookie[0][0]); $cookies[] = $cookie[0][0];
} }
return implode("", array_reverse($cookies)); return implode("", array_reverse($cookies));
} }

View File

@ -119,7 +119,7 @@ class MainSite
// 库存数量 // 库存数量
$stock_num = self::getCoin(); $stock_num = self::getCoin();
// 实际数量 处理硬币库存少于预计数量 // 实际数量 处理硬币库存少于预计数量
$actual_num = intval($estimate_num > $stock_num ? $stock_num : $estimate_num) - self::coinLog(); $actual_num = intval(min($estimate_num, $stock_num)) - self::coinLog();
Log::info("当前硬币库存 $stock_num 预计投币 $estimate_num 实际投币 $actual_num"); Log::info("当前硬币库存 $stock_num 预计投币 $estimate_num 实际投币 $actual_num");
// 上限 // 上限
if ($actual_num <= 0) { if ($actual_num <= 0) {
@ -186,7 +186,7 @@ class MainSite
if ($index >= $num) { if ($index >= $num) {
break; break;
} }
array_push($aids, $card['desc']['rid']); $aids[] = $card['desc']['rid'];
} }
// 此处补全缺失 // 此处补全缺失
if (count($aids) < $num) { if (count($aids) < $num) {
@ -220,12 +220,12 @@ class MainSite
if (in_array($rand_num, $rand_nums)) { if (in_array($rand_num, $rand_nums)) {
continue; continue;
} else { } else {
array_push($rand_nums, $rand_num); $rand_nums[] = $rand_num;
break; break;
} }
} }
$aid = $de_raw['data']['list'][$rand_nums[$i]]['aid']; $aid = $de_raw['data']['list'][$rand_nums[$i]]['aid'];
array_push($aids, $aid); $aids[] = $aid;
} }
return $aids; return $aids;
@ -256,7 +256,7 @@ class MainSite
$temps = array_rand($de_raw['data']['archives'], $num); $temps = array_rand($de_raw['data']['archives'], $num);
} }
foreach ($temps as $temp) { foreach ($temps as $temp) {
array_push($aids, $de_raw['data']['archives'][$temp]['aid']); $aids[] = $de_raw['data']['archives'][$temp]['aid'];
} }
return $aids; return $aids;
} }

View File

@ -121,13 +121,13 @@ class MaterialObject
$last_round = end($rounds); $last_round = end($rounds);
// 最后抽奖轮次无效 // 最后抽奖轮次无效
if ($last_round['join_end_time'] < time()) { if ($last_round['join_end_time'] < time()) {
array_push(self::$invalid_aids, $probe_aid); self::$invalid_aids[] = $probe_aid;
continue; continue;
} }
// 过滤敏感词 // 过滤敏感词
$title = $response['data']['title']; $title = $response['data']['title'];
if (self::filterTitleWords($title)) { if (self::filterTitleWords($title)) {
array_push(self::$invalid_aids, $probe_aid); self::$invalid_aids[] = $probe_aid;
continue; continue;
} }
// 过滤抽奖轮次 // 过滤抽奖轮次
@ -135,10 +135,10 @@ class MaterialObject
if ($round_num == 0) { if ($round_num == 0) {
continue; continue;
} }
array_push($lottery_list, [ $lottery_list[] = [
'aid' => $probe_aid, 'aid' => $probe_aid,
'num' => $round_num, 'num' => $round_num,
]); ];
} }
// 缓存结束 需要的数据的放进缓存 // 缓存结束 需要的数据的放进缓存
setCache('invalid_aids', self::$invalid_aids); setCache('invalid_aids', self::$invalid_aids);

View File

@ -122,8 +122,12 @@ class Notice
'content' => "[$now_time] 用户: $uname 详情: $result" 'content' => "[$now_time] 用户: $uname 详情: $result"
], ],
'jury_leave_office' => [ 'jury_leave_office' => [
'title' => '已卸任风纪委员', 'title' => '已卸任風機委員',
'content' => "[$now_time] 用户: $uname 详情: $result ,请及时关注风纪委员连任状态哦~" 'content' => "[$now_time] 用户: $uname 详情: $result ,请及时关注風機委員连任状态哦~"
],
'jury_auto_apply' => [
'title' => '嘗試連任風機委員',
'content' => "[$now_time] 用户: $uname 详情: $result ,请及时关注風機委員连任状态哦~"
], ],
default => [ default => [
'title' => '推送消息异常记录', 'title' => '推送消息异常记录',

View File

@ -12,7 +12,6 @@ namespace BiliHelper\Plugin;
use BiliHelper\Core\Log; use BiliHelper\Core\Log;
use BiliHelper\Core\Curl; use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
use BiliHelper\Util\BaseRaffle; use BiliHelper\Util\BaseRaffle;
class PkRaffle extends BaseRaffle class PkRaffle extends BaseRaffle
@ -58,7 +57,7 @@ class PkRaffle extends BaseRaffle
'wait' => time() + mt_rand(5, 25) 'wait' => time() + mt_rand(5, 25)
]; ];
Statistics::addPushList($data['raffle_name']); Statistics::addPushList($data['raffle_name']);
array_push(self::$wait_list, $data); self::$wait_list[] = $data;
} }
return true; return true;
} }
@ -79,14 +78,14 @@ class PkRaffle extends BaseRaffle
'csrf_token' => getCsrf(), 'csrf_token' => getCsrf(),
"csrf" => getCsrf(), "csrf" => getCsrf(),
]; ];
array_push($tasks, [ $tasks[] = [
'payload' => Sign::common($payload), 'payload' => Sign::common($payload),
'source' => [ 'source' => [
'room_id' => $raffle['room_id'], 'room_id' => $raffle['room_id'],
'raffle_id' => $raffle['raffle_id'], 'raffle_id' => $raffle['raffle_id'],
'raffle_name' => $raffle['raffle_name'] 'raffle_name' => $raffle['raffle_name']
] ]
]); ];
} }
// print_r($results); // print_r($results);
return Curl::async('app', $url, $tasks); return Curl::async('app', $url, $tasks);
@ -112,7 +111,7 @@ class PkRaffle extends BaseRaffle
if (isset($de_raw['code']) && $de_raw['code'] == 0) { if (isset($de_raw['code']) && $de_raw['code'] == 0) {
Statistics::addSuccessList($data['raffle_name']); Statistics::addSuccessList($data['raffle_name']);
$award_text = $de_raw['data']['award_text']; $award_text = $de_raw['data']['award_text'];
Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} {$data['raffle_name']}: {$award_text}"); Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} {$data['raffle_name']}: $award_text");
// 收益 // 收益
Statistics::addProfitList($data['raffle_name'] . '-' . explode('X', $award_text)[0], $de_raw['data']['award_num']); Statistics::addProfitList($data['raffle_name'] . '-' . explode('X', $award_text)[0], $de_raw['data']['award_num']);
} elseif (isset($de_raw['msg']) && $de_raw['code'] == -403 && $de_raw['msg'] == '访问被拒绝') { } elseif (isset($de_raw['msg']) && $de_raw['code'] == -403 && $de_raw['msg'] == '访问被拒绝') {

View File

@ -0,0 +1,81 @@
<?php
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2021 ~ 2022
*/
namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Util\BaseRaffle;
class RedPocketRaffle extends BaseRaffle
{
const ACTIVE_TITLE = '利是包';
const ACTIVE_SWITCH = 'live_red_pocket';
protected static array $wait_list = [];
protected static array $finish_list = [];
protected static array $all_list = [];
/**
* @use 解析数据
* @param int $room_id
* @param array $data
* @return bool
*/
protected static function parseLotteryInfo(int $room_id, array $data): bool
{
return true;
}
/**
* @use 创建抽奖任务
* @param array $raffles
* @return array
*/
protected static function createLottery(array $raffles): array
{
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/popularityRedPocket/RedPocketDraw';
$tasks = [];
foreach ($raffles as $raffle) {
$payload = [
'ruid' => $raffle['ruid'],
'room_id' => $raffle['room_id'],
'lot_id' => $raffle['lot_id'],
'spm_id' => '444.8.red_envelope.extract',
'jump_from' => '',
'session_id' => '',
'csrf_token' => getCsrf(),
'csrf' => getCsrf(),
'visit_id' => ''
];
// {"code":0,"message":"0","ttl":1,"data":{"join_status":1}}
$tasks[] = [
'payload' => Sign::common($payload),
'source' => [
'room_id' => $raffle['room_id'],
'raffle_id' => $raffle['raffle_id'],
'raffle_name' => $raffle['raffle_name']
]
];
}
// print_r($results);
return Curl::async('app', $url, $tasks);
}
/**
* @use 解析抽奖信息
* @param array $results
* @return mixed
*/
protected static function parseLottery(array $results): mixed
{
return '';
}
}

View File

@ -46,7 +46,7 @@ class Schedule
} }
self::isSleep(); self::isSleep();
self::isSpecialPause(); self::isSpecialPause();
self::setLock(1 * 60); self::setLock(60);
} }
/** /**

View File

@ -217,7 +217,7 @@ class Statistics
'参与' => self::getResults(self::$join_list, $key) . '/' . self::getResult(self::$join_list, $key), '参与' => self::getResults(self::$join_list, $key) . '/' . self::getResult(self::$join_list, $key),
'成功' => self::getResults(self::$success_list, $key) . '/' . self::getResult(self::$success_list, $key), '成功' => self::getResults(self::$success_list, $key) . '/' . self::getResult(self::$success_list, $key),
]; ];
array_push($tr_list_count, $td); $tr_list_count[] = $td;
} }
} }
// 收益数量 // 收益数量
@ -229,7 +229,7 @@ class Statistics
'奖品' => explode('-', $key)[1], '奖品' => explode('-', $key)[1],
'更新时间' => self::timeTran(self::getResult(self::$profit_list, $key, 'updated_time')), '更新时间' => self::timeTran(self::getResult(self::$profit_list, $key, 'updated_time')),
]; ];
array_push($tr_list_profit, $td); $tr_list_profit[] = $td;
} }
} }
return [self::unique_arr($tr_list_count), self::unique_arr($tr_list_profit)]; return [self::unique_arr($tr_list_count), self::unique_arr($tr_list_profit)];
@ -257,7 +257,7 @@ class Statistics
$renderer = new ArrayToTextTable($data); $renderer = new ArrayToTextTable($data);
foreach (explode("\n", $renderer->getTable()) as $value) { foreach (explode("\n", $renderer->getTable()) as $value) {
if ($value) { if ($value) {
array_push($th_list, $value); $th_list[] = $value;
} }
} }
} }

View File

@ -63,7 +63,7 @@ class StormRaffle extends BaseRaffle
'wait' => time() 'wait' => time()
]; ];
Statistics::addPushList($data['raffle_name']); Statistics::addPushList($data['raffle_name']);
array_push(self::$wait_list, $data); self::$wait_list[] = $data;
return true; return true;
} }

View File

@ -135,7 +135,7 @@ class User
$de_raw = json_decode($raw, true); $de_raw = json_decode($raw, true);
if ($de_raw['code'] == 0 && isset($de_raw['data']['list'])) { if ($de_raw['code'] == 0 && isset($de_raw['data']['list'])) {
foreach ($de_raw['data']['list'] as $user) { foreach ($de_raw['data']['list'] as $user) {
array_push($followings, $user['mid']); $followings[] = $user['mid'];
} }
if (count($followings) == $de_raw['data']['total']) { if (count($followings) == $de_raw['data']['total']) {
break; break;
@ -173,7 +173,7 @@ class User
$de_raw = json_decode($raw, true); $de_raw = json_decode($raw, true);
if ($de_raw['code'] == 0 && isset($de_raw['data'])) { if ($de_raw['code'] == 0 && isset($de_raw['data'])) {
foreach ($de_raw['data'] as $user) { foreach ($de_raw['data'] as $user) {
array_push($followings, $user['mid']); $followings[] = $user['mid'];
} }
if (count($de_raw['data']) != $page_size || empty($de_raw['data'])) { if (count($de_raw['data']) != $page_size || empty($de_raw['data'])) {
break; break;

View File

@ -89,7 +89,7 @@ class ZoneTcpClient
{ {
Log::debug("Reconnect Reason: {$area_data['area_id']} -> $reason"); Log::debug("Reconnect Reason: {$area_data['area_id']} -> $reason");
self::$client_maps["server" . $area_data['area_id']]['status'] = false; self::$client_maps["server" . $area_data['area_id']]['status'] = false;
array_push(self::$trigger_restart, $area_data); self::$trigger_restart[] = $area_data;
} }
/** /**
@ -104,7 +104,7 @@ class ZoneTcpClient
break; break;
} }
if (time() < $area_data['wait_time']) { if (time() < $area_data['wait_time']) {
array_push(self::$trigger_restart, $area_data); self::$trigger_restart[] = $area_data;
continue; continue;
} }
Log::notice("update_connections triggered, info: {$area_data['area_id']}"); Log::notice("update_connections triggered, info: {$area_data['area_id']}");
@ -193,6 +193,20 @@ class ZoneTcpClient
$data = []; $data = [];
$update_room = false; $update_room = false;
switch ($de_raw['cmd']) { switch ($de_raw['cmd']) {
case 'POPULARITY_RED_POCKET_WINNER_LIST':
// winner_info[] -> busers[] -> uid
Log::debug(json_encode($de_raw, true));
break;
case 'POPULARITY_RED_POCKET_START':
Log::debug(json_encode($de_raw, true));
$data = [
'room_id' => self::$room_id,
'raffle_id' => $de_raw['lot_id'],
'raffle_title' => '利是包',
'raffle_type' => 'red_pocket',
'source' => $msg
];
break;
case 'TV_START': case 'TV_START':
// 小电视飞船(1) // 小电视飞船(1)
$data = [ $data = [
@ -354,7 +368,7 @@ class ZoneTcpClient
self::$raffle_list[$data['raffle_type']] = []; self::$raffle_list[$data['raffle_type']] = [];
} }
$data['area_id'] = self::$area_id; $data['area_id'] = self::$area_id;
array_push(self::$raffle_list[$data['raffle_type']], $data); self::$raffle_list[$data['raffle_type']][] = $data;
Log::info("监测到 @分区 {$data['area_id']} @房间 {$data['room_id']} @抽奖 {$data['raffle_title']}"); Log::info("监测到 @分区 {$data['area_id']} @房间 {$data['room_id']} @抽奖 {$data['raffle_title']}");
// print_r($data); // print_r($data);
} }
@ -607,7 +621,7 @@ class ZoneTcpClient
$length = $head['packlen'] ?? 16; $length = $head['packlen'] ?? 16;
$body = substr($data, $step + 16, $length - 16); $body = substr($data, $step + 16, $length - 16);
$step += $length; $step += $length;
array_push($list, $body); $list[] = $body;
} }
return $list; return $list;
} }

View File

@ -24,8 +24,8 @@ class Faker
*/ */
public static function numberBetween(int $int1 = 0, int $int2 = 2147483647): int public static function numberBetween(int $int1 = 0, int $int2 = 2147483647): int
{ {
$min = $int1 < $int2 ? $int1 : $int2; $min = min($int1, $int2);
$max = $int1 < $int2 ? $int2 : $int1; $max = max($int1, $int2);
return mt_rand($min, $max); return mt_rand($min, $max);
} }

View File

@ -268,7 +268,7 @@ class File
if (is_file($filename) && is_writeable($filename)) { if (is_file($filename) && is_writeable($filename)) {
// 创建文件句柄, 以读写方式打开 // 创建文件句柄, 以读写方式打开
$handler = fopen($filename, 'rb+'); $handler = fopen($filename, 'rb+');
$length = $length < 0 ? 0 : $length; $length = max($length, 0);
ftruncate($handler, $length); ftruncate($handler, $length);
fclose($handler); fclose($handler);
} }

View File

@ -65,14 +65,14 @@ abstract class BaseRaffle
break; break;
} }
if ($raffle['wait'] > time()) { if ($raffle['wait'] > time()) {
array_push(static::$wait_list, $raffle); static::$wait_list[] = $raffle;
break; break;
} }
if (count($raffle_list) > 200) { if (count($raffle_list) > 200) {
break; break;
} }
array_push($room_list, $raffle['room_id']); $room_list[] = $raffle['room_id'];
array_push($raffle_list, $raffle); $raffle_list[] = $raffle;
// 有备注要单独处理 // 有备注要单独处理
if (isset($raffle['remarks'])) { if (isset($raffle['remarks'])) {
Statistics::addJoinList($raffle['remarks']); Statistics::addJoinList($raffle['remarks']);
@ -171,7 +171,7 @@ abstract class BaseRaffle
static::$all_list = array_values(array_splice(static::$all_list, 2000, 2000)); static::$all_list = array_values(array_splice(static::$all_list, 2000, 2000));
} }
if ($filter) { if ($filter) {
array_push(static::$all_list, $lid); static::$all_list[] = $lid;
} }
return false; return false;
} }
@ -202,7 +202,7 @@ abstract class BaseRaffle
} }
$banned_status = Live::fishingDetection($current_rid); $banned_status = Live::fishingDetection($current_rid);
if ($banned_status) { if ($banned_status) {
array_push(static::$banned_rids, $current_rid); static::$banned_rids[] = $current_rid;
return false; return false;
} }
// 实际检测 // 实际检测