From ade3acb6d887718a30bfca0198af1199b53c24fa Mon Sep 17 00:00:00 2001
From: Lkeme <1462364497@qq.com>
Date: Mon, 23 Dec 2019 14:24:37 +0800
Subject: [PATCH] [add] anchor
---
CHANGELOG.md | 12 ++++++
DOC.md | 35 ++++++++--------
README.md | 2 +-
composer.json | 2 +-
composer.lock | 68 +++++++++++++++---------------
conf/user.conf.example | 12 ++++--
index.php | 5 ++-
src/Anchor.php | 95 ++++++++++++++++++++++++++++++++++++++++++
src/BaseRaffle.php | 2 +-
src/Curl.php | 2 +-
src/Daily.php | 2 +-
src/Danmu.php | 2 +-
src/DataTreating.php | 6 ++-
src/File.php | 2 +-
src/GiftHeart.php | 2 +-
src/GiftSend.php | 2 +-
src/GroupSignIn.php | 2 +-
src/Guard.php | 2 +-
src/Heart.php | 2 +-
src/Live.php | 2 +-
src/Log.php | 2 +-
src/Login.php | 11 +++--
src/MasterSite.php | 2 +-
src/MaterialObject.php | 2 +-
src/Notice.php | 2 +-
src/PkRaffle.php | 2 +-
src/Sign.php | 2 +-
src/Silver.php | 2 +-
src/Silver2Coin.php | 2 +-
src/Socket.php | 2 +-
src/Statistics.php | 2 +-
src/Storm.php | 2 +-
src/Task.php | 4 +-
src/TcpClient.php | 24 +++++++----
src/UnifyRaffle.php | 2 +-
src/User.php | 2 +-
src/Websocket.php | 2 +-
src/Winning.php | 2 +-
38 files changed, 229 insertions(+), 99 deletions(-)
create mode 100644 src/Anchor.php
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 511633c..703a1fd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,18 @@
# Release Notes
# 本项目Log
+## v0.0.1.191223 alpha (2019-12-23)
+
+### Added
+- anchor(beta)
+-
+
+### Changed
+-
+
+### Fixed
+-
+
## v0.0.1.191030 alpha (2019-10-30)
### Added
diff --git a/DOC.md b/DOC.md
index 3e5eab3..4951d9a 100644
--- a/DOC.md
+++ b/DOC.md
@@ -2,7 +2,7 @@

