From c1481438c978114d7d03f31a685d5bbdbfc0f6d7 Mon Sep 17 00:00:00 2001
From: lkeme <1462364497@qq.com>
Date: Sun, 26 Apr 2020 20:07:31 +0800
Subject: [PATCH] [add] Match
---
CHANGELOG.md | 13 ++
DOC.md | 51 +++---
README.md | 4 +-
composer.lock | 285 +++++++++++++++++++++++++++++---
conf/user.conf.example | 3 +
src/core/App.php | 1 +
src/core/Env.php | 2 +-
src/plugin/Live.php | 30 ++++
src/plugin/Match.php | 356 ++++++++++++++++++++++++++++++++++++++++
src/plugin/Schedule.php | 2 +-
10 files changed, 695 insertions(+), 52 deletions(-)
create mode 100644 src/plugin/Match.php
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b44aa61..d45abb2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,19 @@
# Release Notes
# 本项目Log
+## v0.4.0.200426 alpha (2020-04-26)
+
+### Added
+- 赛事助手 (签到、分享)
+-
+
+### Changed
+-
+
+### Fixed
+- 修复休眠机制
+-
+
## v0.3.0.200425 alpha (2020-04-25)
### Added
diff --git a/DOC.md b/DOC.md
index 6809935..c2c6b34 100644
--- a/DOC.md
+++ b/DOC.md
@@ -2,7 +2,7 @@

