From e6aab0504c8f08ef5fd3b99f44ca5d9040ada7c4 Mon Sep 17 00:00:00 2001
From: Lkeme <19500576+lkeme@users.noreply.github.com>
Date: Tue, 18 May 2021 16:35:03 +0800
Subject: [PATCH] [update] Version 0.9.1
---
CHANGELOG.md | 25 ++++++++++
DOC.md | 9 ++--
README.md | 88 ++++++++++++++++++----------------
conf/user.ini.example | 2 +-
data/activity_infos.json | 45 -----------------
data/latest_version.json | 4 +-
src/plugin/ActivityLottery.php | 30 ++++++++++--
src/plugin/Barrage.php | 1 +
src/plugin/CapsuleLottery.php | 29 +++++++++--
src/plugin/DoubleHeart.php | 8 ++--
src/plugin/Judge.php | 29 +++++++----
src/plugin/PolishTheMedal.php | 7 ++-
src/plugin/Silver2Coin.php | 47 +++++++++++-------
src/plugin/StormRaffle.php | 4 +-
src/plugin/User.php | 20 ++++++++
src/tool/Generator.php | 7 ++-
src/util/TimeLock.php | 14 +++---
src/util/XliveHeartBeat.php | 5 +-
18 files changed, 228 insertions(+), 146 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8b9aa3c..cefe7be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,31 @@
# 本项目Log
+## v0.9.1.210518 alpha (2021-05-18)
+
+### Added
+
+-
+
+### Changed
+
+- 删除过期活动
+- 更新风纪委员
+- 更新银瓜子兑换硬币
+- 更新点亮勋章
+- 更新部分日志打印输出
+-
+
+### Fixed
+
+- 修复已知BUG
+-
+
+### Remarks
+
+-
+-
+
## v0.9.0.210517 alpha (2021-05-17)
### Added
diff --git a/DOC.md b/DOC.md
index b0cf7eb..41949ca 100644
--- a/DOC.md
+++ b/DOC.md
@@ -1,5 +1,7 @@
## 环境依赖
+通常使用 `composer` 工具会自动检测以下依赖问题。
+
|Requirement |
|--------------------|
|PHP >=7.3 |
@@ -10,8 +12,6 @@
|php_zlib |
|php_mbstring |
-> 通常使用 `composer` 工具会自动检测上述依赖问题。
-
## Composer
+ [Composer 安装与使用](https://www.runoob.com/w3cnote/composer-install-and-usage.html)
@@ -102,9 +102,12 @@ $ cp user.ini.example user.ini
```
$ composer install
-$ composer dump-autoload
```
+[comment]: <> (composer dump-autoload (-o))
+
+[comment]: <> (composer dumpautoload (-o))
+
3. 按照说明修改配置文件 `user.ini`
```
diff --git a/README.md b/README.md
index 0afab8f..3478eef 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
-
+
@@ -28,53 +28,53 @@
## 功能组件
-> 以下任务都是按设定周期自动执行,`true`为正常使用,`false`为暂停使用或抛弃。
+以下任务都是按设定周期自动执行,`true`为正常使用,`false`为暂停使用或抛弃。
| plugin | status | version | description |
|-----------------|--------|----------|---------------------------------------------|
-| CheckUpdate | true | 21.05.17 | 程序检查更新 |
-| Login | true | 21.05.17 | 账号登录、刷新、维持 |
-| Schedule | true | 21.05.17 | 控制插件运行周期 |
-| MainSite | true | 21.05.17 | 投币、观看、分享视频 (速升6级不是梦) |
-| DailyBag | true | 21.05.17 | 双端领取日常/周常礼包 |
-| ManGa | true | 21.05.17 | 漫画签到、分享 |
-| ActivityLottery | true | 21.05.17 | 主站活动九宫格抽奖 |
-| Competition | true | 21.05.17 | 游戏赛事竞猜 |
-| DoubleHeart | true | 21.05.17 | 双端心跳 (姥爷直播经验) |
-| DailyTask | true | 21.05.17 | 直播每日任务(签到、观看) |
-| Barrage | true | 21.05.17 | 保持活跃弹幕 |
-| Silver2Coin | true | 21.05.17 | 银瓜子兑换硬币 |
-| Judge | true | 21.05.17 | 风纪委员投票 |
-| GiftSend | true | 21.05.17 | 礼物赠送、维持每日勋章亲密度 |
-| GroupSignIn | true | 21.05.17 | 友爱社签到 |
-| GiftHeart | true | 21.05.17 | 日常心跳每日礼包礼物 |
-| SmallHeart | true | 21.05.17 | 直播挂机,每日24个小心心 |
-| MaterialObject | true | 21.05.17 | 直播金色宝箱实物抽奖 |
-| AloneTcpClient | true | 21.05.17 | 作者的独立直播监控 |
-| ZoneTcpClient | true | 21.05.17 | 官方的分区直播监控 |
-| StormRaffle | true | 21.05.17 | 直播节奏风暴抽奖、亿元 |
-| GiftRaffle | true | 21.05.17 | 直播礼物抽奖 |
-| PkRaffle | true | 21.05.17 | 直播大乱斗抽奖 |
-| GuardRaffle | true | 21.05.17 | 直播大航海抽奖 |
-| AnchorRaffle | true | 21.05.17 | 直播天选时刻抽奖 |
-| GiftRaffle | true | 21.05.17 | 直播礼物抽奖 |
-| AwardRecord | true | 21.05.17 | 最新的中奖纪录通知 |
-| Forward | true | 21.05.17 | 主站动态抽奖转发 |
-| CapsuleLottery | true | 21.05.17 | 直播扭蛋活动抽奖 |
-| PolishTheMedal | true | 21.05.17 | 每日自动点亮灰色勋章 |
-| CapsuleLottery | true | 21.05.17 | 直播扭蛋活动抽奖 |
-| VipPrivilege | true | 21.05.17 | 每月领取年度大会员特权(B币券、会员购优惠券) |
-| BpConsumption | true | 21.05.17 | 每月消费使用年度大会员特权的B币券 |
-| Statistics | true | 21.05.17 | 全局抽奖结果统计 |
+| CheckUpdate | true | 21.05.18 | 程序检查更新 |
+| Login | true | 21.05.18 | 账号登录、刷新、维持 |
+| Schedule | true | 21.05.18 | 控制插件运行周期 |
+| MainSite | true | 21.05.18 | 投币、观看、分享视频 (速升6级不是梦) |
+| DailyBag | true | 21.05.18 | 双端领取日常/周常礼包 |
+| ManGa | true | 21.05.18 | 漫画签到、分享 |
+| ActivityLottery | true | 21.05.18 | 主站活动九宫格抽奖 |
+| Competition | true | 21.05.18 | 游戏赛事竞猜 |
+| DoubleHeart | true | 21.05.18 | 双端心跳 (姥爷直播经验) |
+| DailyTask | true | 21.05.18 | 直播每日任务(签到、观看) |
+| Barrage | true | 21.05.18 | 保持活跃弹幕 |
+| Silver2Coin | true | 21.05.18 | 银瓜子兑换硬币 |
+| Judge | true | 21.05.18 | 风纪委员投票 |
+| GiftSend | true | 21.05.18 | 礼物赠送、维持每日勋章亲密度 |
+| GroupSignIn | true | 21.05.18 | 友爱社签到 |
+| GiftHeart | true | 21.05.18 | 日常心跳每日礼包礼物 |
+| SmallHeart | true | 21.05.18 | 直播挂机,每日24个小心心 |
+| MaterialObject | true | 21.05.18 | 直播金色宝箱实物抽奖 |
+| AloneTcpClient | true | 21.05.18 | 作者的独立直播监控 |
+| ZoneTcpClient | true | 21.05.18 | 官方的分区直播监控 |
+| StormRaffle | true | 21.05.18 | 直播节奏风暴抽奖、亿元 |
+| GiftRaffle | true | 21.05.18 | 直播礼物抽奖 |
+| PkRaffle | true | 21.05.18 | 直播大乱斗抽奖 |
+| GuardRaffle | true | 21.05.18 | 直播大航海抽奖 |
+| AnchorRaffle | true | 21.05.18 | 直播天选时刻抽奖 |
+| GiftRaffle | true | 21.05.18 | 直播礼物抽奖 |
+| AwardRecord | true | 21.05.18 | 最新的中奖纪录通知 |
+| Forward | true | 21.05.18 | 主站动态抽奖转发 |
+| CapsuleLottery | true | 21.05.18 | 直播扭蛋活动抽奖 |
+| PolishTheMedal | true | 21.05.18 | 每日自动点亮灰色勋章 |
+| CapsuleLottery | true | 21.05.18 | 直播扭蛋活动抽奖 |
+| VipPrivilege | true | 21.05.18 | 每月领取年度大会员特权(B币券、会员购优惠券) |
+| BpConsumption | true | 21.05.18 | 每月消费使用年度大会员特权的B币券 |
+| Statistics | true | 21.05.18 | 全局抽奖结果统计 |
| Silver | false | 21.03.27 | 直播银瓜子自动开启宝箱 |
## 交流反馈
-> Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **请不要来问如何使用, 文档齐全, 仅用于BUG提交反馈**
+Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **请不要来问如何使用, 文档齐全, 仅用于BUG提交反馈**
## 相关文档
-> 有疑问一定要先看看文档或Issue里是否存在相同的问题,再考虑其他渠道咨询。
+有疑问一定要先看看文档或Issue里是否存在相同的问题,再考虑其他渠道咨询。
* [使用文档 / DOC.md](./DOC.md)
* [更新日志 / CHANGELOG.md](./CHANGELOG.md)
@@ -83,15 +83,19 @@
## 打赏支持
-> 如果觉得本项目好用,对你有所帮助,欢迎打赏支持。
+如果觉得本项目好用,对你有所帮助,欢迎打赏支持本项目哦。
-
+

+
+[comment]: <> ()
## 运行效果
-> 不代表当前版本,以当前最新版本运行结果为准
+效果图不代表当前版本,请以当前最新版本运行结果为准。
-
+
+
+[comment]: <> ()
## 项目相关
diff --git a/conf/user.ini.example b/conf/user.ini.example
index 93699b3..a49eee1 100644
--- a/conf/user.ini.example
+++ b/conf/user.ini.example
@@ -95,7 +95,7 @@ enable = false
[live_storm]
enable = false
drop_rate = 0
-attempt = "10,20"
+attempt = "5,10"
; 直播天选时刻|抽取类型(0: 无限制; 1: 关注主播; 2: 粉丝勋章; 3大航海; 4用户等级;5主站等级)|自动取关(测试功能)|过滤关键词|逗号分隔
[live_anchor]
diff --git a/data/activity_infos.json b/data/activity_infos.json
index 61dcc47..9b768d8 100644
--- a/data/activity_infos.json
+++ b/data/activity_infos.json
@@ -32,40 +32,6 @@
"draw_times": 1,
"expire_at": "2021-07-15 11:59:59"
},
- {
- "url": "https://www.bilibili.com/blackboard/activity-nA2uYrmpfA.html",
- "title": "哥斯拉金刚你站谁",
- "description": "活动期间每天分享页面,新增一次机会。",
- "sid": "f851e27a-858e-11eb-8597-246e966235d8",
- "login": "true",
- "follow": "false",
- "share": "true",
- "draw_times": 2,
- "expire_at": "2021-05-23 11:59:59"
- },
- {
- "url": "https://www.bilibili.com/blackboard/activity-QEya2bouhQ.html",
- "title": "春日嗑糖大作战",
- "description": "活动期间每天分享页面,新增一次机会。",
- "sid": "20b0dfaf-8bcd-11eb-8597-246e966235d8",
- "login": "true",
- "follow": "false",
- "share": "true",
- "draw_times": 2,
- "expire_at": "2021-05-05 23:59:59"
- },
- {
- "url": "https://www.bilibili.com/blackboard/gaming_on_bilibili.html",
- "title": "上B站看电竞",
- "description": "活动期间每天分享页面,新增一次机会。",
- "sid": "0b87bd83-8565-11eb-8597-246e966235d8",
- "login": "true",
- "follow": "false",
- "share": "true",
- "draw_times": 1,
- "expire_at": "2021-05-30 23:59:59",
- "remarks": "时间不名,暂定一个月。"
- },
{
"url": "https://www.bilibili.com/blackboard/activity-aT7zphkwF1.html",
"title": "初夏逛吃大会",
@@ -77,17 +43,6 @@
"draw_times": 1,
"expire_at": "2021-06-10 23:59:59"
},
- {
- "url": "https://www.bilibili.com/blackboard/activity-oGiWFe0YTz.html",
- "title": "京东超市超有young",
- "description": "活动期间每天分享页面,新增一次机会。",
- "sid": "4eb728e2-a0d7-11eb-8597-246e966235d8",
- "login": "true",
- "follow": "false",
- "share": "true",
- "draw_times": 1,
- "expire_at": "2021-04-25 23:59:59"
- },
{
"url": "https://www.bilibili.com/blackboard/activity-Tpo81ydpiW.html",
"title": "和平精英周年庆嘉年华1次",
diff --git a/data/latest_version.json b/data/latest_version.json
index f530fa9..b9b2257 100644
--- a/data/latest_version.json
+++ b/data/latest_version.json
@@ -4,7 +4,7 @@
"branch": "master",
"source": "https://github.com/lkeme/BiliHelper-personal",
"raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json",
- "version": "0.9.0.210517",
+ "version": "0.9.1.210518",
"des": "程序有更新,请及时线上查看更新哦~",
- "time": "2021年5月17日17:44:47"
+ "time": "2021年5月18日16:29:44"
}
\ No newline at end of file
diff --git a/src/plugin/ActivityLottery.php b/src/plugin/ActivityLottery.php
index fd963fe..4358f25 100644
--- a/src/plugin/ActivityLottery.php
+++ b/src/plugin/ActivityLottery.php
@@ -115,7 +115,10 @@ class ActivityLottery
self::addTimes($task['act']->sid, $task['act']->url, 3);
break;
case 'draw':
- self::doLottery($task['act']->sid, $task['act']->url, 0);
+ // 有抽奖机会才抽奖
+ if (self::initTimes($task['act']->sid, $task['act']->url, false)) {
+ self::doLottery($task['act']->sid, $task['act']->url, 0);
+ }
break;
default:
Log::info("当前 {$task['act']->title} #{$task['operation']} 任务不存在哦");
@@ -128,9 +131,10 @@ class ActivityLottery
* @use 获取抽奖机会
* @param string $sid
* @param string $referer
+ * @param bool $init
* @return bool
*/
- private static function initTimes(string $sid, string $referer): bool
+ private static function initTimes(string $sid, string $referer, bool $init = true): bool
{
$url = 'https://api.bilibili.com/x/activity/lottery/mytimes';
$headers = [
@@ -143,12 +147,25 @@ class ActivityLottery
$raw = Curl::get('pc', $url, $payload, $headers);
$de_raw = json_decode($raw, true);
// {"code":0,"message":"0","ttl":1,"data":{"times":2}}
+ // {"code":0,"message":"0","ttl":1,"data":{"times":3}}
+ if ($init) {
+ if ($de_raw['code'] == 0) {
+ Log::notice("剩余抽奖次数 {$de_raw['data']['times']}");
+ return true;
+ }
+ Log::warning("获取抽奖次数失败 {$raw}");
+ return false;
+ }
if ($de_raw['code'] == 0) {
- Log::notice("获取抽奖机会成功 {$raw}");
+ Log::notice("剩余抽奖次数 {$de_raw['data']['times']}");
+ if ($de_raw['data']['times'] <= 0) {
+ return false;
+ }
return true;
}
- Log::warning("获取抽奖机会失败 {$raw}");
+ Log::warning("获取抽奖次数失败 {$raw}");
return false;
+
}
/**
@@ -172,9 +189,12 @@ class ActivityLottery
'csrf' => getCsrf()
];
$raw = Curl::post('pc', $url, $payload, $headers);
+ // {"code":75405,"message":"抽奖机会用尽啦","ttl":1}
+ // {"code":75003,"message":"活动已结束","ttl":1}
+ // {"code":0,"message":"0","ttl":1}
$de_raw = json_decode($raw, true);
Log::notice("增加抽奖机会#{$action_type} {$raw}");
- // {"code":0,"message":"0","ttl":1}
+
if ($de_raw['code'] == 0) {
return true;
}
diff --git a/src/plugin/Barrage.php b/src/plugin/Barrage.php
index b1462dd..e672bcf 100644
--- a/src/plugin/Barrage.php
+++ b/src/plugin/Barrage.php
@@ -86,6 +86,7 @@ class Barrage
$response = Live::sendBarragePC($room_id, $content);
// {"code":0,"data":[],"message":"","msg":""}
// {"code":0,"message":"你被禁言啦","msg":"你被禁言啦"}
+ // TODO 长度限制
if (isset($response['code']) && $response['code'] == 0 && isset($response['data'])) {
Log::notice("在直播间@{$room_id} 发送活跃弹幕成功 CODE -> {$response['code']}");
return true;
diff --git a/src/plugin/CapsuleLottery.php b/src/plugin/CapsuleLottery.php
index 5d86739..1e83513 100644
--- a/src/plugin/CapsuleLottery.php
+++ b/src/plugin/CapsuleLottery.php
@@ -108,12 +108,16 @@ class CapsuleLottery
Log::info("执行 {$task['act']->title} #{$task['operation']} 任务");
// 执行任务
switch ($task['operation']) {
+ // TODO 观看 分享 签到任务
case 'watch':
$interval = self::xliveHeartBeatTask($task['act']->room_id, 999, 999);
self::$interval = $interval == 0 ? 60 : $interval;
break;
case 'draw':
- self::doLottery($task['act']->coin_id, $task['act']->url, 0);
+ // 抽奖次数 > 0 开始抽奖
+ if (self::getLuckyNum($task['act']->coin_id, $task['act']->url)) {
+ self::doLottery($task['act']->coin_id, $task['act']->url, 0);
+ }
break;
default:
Log::info("当前 {$task['act']->title} #{$task['operation']} 任务不存在哦");
@@ -208,8 +212,9 @@ class CapsuleLottery
* @use 获取扭蛋信息
* @param int $coin_id
* @param string $referer
+ * @return array
*/
- private static function getCapsuleInfo(int $coin_id, string $referer)
+ private static function getCapsuleInfo(int $coin_id, string $referer): array
{
$url = 'https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/get_capsule_info_v3';
$headers = [
@@ -224,9 +229,27 @@ class CapsuleLottery
$raw = Curl::get('pc', $url, $payload, $headers);
// data -> status 0||2
// {"code":0,"message":"0","ttl":1,"data":{"coin":9,"rule":"2020年英雄联盟职业联赛春季赛抽奖奖池","gift_list":[{"name":"辣条","num":1,"web_url":"https://i0.hdslb.com/bfs/live/48605b0fe9eca5aba87f93da0fa0aa361c419835.png","mobile_url":"https://i0.hdslb.com/bfs/live/8e7a4dc8de374faee22fca7f9a3f801a1712a36b.png","usage":{"text":"辣条是一种直播虚拟礼物,可以在直播间送给自己喜爱的主播哦~","url":""},"type":1,"expire":"3天","gift_type":"325a347f91903c0353385e343dd358f0"},{"name":"3天头衔续期卡","num":1,"web_url":"https://i0.hdslb.com/bfs/live/48aecec2d7243b6f8bd17f20ff715db89f9adcec.png","mobile_url":"https://i0.hdslb.com/bfs/live/48aecec2d7243b6f8bd17f20ff715db89f9adcec.png","usage":{"text":"3天头衔续期卡*1","url":""},"type":21,"expire":"1周","gift_type":"4bda2f960342d86a426ebc067d3633ed"},{"name":"LPL2020助威","num":1,"web_url":"https://i0.hdslb.com/bfs/live/d9ee9558fcc438c99deb00ed1f6bd3707bac3452.png","mobile_url":"https://i0.hdslb.com/bfs/live/d9ee9558fcc438c99deb00ed1f6bd3707bac3452.png","usage":{"text":"2020LPL限定头衔","url":""},"type":2,"expire":"1周","gift_type":"b114c47920fce2aca5fca7a27cca5915"},{"name":"随机英雄联盟角色手办","num":1,"web_url":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","mobile_url":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","usage":{"text":"随机英雄联盟角色手办*1","url":""},"type":100024,"expire":"当天","gift_type":"6a4ae5853753d67d07cea2b1750795f4"},{"name":"2020LPL彩色弹幕","num":1,"web_url":"https://i0.hdslb.com/bfs/live/9a571f9d82c2a8cbbe869fd92796e70b19f9c2cc.png","mobile_url":"https://i0.hdslb.com/bfs/live/9a571f9d82c2a8cbbe869fd92796e70b19f9c2cc.png","usage":{"text":"LPL专属彩色弹幕","url":""},"type":20,"expire":"3天","gift_type":"14e40c6949800b5d840011e47e54d0c5"},{"name":"7天头衔续期卡","num":1,"web_url":"https://i0.hdslb.com/bfs/live/a2ffb62dc90d4896ddc3d1dcdbe83ac5d1dd7328.png","mobile_url":"https://i0.hdslb.com/bfs/live/a2ffb62dc90d4896ddc3d1dcdbe83ac5d1dd7328.png","usage":{"text":"7天头衔续期卡*1","url":""},"type":21,"expire":"1周","gift_type":"bbfc114b65126486a40c81daedd911e5"},{"name":"2020LPL春季赛助威券","num":1,"web_url":"https://i0.hdslb.com/bfs/live/be4cdecc4809caf8aa21817880a3283672b5a477.png","mobile_url":"https://i0.hdslb.com/bfs/live/be4cdecc4809caf8aa21817880a3283672b5a477.png","usage":{"text":"再来一次!(✪ω✪)","url":""},"type":22,"expire":"当天","gift_type":"96d2b8187ec6564fa40733153a41ac14"},{"name":"30天头衔续期卡","num":1,"web_url":"https://i0.hdslb.com/bfs/live/fc49e08115db6edd0276fba69ed8835a64714441.png","mobile_url":"https://i0.hdslb.com/bfs/live/fc49e08115db6edd0276fba69ed8835a64714441.png","usage":{"text":"30天头衔续期卡*1","url":""},"type":21,"expire":"1周","gift_type":"02810fd04244c47952bd4ed0b35617db"},{"name":"辣条","num":233,"web_url":"https://i0.hdslb.com/bfs/live/48605b0fe9eca5aba87f93da0fa0aa361c419835.png","mobile_url":"https://i0.hdslb.com/bfs/live/8e7a4dc8de374faee22fca7f9a3f801a1712a36b.png","usage":{"text":"辣条是一种直播虚拟礼物,可以在直播间送给自己喜爱的主播哦~","url":""},"type":1,"expire":"3天","gift_type":"a6d260760dfb1fe9f5375b3c8c7bd7ad"},{"name":"随机提伯斯熊毛绒公仔","num":1,"web_url":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","mobile_url":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","usage":{"text":"提伯斯熊毛绒公仔*1","url":""},"type":100024,"expire":"当天","gift_type":"2df71ff3306a4a2b4a627889cbd63c5b"}],"change_num":10000,"status":0,"is_login":true,"user_score":90000,"list":[{"num":1,"gift":"随机英雄联盟角色手办","date":"2020-04-23","name":"nXBo7p0svjm","web_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","mobile_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","count":1},{"num":1,"gift":"随机提伯斯熊毛绒公仔","date":"2020-04-20","name":"z98rwt","web_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","mobile_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","count":1},{"num":1,"gift":"随机英雄联盟角色手办","date":"2020-04-18","name":"wBQW6Z6jgbb","web_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","mobile_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","count":1},{"num":1,"gift":"随机提伯斯熊毛绒公仔","date":"2020-04-13","name":"dU9449p1zkz","web_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","mobile_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","count":1},{"num":1,"gift":"随机英雄联盟角色手办","date":"2020-04-10","name":"ckcs8151","web_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","mobile_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","count":1},{"num":1,"gift":"随机提伯斯熊毛绒公仔","date":"2020-04-06","name":"l1d9fgn1gl","web_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","mobile_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","count":1},{"num":1,"gift":"随机提伯斯熊毛绒公仔","date":"2020-03-31","name":"rlBF7ivbffe","web_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","mobile_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","count":1},{"num":1,"gift":"随机英雄联盟角色手办","date":"2020-03-29","name":"卟要悔","web_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","mobile_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","count":1},{"num":1,"gift":"随机提伯斯熊毛绒公仔","date":"2020-03-23","name":"就这样8丶","web_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","mobile_image":"https://i0.hdslb.com/bfs/live/61414ab727c55cd1de8fb5c1c79a5a05dada3a55.png","count":1},{"num":1,"gift":"随机英雄联盟角色手办","date":"2020-03-17","name":"bIud77Vsory","web_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","mobile_image":"https://i0.hdslb.com/bfs/live/4a2f604ef7b3dad583c054d4ffdb30e37f37ad9c.png","count":1}]}}
- $de_raw = json_decode($raw, true);
+ return json_decode($raw, true);
}
+ /**
+ * @获取剩余抽奖次数
+ * @param int $coin_id
+ * @param string $referer
+ * @return int
+ */
+ private static function getLuckyNum(int $coin_id, string $referer): int
+ {
+ $capsule_info = self::getCapsuleInfo($coin_id, $referer);
+ if ($capsule_info['code'] == 0) {
+ Log::info("获取剩余抽奖次数成功 {$capsule_info['data']['coin']}");
+ return $capsule_info['data']['coin'];
+ }
+ Log::warning("获取剩余抽奖次数失败 {$capsule_info}");
+ return 0;
+ }
+
+
/**
* @use 获取用户活动任务
* @param int $act_id
diff --git a/src/plugin/DoubleHeart.php b/src/plugin/DoubleHeart.php
index 5824c88..5979ca6 100644
--- a/src/plugin/DoubleHeart.php
+++ b/src/plugin/DoubleHeart.php
@@ -49,9 +49,9 @@ class DoubleHeart
$data = json_decode($data, true);
if (isset($data['code']) && $data['code']) {
- Log::warning('[PC] 发送心跳异常', ['msg' => $data['message']]);
+ Log::warning('[PC] 发送在线心跳失败', ['msg' => $data['message']]);
} else {
- Log::notice('[PC] 发送心跳正常');
+ Log::notice('[PC] 发送在线心跳成功');
}
}
@@ -69,9 +69,9 @@ class DoubleHeart
$data = json_decode($data, true);
if (isset($data['code']) && $data['code']) {
- Log::warning('[APP] 发送心跳异常', ['msg' => $data['message']]);
+ Log::warning('[APP] 发送在线心跳失败', ['msg' => $data['message']]);
} else {
- Log::notice('[APP] 发送心跳正常');
+ Log::notice('[APP] 发送在线心跳成功');
}
}
}
diff --git a/src/plugin/Judge.php b/src/plugin/Judge.php
index e77799f..efa20e0 100644
--- a/src/plugin/Judge.php
+++ b/src/plugin/Judge.php
@@ -36,7 +36,10 @@ class Judge
return;
}
// self::judgementIndex();
- self::setLock(mt_rand(15, 30) * 60);
+ // 如果没有设置时间 就设置个默认时间
+ if (self::getLock() < time()) {
+ self::setLock(mt_rand(15, 30) * 60);
+ }
}
/**
@@ -149,6 +152,7 @@ class Judge
"csrf" => getCsrf(),
];
$raw = Curl::post('pc', $url, $payload);
+ // {"code":25012,"message":"请勿重复投票","ttl":1}
$de_raw = json_decode($raw, true);
if (isset($de_raw['code']) && $de_raw['code']) {
Log::warning("案件 {$case_id} 投票失败 {$raw}");
@@ -173,14 +177,23 @@ class Judge
// {"code":25008,"message":"真给力 , 移交众裁的举报案件已经被处理完了","ttl":1}
// {"code":25014,"message":"25014","ttl":1}
// {"code":25005,"message":"请成为风纪委员后再试","ttl":1}
- if (isset($de_raw['code']) && $de_raw['code'] == 25005) {
- Log::warning($de_raw['message']);
- self::setLock(self::timing(10));
- return null;
- }
if (isset($de_raw['code']) && $de_raw['code']) {
- Log::info("没有获取到案件~ {$raw}");
- return null;
+ switch ($de_raw['code']) {
+ case 25005:
+ Log::warning($de_raw['message']);
+ self::setLock(self::timing(10));
+ return null;
+ case 25008:
+ Log::info("暂时没有新的案件需要审理~ {$raw}");
+ return null;
+ case 25014:
+ Log::info("今日案件已审满,感谢您对社区的贡献!明天再来看看吧~");
+ self::setLock(self::timing(7, 0, 0, true));
+ return null;
+ default:
+ Log::info("获取案件失败~ {$raw}");
+ return null;
+ }
} else {
$case_id = $de_raw['data']['id'];
Log::info("获取到案件 {$case_id} ~");
diff --git a/src/plugin/PolishTheMedal.php b/src/plugin/PolishTheMedal.php
index d2044fa..762de10 100644
--- a/src/plugin/PolishTheMedal.php
+++ b/src/plugin/PolishTheMedal.php
@@ -31,10 +31,10 @@ class PolishTheMedal
}
// 获取灰色勋章
if (self::$metal_lock < time()) {
- // 如果勋章过多导致未处理完,就1小时一次,否则8小时一次。
+ // 如果勋章过多导致未处理完,就1小时一次,否则10小时一次。
if (empty(self::$grey_fans_medals)) {
self::fetchGreyMedalList();
- self::$metal_lock = time() + 8 * 60 * 60;
+ self::$metal_lock = time() + 10 * 60 * 60;
} else {
self::$metal_lock = time() + 1 * 60 * 60;
}
@@ -55,6 +55,9 @@ class PolishTheMedal
$medal = array_pop(self::$grey_fans_medals);
// 为空
if (is_null($medal)) return;
+ // 特殊房间处理|央视未开播|CODE -> 11000 MSG -> ''
+ if (in_array($medal['roomid'], [21686237])) return;
+
Log::info("开始点亮直播间@{$medal['roomid']}的勋章");
// 擦亮
$response = Live::sendBarrageAPP($medal['roomid'], Generator::emoji());
diff --git a/src/plugin/Silver2Coin.php b/src/plugin/Silver2Coin.php
index 45c28a2..9158e27 100644
--- a/src/plugin/Silver2Coin.php
+++ b/src/plugin/Silver2Coin.php
@@ -24,7 +24,8 @@ class Silver2Coin
return;
}
if (self::appSilver2coin() && self::pcSilver2coin()) {
- self::setLock(self::timing(10));
+ // 定时10点 + 1-60分钟随机
+ self::setLock(self::timing(10, 0, 0, true));
return;
}
self::setLock(3600);
@@ -40,18 +41,10 @@ class Silver2Coin
$url = 'https://api.live.bilibili.com/AppExchange/silver2coin';
$payload = [];
$raw = Curl::get('app', $url, Sign::common($payload));
- // {"code":403,"msg":"仅主站正式会员以上的用户可以兑换","message":"仅主站正式会员以上的用户可以兑换","data":[]}
$de_raw = json_decode($raw, true);
- if (!$de_raw['code'] && $de_raw['msg'] == '兑换成功') {
- Log::notice('[APP] 银瓜子兑换硬币: ' . $de_raw['msg']);
- } elseif ($de_raw['code'] == 403) {
- Log::warning('[APP] 银瓜子兑换硬币: ' . $de_raw['msg']);
- } else {
- Log::warning('[APP] 银瓜子兑换硬币: ' . $de_raw['msg']);
- return false;
- }
- return true;
+ return self::handle('APP', $de_raw);
+
}
/**
@@ -64,15 +57,33 @@ class Silver2Coin
$payload = [];
$url = "https://api.live.bilibili.com/exchange/silver2coin";
$url = "https://api.live.bilibili.com/pay/v1/Exchange/silver2coin";
-
$raw = Curl::get('pc', $url, $payload);
- // {"code":403,"msg":"仅主站正式会员以上的用户可以兑换","message":"仅主站正式会员以上的用户可以兑换","data":[]}
$de_raw = json_decode($raw, true);
- if (isset($de_raw['code']) && $de_raw['code'] == 0) {
- Log::notice('[PC] 银瓜子兑换硬币: ' . $de_raw['msg']);
- return true;
+
+ return self::handle('PC', $de_raw);
+ }
+
+ /**
+ * @use 处理结果
+ * @param int $type
+ * @param array $data
+ * @return bool
+ */
+ private static function handle(int $type, array $data): bool
+ {
+ // {"code":403,"msg":"每天最多能兑换 1 个","message":"每天最多能兑换 1 个","data":[]}
+ // {"code":403,"msg":"仅主站正式会员以上的用户可以兑换","message":"仅主站正式会员以上的用户可以兑换","data":[]}
+ // {"code":0,"msg":"兑换成功","message":"兑换成功","data":{"gold":"5074","silver":"36734","tid":"727ab65376a15a6b117cf560a20a21122334","coin":1}}
+ switch ($data['code']) {
+ case 0:
+ Log::notice("[{$type}] 银瓜子兑换硬币: {$data['msg']}");
+ return true;
+ case 403:
+ Log::warning("[{$type}] 银瓜子兑换硬币: {$data['msg']}");
+ return true;
+ default:
+ Log::warning("[{$type}] 银瓜子兑换硬币: CODE -> {$data['code']} MSG -> {$data['msg']} ");
+ return false;
}
- Log::warning('[PC] 银瓜子兑换硬币: ' . $de_raw['msg']);
- return false;
}
}
\ No newline at end of file
diff --git a/src/plugin/StormRaffle.php b/src/plugin/StormRaffle.php
index 22bf884..2fa1a6b 100644
--- a/src/plugin/StormRaffle.php
+++ b/src/plugin/StormRaffle.php
@@ -76,7 +76,7 @@ class StormRaffle extends BaseRaffle
*/
private static function formatInfo($id, $num, $info): string
{
- return "风暴 {$id} 请求 {$num} 状态 {$info}";
+ return "节奏风暴 {$id} 请求 {$num} 状态 {$info}";
}
/**
@@ -88,7 +88,7 @@ class StormRaffle extends BaseRaffle
{
$url = 'https://api.live.bilibili.com/lottery/v1/Storm/join';
foreach ($raffles as $raffle) {
- self::$attempt = empty($attempt = getConf('attempt', 'live_storm')) ? [10, 20] : explode(',', $attempt);
+ self::$attempt = empty($attempt = getConf('attempt', 'live_storm')) ? [5, 10] : explode(',', $attempt);
$num = mt_rand((int)self::$attempt[0], (int)self::$attempt[1]);
$payload = [
'id' => $raffle['raffle_id'],
diff --git a/src/plugin/User.php b/src/plugin/User.php
index c6ed63c..7e19641 100644
--- a/src/plugin/User.php
+++ b/src/plugin/User.php
@@ -317,4 +317,24 @@ class User
return false;
}
+ /**
+ * @use 我的钱包
+ */
+ public static function myWallet()
+ {
+ $url = 'https://api.live.bilibili.com/pay/v2/Pay/myWallet';
+ $headers = [
+ 'origin' => 'https://link.bilibili.com',
+ 'referer' => 'https://link.bilibili.com/p/center/index'
+ ];
+ $payload = [
+ 'need_bp' => 1,
+ 'need_metal' => 1,
+ 'platform' => 'pc',
+ ];
+ $raw = Curl::get('pc', $url, $payload, $headers);
+ // {"code":0,"msg":"succ","message":"succ","data":{"gold":5074,"silver":37434,"bp":"0","metal":1904}}
+ $de_raw = json_decode($raw, true);
+ }
+
}
\ No newline at end of file
diff --git a/src/tool/Generator.php b/src/tool/Generator.php
index 15799a9..8d7414b 100644
--- a/src/tool/Generator.php
+++ b/src/tool/Generator.php
@@ -67,7 +67,7 @@ class Generator
*/
public static function emoji(): string
{
- $emoji_list = [
+ $emoji_list_all = [
"(⌒▽⌒)", "( ̄▽ ̄)", "(=・ω・=)", "(`・ω・´)", "(〜 ̄△ ̄)〜", "(・∀・)",
"(°∀°)ノ", "( ̄3 ̄)", "╮( ̄▽ ̄)╭", "_(:3」∠)_", "( ´_ゝ`)", "←_←", "→_→",
"(<_<)", "(>_>)", "(;¬_¬)", '("▔□▔)/', "(゚Д゚≡゚д゚)!?", "Σ(゚д゚;)", "Σ(  ̄□ ̄||)",
@@ -76,6 +76,11 @@ class Generator
"(╯°口°)╯(┴—┴", "←◡←", "( ♥д♥)", "Σ>―(〃°ω°〃)♡→", "⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄",
"(╬゚д゚)▄︻┻┳═一", "・*・:≡( ε:)", "(打卡)", "(签到)"
];
+ $emoji_list = [
+ "(⌒▽⌒)", "( ̄▽ ̄)", "(=・ω・=)", "(`・ω・´)", "(〜 ̄△ ̄)〜",
+ "╮( ̄▽ ̄)╭", "_(:3」∠)_", "( ´_ゝ`)", "(● ̄(エ) ̄●)", "(・∀・)",
+ "(´・_・`)", "( ̄へ ̄)", "(打卡)", "(签到)"
+ ];
shuffle($emoji_list);
return $emoji_list[array_rand($emoji_list)];
}
diff --git a/src/util/TimeLock.php b/src/util/TimeLock.php
index df8ff67..19137e5 100644
--- a/src/util/TimeLock.php
+++ b/src/util/TimeLock.php
@@ -49,19 +49,21 @@ trait TimeLock
/**
* @use 定时
- * @param int $hour
- * @param int $minute
- * @param int $seconds
+ * @param int $hour 时
+ * @param int $minute 分
+ * @param int $seconds 秒
+ * @param bool $random 随机一个小时内
* @return int
*/
- public static function timing(int $hour, int $minute = 0, int $seconds = 0): int
+ public static function timing(int $hour, int $minute = 0, int $seconds = 0, bool $random = false): int
{
$time = strtotime('today') + ($hour * 60 * 60) + ($minute * 60) + ($seconds);
if ($time > time()) {
- return strtotime('today') + ($hour * 60 * 60) + ($minute * 60) + ($seconds) - time();
+ $timing = strtotime('today') + ($hour * 60 * 60) + ($minute * 60) + ($seconds) - time();
} else {
- return strtotime('tomorrow') + ($hour * 60 * 60) + ($minute * 60) + ($seconds) - time();
+ $timing = strtotime('tomorrow') + ($hour * 60 * 60) + ($minute * 60) + ($seconds) - time();
}
+ return $random ? $timing + mt_rand(1, 60) * 60 : $timing;
}
diff --git a/src/util/XliveHeartBeat.php b/src/util/XliveHeartBeat.php
index d45476a..a44a381 100644
--- a/src/util/XliveHeartBeat.php
+++ b/src/util/XliveHeartBeat.php
@@ -13,7 +13,6 @@ namespace BiliHelper\Util;
use BiliHelper\Core\Curl;
use BiliHelper\Core\Log;
use BiliHelper\Plugin\Live;
-use BiliHelper\Plugin\User;
use BiliHelper\Tool\Generator;
trait XliveHeartBeat
@@ -41,7 +40,6 @@ trait XliveHeartBeat
'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36'
];
-
/**
* @use 任务接口
* @param int $room_id
@@ -239,7 +237,6 @@ trait XliveHeartBeat
return false;
}
-
/**
* @use 格式T
* @param array $t
@@ -273,7 +270,7 @@ trait XliveHeartBeat
* @use 重置变量
* @param false $force
*/
- protected static function resetVar($force = false)
+ protected static function resetVar(bool $force = false)
{
if ($force) {
static::$_room_info = [];