-
+
@@ -17,22 +17,23 @@ B 站直播实用脚本
|plugin |version |description |
|--------------------|--------------------|--------------------|
-|Daily |19.07.13 |每日背包奖励 |
-|GiftSend |19.07.13 |自动清空过期礼物 |
-|Heart |19.07.13 |双端直播间心跳 |
-|Login |19.07.13 |帐号登录组件 |
-|Silver |19.07.13 |自动领宝箱 |
-|Task |19.07.13 |每日任务 |
-|GiftHeart |19.07.13 |心跳礼物 |
-|Silver2Coin |19.07.13 |银瓜子换硬币 |
-|MaterialObject |19.07.13 |实物抽奖 |
-|GroupSignIn |19.07.13 |应援团签到 |
-|Storm |19.07.13 |节奏风暴 |
-|Notice |19.07.13 |Server酱 |
-|UnifyRaffle |19.07.23 |统一活动抽奖 |
-|MasterSite |19.07.13 |主站(观看、分享、投币)|
-|Guard |19.07.23 |舰长上船亲密度 |
-|PkRaffle |19.07.23 |大乱斗 |
+|Daily |19.12.23 |每日背包奖励 |
+|GiftSend |19.12.23 |自动清空过期礼物 |
+|Heart |19.12.23 |双端直播间心跳 |
+|Login |19.12.23 |帐号登录组件 |
+|Silver |19.12.23 |自动领宝箱 |
+|Task |19.12.23 |每日任务 |
+|GiftHeart |19.12.23 |心跳礼物 |
+|Silver2Coin |19.12.23 |银瓜子换硬币 |
+|MaterialObject |19.12.23 |实物抽奖 |
+|GroupSignIn |19.12.23 |应援团签到 |
+|Storm |19.12.23 |节奏风暴 |
+|Notice |19.12.23 |Server酱 |
+|UnifyRaffle |19.12.23 |统一活动抽奖 |
+|MasterSite |19.12.23 |主站(观看、分享、投币)|
+|Guard |19.12.23 |舰长上船亲密度 |
+|PkRaffle |19.12.23 |大乱斗 |
+|Anchor |19.12.23 |天选时刻 |
## 打赏赞助
diff --git a/README.md b/README.md
index d0e8da0..be6f22e 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg)
## 公告
-Currently for Personal Edition **0.0.1.190822 alpha**
+Currently for Personal Edition **0.0.1.191213 alpha**
## 文档
diff --git a/composer.json b/composer.json
index f8e1f92..eecd952 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
"vlucas/phpdotenv": "^2.4",
"monolog/monolog": "^1.23",
"bramus/monolog-colored-line-formatter": "^2.0",
- "clue/socket-raw": "1.4"
+ "clue/socket-raw": "^1.4.1"
},
"license": "MIT",
"authors": [
diff --git a/composer.lock b/composer.lock
index db5e915..1c1c100 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "6fca2d61232110e041d8cb569c30d02f",
+ "content-hash": "d09e06835f7ff6a06fcb74285e6617c5",
"packages": [
{
"name": "bramus/ansi-php",
- "version": "3.0.2",
+ "version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/bramus/ansi-php.git",
- "reference": "79d30c30651b0c6f23cf85503c779c72ac74ab8a"
+ "reference": "fb0be33f36053af7454d462e3ddc0a2ac0b2f311"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/bramus/ansi-php/zipball/79d30c30651b0c6f23cf85503c779c72ac74ab8a",
- "reference": "79d30c30651b0c6f23cf85503c779c72ac74ab8a",
+ "url": "https://api.github.com/repos/bramus/ansi-php/zipball/fb0be33f36053af7454d462e3ddc0a2ac0b2f311",
+ "reference": "fb0be33f36053af7454d462e3ddc0a2ac0b2f311",
"shasum": "",
"mirrors": [
{
@@ -50,7 +50,7 @@
}
],
"description": "ANSI Control Functions and ANSI Control Sequences (Colors, Erasing, etc.) for PHP CLI Apps",
- "time": "2019-02-12T15:05:30+00:00"
+ "time": "2019-12-03T09:04:38+00:00"
},
{
"name": "bramus/monolog-colored-line-formatter",
@@ -102,16 +102,16 @@
},
{
"name": "clue/socket-raw",
- "version": "v1.4.0",
+ "version": "v1.4.1",
"source": {
"type": "git",
"url": "https://github.com/clue/php-socket-raw.git",
- "reference": "2f6654445233407900c9a804490cecd8e4f2ae86"
+ "reference": "00ab102d061f6cdb895e79dd4d69140c7bda31cc"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/clue/php-socket-raw/zipball/2f6654445233407900c9a804490cecd8e4f2ae86",
- "reference": "2f6654445233407900c9a804490cecd8e4f2ae86",
+ "url": "https://api.github.com/repos/clue/php-socket-raw/zipball/00ab102d061f6cdb895e79dd4d69140c7bda31cc",
+ "reference": "00ab102d061f6cdb895e79dd4d69140c7bda31cc",
"shasum": "",
"mirrors": [
{
@@ -140,10 +140,10 @@
"authors": [
{
"name": "Christian Lück",
- "email": "christian@lueck.tv"
+ "email": "christian@clue.engineering"
}
],
- "description": "Simple and lightweight OOP wrapper for PHP's low level sockets extension (ext-sockets)",
+ "description": "Simple and lightweight OOP wrapper for PHP's low-level sockets extension (ext-sockets)",
"homepage": "https://github.com/clue/php-socket-raw",
"keywords": [
"Socket",
@@ -159,20 +159,20 @@
"udp",
"unix"
],
- "time": "2019-01-22T11:08:01+00:00"
+ "time": "2019-10-28T12:32:07+00:00"
},
{
"name": "monolog/monolog",
- "version": "1.24.0",
+ "version": "1.25.3",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
- "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
+ "reference": "fa82921994db851a8becaf3787a9e73c5976b6f1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
- "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fa82921994db851a8becaf3787a9e73c5976b6f1",
+ "reference": "fa82921994db851a8becaf3787a9e73c5976b6f1",
"shasum": "",
"mirrors": [
{
@@ -243,20 +243,20 @@
"logging",
"psr-3"
],
- "time": "2018-11-05T09:00:11+00:00"
+ "time": "2019-12-20T14:15:16+00:00"
},
{
"name": "psr/log",
- "version": "1.1.0",
+ "version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
- "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
+ "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
- "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801",
+ "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801",
"shasum": "",
"mirrors": [
{
@@ -271,7 +271,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.0.x-dev"
+ "dev-master": "1.1.x-dev"
}
},
"autoload": {
@@ -296,20 +296,20 @@
"psr",
"psr-3"
],
- "time": "2018-11-20T15:27:04+00:00"
+ "time": "2019-11-01T11:05:21+00:00"
},
{
"name": "symfony/polyfill-ctype",
- "version": "v1.11.0",
+ "version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "82ebae02209c21113908c229e9883c419720738a"
+ "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
- "reference": "82ebae02209c21113908c229e9883c419720738a",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
+ "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
"shasum": "",
"mirrors": [
{
@@ -327,7 +327,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.11-dev"
+ "dev-master": "1.13-dev"
}
},
"autoload": {
@@ -343,13 +343,13 @@
"MIT"
],
"authors": [
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- },
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
@@ -360,7 +360,7 @@
"polyfill",
"portable"
],
- "time": "2019-02-06T07:57:58+00:00"
+ "time": "2019-11-27T13:56:44+00:00"
},
{
"name": "vlucas/phpdotenv",
diff --git a/conf/user.conf.example b/conf/user.conf.example
index 887dd46..6e184c5 100644
--- a/conf/user.conf.example
+++ b/conf/user.conf.example
@@ -44,15 +44,19 @@ SOCKET_ROOM_ID=9522051
# 主站助手
USE_MASTER_SITE=true
-# 舰长总督
-USE_GUARD=true
-
# 统一活动
USE_ACTIVE=true
+# 舰长总督
+USE_GUARD=true
+
# 大乱斗
USE_PK=true
+# 天选时刻|抽取类型(0: 无限制; 1: 关注主播; 2: 粉丝勋章; 3大航海; 4用户等级;5主站等级)|逗号分隔
+USE_ANCHOR=false
+ANCHOR_TYPE=0,1
+
# 实物抽奖
USE_MO=true
@@ -93,7 +97,7 @@ APP_UNAME=
# 多账号区别输出
APP_MULTIPLE=false
-# 账号别名,如果为空则默认使用登陆账号作为标示
+# 账号别名,如果为空则默认使用登录账号作为标示
APP_USER_IDENTITY=
# 日志回调地址
diff --git a/index.php b/index.php
index d4f2682..97479e6 100644
--- a/index.php
+++ b/index.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
@@ -54,8 +54,9 @@ class Index
PkRaffle::run();
UnifyRaffle::run();
Guard::run();
+ Anchor::run();
Statistics::run();
- usleep(0.1 * 1000000);
+ usleep(0.2 * 1000000);
}
}
diff --git a/src/Anchor.php b/src/Anchor.php
new file mode 100644
index 0000000..ae6aa60
--- /dev/null
+++ b/src/Anchor.php
@@ -0,0 +1,95 @@
+ $rid
+ ];
+ $url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/Anchor/Check';
+ $raw = Curl::get($url, Sign::api($payload));
+ $de_raw = json_decode($raw, true);
+
+ // 防止异常情况
+ if (!isset($de_raw['data']) || $de_raw['data']['join_type'] || $de_raw['data']['lot_status']) {
+ return false;
+ }
+ // TODO
+ self::$filter_type = empty(self::$filter_type) ? explode(',', getenv('ANCHOR_TYPE')) : self::$filter_type;
+ if (!in_array((string)$de_raw['data']['require_type'], self::$filter_type)) {
+ return false;
+ }
+
+ $data = [
+ 'room_id' => $de_raw['data']['room_id'],
+ 'raffle_id' => $de_raw['data']['id'],
+ 'prize' => $de_raw['data']['award_name'],
+ 'wait' => strtotime(date("Y-m-d H:i:s"))
+ ];
+ if (static::toRepeatLid($data['raffle_id'])) {
+ return false;
+ }
+ Statistics::addPushList(static::ACTIVE_TITLE);
+ array_push(static::$wait_list, $data);
+ return true;
+ }
+
+
+ /**
+ * @use 请求抽奖
+ * @param array $data
+ * @return bool
+ */
+ protected static function lottery(array $data): bool
+ {
+ $user_info = User::parseCookies();
+ $payload = [
+ 'id' => $data['raffle_id'],
+ 'roomid' => $data['room_id'],
+ 'platform' => 'pc',
+ 'csrf_token' => $user_info['token'],
+ 'csrf' => $user_info['token'],
+ 'visit_id' => '',
+ ];
+ $url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/Anchor/Join';
+ $raw = Curl::post($url, Sign::api($payload));
+ $de_raw = json_decode($raw, true);
+
+ if (isset($de_raw['code']) && $de_raw['code'] == 0) {
+ print_r($de_raw);
+ Statistics::addSuccessList(static::ACTIVE_TITLE);
+ Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . static::ACTIVE_TITLE . ": {$data['prize']}");
+ } else {
+ Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . static::ACTIVE_TITLE . ": {$de_raw['message']}");
+ }
+ return true;
+ }
+}
diff --git a/src/BaseRaffle.php b/src/BaseRaffle.php
index d58d94f..eb2b92c 100644
--- a/src/BaseRaffle.php
+++ b/src/BaseRaffle.php
@@ -6,7 +6,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Curl.php b/src/Curl.php
index a2bf17a..adf87a5 100644
--- a/src/Curl.php
+++ b/src/Curl.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Daily.php b/src/Daily.php
index 7887eb9..f3bf116 100644
--- a/src/Daily.php
+++ b/src/Daily.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Danmu.php b/src/Danmu.php
index 28729ab..c6172d1 100644
--- a/src/Danmu.php
+++ b/src/Danmu.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/DataTreating.php b/src/DataTreating.php
index ac35b1a..b0ece70 100644
--- a/src/DataTreating.php
+++ b/src/DataTreating.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
@@ -46,6 +46,10 @@ class DataTreating
// 乱斗
PkRaffle::pushToQueue($info);
break;
+ case 'anchor':
+ // 天选时刻
+ Anchor::pushToQueue($info);
+ break;
default:
break;
}
diff --git a/src/File.php b/src/File.php
index d553147..729955a 100644
--- a/src/File.php
+++ b/src/File.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/GiftHeart.php b/src/GiftHeart.php
index 29e2045..35d3320 100644
--- a/src/GiftHeart.php
+++ b/src/GiftHeart.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/GiftSend.php b/src/GiftSend.php
index c880fc8..6c6861d 100644
--- a/src/GiftSend.php
+++ b/src/GiftSend.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/GroupSignIn.php b/src/GroupSignIn.php
index 9d39f04..b7f4512 100644
--- a/src/GroupSignIn.php
+++ b/src/GroupSignIn.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Guard.php b/src/Guard.php
index 1e8ce2e..e7b5c01 100644
--- a/src/Guard.php
+++ b/src/Guard.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Heart.php b/src/Heart.php
index b23ccca..889cc08 100644
--- a/src/Heart.php
+++ b/src/Heart.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Live.php b/src/Live.php
index 3a14e74..154457b 100644
--- a/src/Live.php
+++ b/src/Live.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Log.php b/src/Log.php
index 4a45410..c6e663c 100644
--- a/src/Log.php
+++ b/src/Log.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Login.php b/src/Login.php
index 7db8322..12d470a 100644
--- a/src/Login.php
+++ b/src/Login.php
@@ -4,7 +4,7 @@
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
@@ -134,6 +134,11 @@ class Login
$headers = $captcha_data['headers'];
continue;
}
+ // https://passport.bilibili.com/mobile/verifytel_h5.html
+ if (!$data['code'] && $data['data']['status']) {
+ Log::error('登录失败', ['msg' => '登录异常, 账号启用了设备锁或异地登录需验证手机!']);
+ die();
+ }
break;
}
if (isset($data['code']) && $data['code']) {
@@ -155,10 +160,10 @@ class Login
protected static function loginWithCaptcha()
{
- Log::info('登陆需要验证 ,启动验证码登陆!');
+ Log::info('登录需要验证, 启动验证码登录!');
$headers = [
'Accept' => 'application/json, text/plain, */*',
- 'User-Agent' => 'bili-universal/8230 CFNetwork/975.0.3 Darwin/18.2.0',
+ 'User-Agent' => 'bili-universal/8470 CFNetwork/978.0.7 Darwin/18.5.0',
'Host' => 'passport.bilibili.com',
'Cookie' => 'sid=blhelper'
];
diff --git a/src/MasterSite.php b/src/MasterSite.php
index 32bda7e..88ad3dd 100644
--- a/src/MasterSite.php
+++ b/src/MasterSite.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/MaterialObject.php b/src/MaterialObject.php
index 8c32906..412236d 100644
--- a/src/MaterialObject.php
+++ b/src/MaterialObject.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Notice.php b/src/Notice.php
index b14c63b..7df86c4 100644
--- a/src/Notice.php
+++ b/src/Notice.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/PkRaffle.php b/src/PkRaffle.php
index 25a5d20..c95549d 100644
--- a/src/PkRaffle.php
+++ b/src/PkRaffle.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Sign.php b/src/Sign.php
index f70743f..6ffc65e 100644
--- a/src/Sign.php
+++ b/src/Sign.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Silver.php b/src/Silver.php
index e31cfc4..8946a59 100644
--- a/src/Silver.php
+++ b/src/Silver.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Silver2Coin.php b/src/Silver2Coin.php
index c18d308..f336c2f 100644
--- a/src/Silver2Coin.php
+++ b/src/Silver2Coin.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Socket.php b/src/Socket.php
index 2c54c49..abd7b29 100644
--- a/src/Socket.php
+++ b/src/Socket.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Statistics.php b/src/Statistics.php
index 5b62f38..ef8b4b4 100644
--- a/src/Statistics.php
+++ b/src/Statistics.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Storm.php b/src/Storm.php
index f076def..6fbf0a6 100644
--- a/src/Storm.php
+++ b/src/Storm.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Task.php b/src/Task.php
index 38ace2d..39cf86f 100644
--- a/src/Task.php
+++ b/src/Task.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
@@ -65,7 +65,7 @@ class Task
} else {
Log::info('签到成功');
// 推送签到信息
- Notice::run('todaySign', $data['msg']);
+ Notice::run('todaySign', $data['message']);
}
}
diff --git a/src/TcpClient.php b/src/TcpClient.php
index 0ff3977..5cafae9 100644
--- a/src/TcpClient.php
+++ b/src/TcpClient.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
@@ -20,6 +20,7 @@ class TcpClient
private static $client = null;
private static $server_addr = null;
private static $server_key = null;
+ private static $socket_timeout = 0;
/**
* @desc 入口
@@ -102,7 +103,7 @@ class TcpClient
if (self::$heart_lock <= time()) {
if (self::writer("")) {
// 心跳默认35s 调整数据错开错误
- self::$heart_lock = time() + 20;
+ self::$heart_lock = time() + 25;
}
}
}
@@ -116,11 +117,14 @@ class TcpClient
{
$data = false;
try {
- $data = self::$client->read($length);
- if (!$data) {
- throw new Exception("Connection failure");
+ while (self::$client->selectRead(self::$socket_timeout)) {
+ $data = self::$client->read($length);
+ if (!$data) {
+ throw new Exception("Connection failure");
+ }
+ if ($length == 4) $data = self::unPackMsg($data);
+ break;
}
- if ($length == 4) $data = self::unPackMsg($data);
} catch (Exception $exception) {
self::reConnect();
}
@@ -136,8 +140,11 @@ class TcpClient
{
$status = false;
try {
- $data = self::packMsg($data);
- $status = self::$client->write($data);
+ while (self::$client->selectWrite(self::$socket_timeout)) {
+ $data = self::packMsg($data);
+ $status = self::$client->write($data);
+ break;
+ }
} catch (Exception $exception) {
self::reConnect();
}
@@ -153,6 +160,7 @@ class TcpClient
if (!self::$client) {
try {
$socket = (new Factory())->createClient(self::$server_addr, 40);
+ $socket->setBlocking(false);
self::$client = $socket;
self::handShake();
Log::info("连接到 {$socket->getPeerName()} 推送服务器");
diff --git a/src/UnifyRaffle.php b/src/UnifyRaffle.php
index 9976dcc..ba184e1 100644
--- a/src/UnifyRaffle.php
+++ b/src/UnifyRaffle.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/User.php b/src/User.php
index 8c65a09..4bbde7c 100644
--- a/src/User.php
+++ b/src/User.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Websocket.php b/src/Websocket.php
index 2fcae1a..7a5d6d0 100644
--- a/src/Websocket.php
+++ b/src/Websocket.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;
diff --git a/src/Winning.php b/src/Winning.php
index 5467b2d..b89bce8 100644
--- a/src/Winning.php
+++ b/src/Winning.php
@@ -5,7 +5,7 @@
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
- * Updated: 2019
+ * Updated: 2019 ~ 2020
*/
namespace lkeme\BiliHelper;