-
+
@@ -15,30 +15,31 @@ B 站直播实用脚本
|plugin |version |description |
|--------------------|--------------------|--------------------|
-|Login |20.04.19 |账号登录 |
-|Schedule |20.04.19 |休眠控制 |
-|MasterSite |20.04.19 |主站助手 |
-|Daily |20.04.19 |每日礼包 |
-|Heart |20.04.19 |双端心跳 |
-|Task |20.04.19 |每日任务 |
-|Silver |20.04.19 |银瓜子宝箱 |
-|Barrage |20.04.19 |活跃弹幕 |
-|Silver2Coin |20.04.19 |银瓜子换硬币 |
-|GiftSend |20.04.19 |礼物赠送 |
-|Judge |20.04.19 |风纪 |
-|GroupSignIn |20.04.19 |友爱社签到 |
-|ManGa |20.04.19 |漫画签到分享 |
-|GiftHeart |20.04.19 |心跳礼物 |
-|MaterialObject |20.04.19 |实物抽奖 |
-|AloneTcpClient |20.04.19 |独立监控 |
-|ZoneTcpClient |20.04.19 |分区监控 |
-|StormRaffle |20.04.19 |节奏风暴 |
-|GiftRaffle |20.04.19 |活动礼物 |
-|PkRaffle |20.04.19 |大乱斗 |
-|GuardRaffle |20.04.19 |舰长总督 |
-|AnchorRaffle |20.04.19 |天选时刻 |
-|AwardRecord |20.04.19 |获奖通知 |
-|Statistics |20.04.19 |数据统计 |
+|Login |20.04.26 |账号登录 |
+|Schedule |20.04.26 |休眠控制 |
+|MasterSite |20.04.26 |主站助手 |
+|Daily |20.04.26 |每日礼包 |
+|Heart |20.04.26 |双端心跳 |
+|Task |20.04.26 |每日任务 |
+|Silver |20.04.26 |银瓜子宝箱 |
+|Barrage |20.04.26 |活跃弹幕 |
+|Silver2Coin |20.04.26 |银瓜子换硬币 |
+|GiftSend |20.04.26 |礼物赠送 |
+|Judge |20.04.26 |风纪 |
+|GroupSignIn |20.04.26 |友爱社签到 |
+|ManGa |20.04.26 |漫画签到分享 |
+|Match |20.04.26 |赛事签到分享 |
+|GiftHeart |20.04.26 |心跳礼物 |
+|MaterialObject |20.04.26 |实物抽奖 |
+|AloneTcpClient |20.04.26 |独立监控 |
+|ZoneTcpClient |20.04.26 |分区监控 |
+|StormRaffle |20.04.26 |节奏风暴 |
+|GiftRaffle |20.04.26 |活动礼物 |
+|PkRaffle |20.04.26 |大乱斗 |
+|GuardRaffle |20.04.26 |舰长总督 |
+|AnchorRaffle |20.04.26 |天选时刻 |
+|AwardRecord |20.04.26 |获奖通知 |
+|Statistics |20.04.26 |数据统计 |
## 打赏赞助
diff --git a/README.md b/README.md
index 4375c8d..8e52eb5 100644
--- a/README.md
+++ b/README.md
@@ -7,11 +7,9 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **仅用于BUG提交
## 公告
-> Currently for Personal Edition **0.3.0.200419 alpha**
+> Currently for Personal Edition **0.4.0.200426 alpha**
```notice
-开源本身是个很美好的,开源、共享服务放出来给公用,很简单很美好。
-从开放服务以来,没想到过会被滥用,免费服务不值得被尊重、被珍惜。
---- 免费的东西总是得不到人的珍惜。
---- 只有花大价钱去买到的东西,才会令人信任。
```
diff --git a/composer.lock b/composer.lock
index 5694dbe..fa8de01 100644
--- a/composer.lock
+++ b/composer.lock
@@ -8,16 +8,16 @@
"packages": [
{
"name": "amphp/amp",
- "version": "v2.4.1",
+ "version": "v2.4.3",
"source": {
"type": "git",
"url": "https://github.com/amphp/amp.git",
- "reference": "2ac3b550c4997f2ec304faa63c8b2885079a2dc4"
+ "reference": "23ac95fc6d6973231763f5ed7d1309b39429b974"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/amphp/amp/zipball/2ac3b550c4997f2ec304faa63c8b2885079a2dc4",
- "reference": "2ac3b550c4997f2ec304faa63c8b2885079a2dc4",
+ "url": "https://api.github.com/repos/amphp/amp/zipball/23ac95fc6d6973231763f5ed7d1309b39429b974",
+ "reference": "23ac95fc6d6973231763f5ed7d1309b39429b974",
"shasum": "",
"mirrors": [
{
@@ -33,14 +33,15 @@
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"ext-json": "*",
- "phpstan/phpstan": "^0.8.5",
+ "jetbrains/phpstorm-stubs": "^2019.3",
"phpunit/phpunit": "^6.0.9 | ^7",
- "react/promise": "^2"
+ "react/promise": "^2",
+ "vimeo/psalm": "^3.11@dev"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.0.x-dev"
+ "dev-master": "2.x-dev"
}
},
"autoload": {
@@ -87,7 +88,7 @@
"non-blocking",
"promise"
],
- "time": "2020-02-10T18:10:57+00:00"
+ "time": "2020-04-19T15:54:21+00:00"
},
{
"name": "bramus/ansi-php",
@@ -246,16 +247,16 @@
},
{
"name": "guzzlehttp/guzzle",
- "version": "6.5.2",
+ "version": "6.5.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
- "reference": "43ece0e75098b7ecd8d13918293029e555a50f82"
+ "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82",
- "reference": "43ece0e75098b7ecd8d13918293029e555a50f82",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/aab4ebd862aa7d04f01a4b51849d657db56d882e",
+ "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e",
"shasum": "",
"mirrors": [
{
@@ -268,7 +269,8 @@
"ext-json": "*",
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.6.1",
- "php": ">=5.5"
+ "php": ">=5.5",
+ "symfony/polyfill-intl-idn": "^1.11"
},
"require-dev": {
"ext-curl": "*",
@@ -276,7 +278,6 @@
"psr/log": "^1.1"
},
"suggest": {
- "ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
@@ -315,7 +316,7 @@
"rest",
"web service"
],
- "time": "2019-12-23T11:57:10+00:00"
+ "time": "2020-04-18T10:38:46+00:00"
},
{
"name": "guzzlehttp/promises",
@@ -830,17 +831,253 @@
"time": "2020-02-27T09:26:54+00:00"
},
{
- "name": "vlucas/phpdotenv",
- "version": "v4.1.3",
+ "name": "symfony/polyfill-intl-idn",
+ "version": "v1.15.0",
"source": {
"type": "git",
- "url": "https://github.com/vlucas/phpdotenv.git",
- "reference": "88f7acc95150bca002a498899f8b52f318e444c2"
+ "url": "https://github.com/symfony/polyfill-intl-idn.git",
+ "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/88f7acc95150bca002a498899f8b52f318e444c2",
- "reference": "88f7acc95150bca002a498899f8b52f318e444c2",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf",
+ "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "symfony/polyfill-mbstring": "^1.3",
+ "symfony/polyfill-php72": "^1.10"
+ },
+ "suggest": {
+ "ext-intl": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.15-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Intl\\Idn\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Laurent Bassin",
+ "email": "laurent@bassin.info"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "idn",
+ "intl",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2020-03-09T19:04:49+00:00"
+ },
+ {
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.15.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac",
+ "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.15-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2020-03-09T19:04:49+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php72",
+ "version": "v1.15.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php72.git",
+ "reference": "37b0976c78b94856543260ce09b460a7bc852747"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747",
+ "reference": "37b0976c78b94856543260ce09b460a7bc852747",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.15-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Php72\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2020-02-27T09:26:54+00:00"
+ },
+ {
+ "name": "vlucas/phpdotenv",
+ "version": "v4.1.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/vlucas/phpdotenv.git",
+ "reference": "feb6dad5ae24b1380827aee1629b730080fde500"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/feb6dad5ae24b1380827aee1629b730080fde500",
+ "reference": "feb6dad5ae24b1380827aee1629b730080fde500",
"shasum": "",
"mirrors": [
{
@@ -898,12 +1135,16 @@
"environment"
],
"funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
{
"url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
"type": "tidelift"
}
],
- "time": "2020-03-27T23:37:15+00:00"
+ "time": "2020-04-12T15:20:09+00:00"
}
],
"packages-dev": [],
diff --git a/conf/user.conf.example b/conf/user.conf.example
index cf86f83..5f56c40 100644
--- a/conf/user.conf.example
+++ b/conf/user.conf.example
@@ -60,6 +60,9 @@ SLEEP_SECTION=2,3,4,5,6
# 漫画助手
USE_MANGA=false
+# 赛事助手
+USE_MATCH=false
+
# 风纪(测试)
USE_JUDGE=false
diff --git a/src/core/App.php b/src/core/App.php
index 4e21cb6..ef8ee8c 100644
--- a/src/core/App.php
+++ b/src/core/App.php
@@ -69,6 +69,7 @@ class App
'MasterSite',
'Daily',
'ManGa',
+ 'Match',
'Heart',
'Task',
'Silver',
diff --git a/src/core/Env.php b/src/core/Env.php
index 1866bc8..1f46c03 100644
--- a/src/core/Env.php
+++ b/src/core/Env.php
@@ -13,7 +13,7 @@ namespace BiliHelper\Core;
class Env
{
private $app_name = 'BiliHelper Personal';
- private $app_version = '0.3.0.*';
+ private $app_version = '0.4.0.*';
/**
* Env constructor.
diff --git a/src/plugin/Live.php b/src/plugin/Live.php
index e23348f..a7eaee6 100644
--- a/src/plugin/Live.php
+++ b/src/plugin/Live.php
@@ -236,4 +236,34 @@ class Live
return (float)sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
}
+
+ /**
+ * @use 发送弹幕
+ * @param int $room_id
+ * @param string $content
+ * @return array
+ */
+ public static function sendBarrage(int $room_id, string $content): array
+ {
+ $user_info = User::parseCookies();
+ $url = 'https://api.live.bilibili.com/msg/send';
+ $payload = [
+ 'color' => '16777215',
+ 'fontsize' => 25,
+ 'mode' => 1,
+ 'msg' => $content,
+ 'rnd' => 0,
+ 'bubble' => 0,
+ 'roomid' => $room_id,
+ 'csrf' => $user_info['token'],
+ 'csrf_token' => $user_info['token'],
+ ];
+ $headers = [
+ 'origin' => 'https://live.bilibili.com',
+ 'referer' => "https://live.bilibili.com/{$room_id}"
+ ];
+ $raw = Curl::post('pc', $url, $payload, $headers);
+ return json_decode($raw, true) ?? ['code' => 404, 'msg' => '上层数据为空!'];
+ }
+
}
\ No newline at end of file
diff --git a/src/plugin/Match.php b/src/plugin/Match.php
new file mode 100644
index 0000000..2963786
--- /dev/null
+++ b/src/plugin/Match.php
@@ -0,0 +1,356 @@
+ [
+ 'type_id' => 25,
+ 'room_id' => 7734200,
+ 'short_room_id' => 6,
+ 'lottery_id' => 46,
+ 'status' => true
+ ],
+ 'OW' => [
+ 'type_id' => 26,
+ 'room_id' => 14073662,
+ 'short_room_id' => 76,
+ 'lottery_id' => 52,
+ 'status' => true
+ ],
+ 'KPL' => [
+ 'type_id' => 27,
+ 'room_id' => 21144080,
+ 'short_room_id' => 55,
+ 'lottery_id' => 55,
+ 'status' => true
+ ],
+ ];
+
+ public static function run()
+ {
+ if (self::getLock() > time() || getenv('USE_MATCH') == 'false') {
+ return;
+ }
+ self::initTask();
+ self::filterTask();
+ self::workTask();
+ self::setLock(3600);
+ }
+
+
+ /**
+ * @use 初始化任务
+ */
+ private static function initTask()
+ {
+ // 检查有效性
+ if (!self::$check_status) {
+ foreach (self::$room_infos as $title => $room) {
+ $status = self::getCapsuleStatus($room['lottery_id'], $room['short_room_id']);
+ if (!$status) {
+ self::$room_infos[$title]['status'] = false;
+ }
+ }
+ self::$check_status = true;
+ }
+ }
+
+
+ /**
+ * @use 过滤任务
+ */
+ private static function filterTask()
+ {
+ // 签到任务
+ foreach (self::$room_infos as $title => $room) {
+ if (!$room['status']) {
+ continue;
+ }
+ $status = self::getSignTask($room['type_id'], $room['room_id'], $room['short_room_id']);
+ if ($status) {
+ echo "aaa" . PHP_EOL;
+ self::$room_infos[$title]['sign'] = true;
+ } else {
+ self::$room_infos[$title]['sign'] = false;
+ }
+ }
+ // 分享任务
+ foreach (self::$room_infos as $title => $room) {
+ if (!$room['status']) {
+ continue;
+ }
+ $status = self::getShareTask($room['type_id'], $room['room_id'], $room['short_room_id']);
+ if ($status) {
+ echo "aaa" . PHP_EOL;
+ self::$room_infos[$title]['share'] = true;
+ } else {
+ self::$room_infos[$title]['share'] = false;
+ }
+ }
+ }
+
+
+ /**
+ * @use 运行任务
+ */
+ private static function workTask()
+ {
+ foreach (self::$room_infos as $title => $room) {
+ if (!$room['status']) {
+ continue;
+ }
+ if (in_array('sign', $room) && $room['sign']) {
+ self::matchSign($room['type_id'], $room['room_id'], $room['short_room_id']);
+ }
+ if (in_array('share', $room) && $room['share']) {
+ self::matchShare($room['type_id'], $room['room_id'], $room['short_room_id']);
+ }
+ }
+ }
+
+
+ /**
+ * @use 获取签到任务
+ * @param int $type_id
+ * @param int $room_id
+ * @param int $short_room_id
+ * @return bool
+ */
+ private static function getSignTask(int $type_id, int $room_id, int $short_room_id): bool
+ {
+ $url = 'https://api.live.bilibili.com/xlive/general-interface/v1/lpl-task/GetSignTask';
+ $payload = [
+ 'game_type' => $type_id,
+ ];
+ $headers = [
+ 'origin' => 'https://live.bilibili.com',
+ 'referer' => "https://live.bilibili.com/{$short_room_id}"
+ ];
+ $raw = Curl::get('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ // 成功 {"code":0,"message":"0","ttl":1,"data":{"id":601,"status":6,"day":30,"awards":[{"title":"彩色弹幕","cover":"https://i0.hdslb.com/bfs/live/9a571f9d82c2a8cbbe869fd92796e70b19f9c2cc.png"},{"title":"助威券","cover":"https://i0.hdslb.com/bfs/activity-plat/static/20200421/158d9f5e9553556421d8e1f652483400/ticket2.png"},{"title":"定制头衔","cover":"https://i0.hdslb.com/bfs/live/928598bde311f01364885ea14658476402eff99f.png"}]}}
+ // 默认 {"code":0,"message":"0","ttl":1,"data":{"id":601,"status":3,"day":30,"awards":[{"title":"彩色弹幕","cover":"https://i0.hdslb.com/bfs/live/9a571f9d82c2a8cbbe869fd92796e70b19f9c2cc.png"},{"title":"助威券","cover":"https://i0.hdslb.com/bfs/activity-plat/static/20200421/158d9f5e9553556421d8e1f652483400/ticket2.png"},{"title":"定制头衔","cover":"https://i0.hdslb.com/bfs/live/928598bde311f01364885ea14658476402eff99f.png"}]}}
+ if (isset($de_raw['data']['status']) && $de_raw['code'] == 0 && $de_raw['data']['status'] == 3) {
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * @use 获取弹幕任务
+ * @param int $type_id
+ * @param int $room_id
+ * @param int $short_room_id
+ * @return bool
+ */
+ private static function getDanmuTask(int $type_id, int $room_id, int $short_room_id): bool
+ {
+ $url = 'https://api.live.bilibili.com/xlive/general-interface/v1/lpl-task/GetDanmuTask';
+ $payload = [
+ 'game_type' => $type_id,
+ '_' => Live::getMillisecond()
+ ];
+ $headers = [
+ 'origin' => 'https://live.bilibili.com',
+ 'referer' => "https://live.bilibili.com/{$short_room_id}"
+ ];
+ $raw = Curl::get('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ // 错误 {"code":1002002,"message":"参数错误","ttl":1,"data":{"id":0,"status":0,"awards":null,"progress":null}}
+ // 默认 {"code":0,"message":"0","ttl":1,"data":{"id":620,"status":3,"awards":null,"progress":{"cur":0,"max":3}}}
+ // 完成 {"code":0,"message":"0","ttl":1,"data":{"id":620,"status":6,"awards":null,"progress":{"cur":3,"max":3}}}
+ if (isset($de_raw['data']['status']) && $de_raw['code'] == 0 && $de_raw['data']['status'] == 3) {
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * @use 获取分享任务
+ * @param int $type_id
+ * @param int $room_id
+ * @param int $short_room_id
+ * @return bool
+ */
+ private static function getShareTask(int $type_id, int $room_id, int $short_room_id): bool
+ {
+ $url = 'https://api.live.bilibili.com/xlive/general-interface/v1/lpl-task/GetShareTask';
+ $payload = [
+ 'game_type' => $type_id,
+ 'room_id' => $short_room_id,
+ '_' => Live::getMillisecond()
+ ];
+ $headers = [
+ 'origin' => 'https://live.bilibili.com',
+ 'referer' => "https://live.bilibili.com/{$short_room_id}"
+ ];
+ $raw = Curl::get('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ // 成功 {"code":0,"message":"0","ttl":1,"data":{"id":600,"status":6,"awards":null}}
+ // 默认 {"code":0,"message":"0","ttl":1,"data":{"id":600,"status":3,"awards":null}}
+ if (isset($de_raw['data']['status']) && $de_raw['code'] == 0 && $de_raw['data']['status'] == 3) {
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * @use 获取观看任务
+ * @param int $type_id
+ * @param int $room_id
+ * @param int $short_room_id
+ * @return bool
+ */
+ private static function getWatchTask(int $type_id, int $room_id, int $short_room_id): bool
+ {
+ $url = 'https://api.live.bilibili.com/xlive/general-interface/v1/lpl-task/GetWatchTask';
+ $payload = [
+ 'game_type' => $type_id,
+ 'room_id' => $room_id,
+ '_' => Live::getMillisecond()
+ ];
+ $headers = [
+ 'origin' => 'https://live.bilibili.com',
+ 'referer' => "https://live.bilibili.com/{$short_room_id}"
+ ];
+ $raw = Curl::get('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ // 错误 {"code":1002002,"message":"系统繁忙,请稍后再试","ttl":1,"data":{"id":0,"status":0,"progress":null,"awards":null}}
+ // 默认 {"code":0,"message":"0","ttl":1,"data":{"id":606,"status":3,"progress":{"cur":0,"max":1800},"awards":null}}
+ if (isset($de_raw['data']['status']) && $de_raw['code'] == 0 && $de_raw['data']['status'] == 3) {
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * @use 检查奖池状态
+ * @param int $lottery_id
+ * @param int $short_room_id
+ * @return bool
+ */
+ private static function getCapsuleStatus(int $lottery_id, int $short_room_id): bool
+ {
+ $url = 'https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/get_capsule_info_v3';
+ $payload = [
+ 'id' => $lottery_id,
+ 'from' => 'web',
+ '-' => Live::getMillisecond()
+ ];
+ $headers = [
+ 'origin' => 'https://live.bilibili.com',
+ 'referer' => "https://live.bilibili.com/{$short_room_id}"
+ ];
+ $raw = Curl::get('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ // 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}]}}
+ if (isset($de_raw['data']['status']) && $de_raw['code'] == 0 && $de_raw['data']['status'] == 0) {
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * @use 分享任务
+ * @param int $type_id
+ * @param int $room_id
+ * @param int $short_room_id
+ * @return bool
+ */
+ private static function matchShare(int $type_id, int $room_id, int $short_room_id): bool
+ {
+ $user_info = User::parseCookies();
+ $url = 'https://api.live.bilibili.com/xlive/general-interface/v1/lpl-task/MatchShare';
+ $payload = [
+ 'game_type' => $type_id,
+ 'csrf_token' => $user_info['token'],
+ 'csrf' => $user_info['token'],
+ 'visit_id' => ''
+ ];
+ $headers = [
+ 'Content-Type' => 'application/x-www-form-urlencoded',
+ 'Origin' => 'https://live.bilibili.com',
+ 'Referer' => "https://live.bilibili.com/{$short_room_id}"
+ ];
+ // {"code":0,"message":"0","ttl":1,"data":{"status":1}}
+ $raw = Curl::post('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ if ($de_raw['code'] == 0) {
+ Log::notice("房间 {$short_room_id} 赛事 {$type_id} 分享成功~");
+ return true;
+ }
+ Log::warning("房间 {$short_room_id} 赛事 {$type_id} 分享失败~");
+ return false;
+ }
+
+
+ /**
+ * @use 签到任务
+ * @param int $type_id
+ * @param int $room_id
+ * @param int $short_room_id
+ * @return bool
+ */
+ private static function matchSign(int $type_id, int $room_id, int $short_room_id): bool
+ {
+ $user_info = User::parseCookies();
+ $url = 'https://api.live.bilibili.com/xlive/general-interface/v1/lpl-task/MatchSign';
+ $payload = [
+ 'room_id' => $room_id,
+ 'game_type' => $type_id,
+ 'csrf_token' => $user_info['token'],
+ 'csrf' => $user_info['token'],
+ 'visit_id' => ''
+ ];
+ $headers = [
+ 'Content-Type' => 'application/x-www-form-urlencoded',
+ 'Origin' => 'https://live.bilibili.com',
+ 'Referer' => "https://live.bilibili.com/{$short_room_id}"
+ ];
+ // {"code":0,"message":"0","ttl":1,"data":{"status":1,"awards":[{"title":"彩色弹幕","cover":"https://i0.hdslb.com/bfs/live/9a571f9d82c2a8cbbe869fd92796e70b19f9c2cc.png","num":1}],"is_focus":1}}
+ $raw = Curl::post('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ if ($de_raw['code'] == 0) {
+ Log::notice("房间 {$short_room_id} 赛事 {$type_id} 签到成功~");
+ return true;
+ }
+ Log::warning("房间 {$short_room_id} 赛事 {$type_id} 签到失败~");
+ return false;
+ }
+
+ private static function matchDanmu()
+ {
+
+ }
+
+ private static function matchWatch()
+ {
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/plugin/Schedule.php b/src/plugin/Schedule.php
index 8f9a14c..4563193 100644
--- a/src/plugin/Schedule.php
+++ b/src/plugin/Schedule.php
@@ -23,7 +23,7 @@ class Schedule
private static $unlock_timers = [];
private static $sleep_section = [];
// 日常类
- private static $fillable = ['Login', 'Schedule', 'Daily', 'Judge', 'MasterSite', 'GiftSend', 'Task', 'Silver2Coin', 'GroupSignIn', 'AwardRecord', 'Statistics'];
+ private static $fillable = ['Login', 'Schedule', 'Daily', 'Judge', 'MasterSite', 'GiftSend', 'Task', 'Silver2Coin', 'ManGa', 'Match', 'GroupSignIn', 'AwardRecord', 'Statistics'];
// 任务类
private static $guarded_first = ['Barrage', 'GiftHeart', 'Silver', 'MaterialObject'];
// 监控类