From 9b92a5e9fe171971be40dceda7918154b529c0d3 Mon Sep 17 00:00:00 2001
From: lkeme <1462364497@qq.com>
Date: Sat, 27 Mar 2021 15:56:36 +0800
Subject: [PATCH] [update] Version 0.8.0
---
CHANGELOG.md | 30 ++
DOC.md | 60 ++--
LICENSE | 2 +-
README.md | 3 +-
composer.json | 16 +-
composer.lock | 384 ++++++++++++++++--------
conf/user.conf.example | 125 ++++----
data/activity_infos.json | 81 +++++
data/capsule_infos.json | 77 +++++
data/filter_words.json | 225 ++++++++++++++
index.php | 4 +-
src/core/App.php | 20 +-
src/core/Config.php | 2 +-
src/core/Curl.php | 8 +-
src/core/Env.php | 8 +-
src/core/Log.php | 22 +-
src/plugin/ActivityLottery.php | 120 ++++++--
src/plugin/AnchorRaffle.php | 20 +-
src/plugin/CapsuleLottery.php | 363 ++++++++++++++++++++++
src/plugin/{Task.php => DailyTask.php} | 6 +-
src/plugin/Forward.php | 40 ++-
src/plugin/{Match.php => GameMatch.php} | 2 +-
src/plugin/GiftRaffle.php | 1 +
src/plugin/GuardRaffle.php | 1 +
src/plugin/Live.php | 32 +-
src/plugin/Login.php | 11 +-
src/plugin/MaterialObject.php | 16 +-
src/plugin/Notice.php | 219 +++++++++++---
src/plugin/PkRaffle.php | 1 +
src/plugin/Schedule.php | 4 +-
src/plugin/Sign.php | 6 +-
src/plugin/Silver2Coin.php | 2 +-
src/plugin/SmallHeart.php | 5 +-
src/plugin/StormRaffle.php | 1 +
src/plugin/ZoneTcpClient.php | 4 +-
src/tool/Common.php | 52 ++++
src/tool/File.php | 274 +++++++++++++++++
src/util/AllotTasks.php | 92 ++++++
src/{plugin => util}/BaseRaffle.php | 4 +-
src/util/FilterWords.php | 39 +++
40 files changed, 2018 insertions(+), 364 deletions(-)
create mode 100644 data/activity_infos.json
create mode 100644 data/capsule_infos.json
create mode 100644 data/filter_words.json
create mode 100644 src/plugin/CapsuleLottery.php
rename src/plugin/{Task.php => DailyTask.php} (95%)
rename src/plugin/{Match.php => GameMatch.php} (99%)
create mode 100644 src/tool/Common.php
create mode 100644 src/tool/File.php
create mode 100644 src/util/AllotTasks.php
rename src/{plugin => util}/BaseRaffle.php (98%)
create mode 100644 src/util/FilterWords.php
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5665802..8274438 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,36 @@
# Release Notes
# 本项目Log
+## v0.8.0.210327 alpha (2021-03-27)
+
+### Added
+- 增加直播扭蛋抽奖活动(可自定义)
+- 增加主站九宫格抽奖活动(可自定义)
+- 增加多个推送消息通道
+-
+
+### Changed
+- 更新过滤词独立
+- 更新请求中心
+- 更新日志打印
+- 更新基础库
+- 更新环境读取流程
+- 更新部分配置
+- 更新登录请求
+- 更新实物抽奖&天选抽奖
+- 支持PHP8.0+
+- 更新弹幕抽奖
+- 更新每日任务
+- 更新部分任务架构
+- 引入必要新包
+-
+
+### Fixed
+- 修复小心心心跳错误
+- 修复部分推送错误
+- 修复银瓜子换银币日志错误
+-
+
## v0.6.7.201117 alpha (2020-11-17)
### Added
diff --git a/DOC.md b/DOC.md
index 7ea9f5e..c654b2a 100644
--- a/DOC.md
+++ b/DOC.md
@@ -2,7 +2,7 @@

-
+
@@ -15,34 +15,36 @@ B 站直播实用脚本
|plugin |version |description |
|--------------------|--------------------|--------------------|
-|Login |21.01.19 |账号登录 |
-|Schedule |21.01.19 |休眠控制 |
-|MasterSite |21.01.19 |主站助手 |
-|Daily |21.01.19 |每日礼包 |
-|Heart |21.01.19 |双端心跳 |
-|Task |21.01.19 |每日任务 |
-|Silver |21.01.19 |银瓜子宝箱 |
-|Barrage |21.01.19 |活跃弹幕 |
-|Silver2Coin |21.01.19 |银瓜子换硬币 |
-|GiftSend |21.01.19 |礼物赠送 |
-|Judge |21.01.19 |风纪 |
-|GroupSignIn |21.01.19 |友爱社签到 |
-|ManGa |21.01.19 |漫画签到分享 |
-|Match |21.01.19 |赛事签到分享 |
-|GiftHeart |21.01.19 |心跳礼物 |
-|MaterialObject |21.01.19 |实物抽奖 |
-|AloneTcpClient |21.01.19 |独立监控 |
-|ZoneTcpClient |21.01.19 |分区监控 |
-|StormRaffle |21.01.19 |节奏风暴 |
-|GiftRaffle |21.01.19 |活动礼物 |
-|PkRaffle |21.01.19 |大乱斗 |
-|GuardRaffle |21.01.19 |舰长总督 |
-|AnchorRaffle |21.01.19 |天选时刻 |
-|AwardRecord |21.01.19 |获奖通知 |
-|Statistics |21.01.19 |数据统计 |
-|Competition |21.01.19 |赛事竞猜 |
-|SmallHeart |21.01.19 |小心心 |
-|ActivityLottery |21.01.19 |主站活动 |
+|Login |21.03.27 |账号登录 |
+|Schedule |21.03.27 |休眠控制 |
+|MasterSite |21.03.27 |主站助手 |
+|Daily |21.03.27 |每日礼包 |
+|Heart |21.03.27 |双端心跳 |
+|DailyTask |21.03.27 |每日任务 |
+|Silver |21.03.27 |银瓜子宝箱 |
+|Barrage |21.03.27 |活跃弹幕 |
+|Silver2Coin |21.03.27 |银瓜子换硬币 |
+|GiftSend |21.03.27 |礼物赠送 |
+|Judge |21.03.27 |风纪 |
+|GroupSignIn |21.03.27 |友爱社签到 |
+|ManGa |21.03.27 |漫画签到分享 |
+|GameMatch |21.03.27 |赛事签到分享 |
+|GiftHeart |21.03.27 |心跳礼物 |
+|MaterialObject |21.03.27 |实物抽奖 |
+|AloneTcpClient |21.03.27 |独立监控 |
+|ZoneTcpClient |21.03.27 |分区监控 |
+|StormRaffle |21.03.27 |节奏风暴 |
+|GiftRaffle |21.03.27 |活动礼物 |
+|PkRaffle |21.03.27 |大乱斗 |
+|GuardRaffle |21.03.27 |舰长总督 |
+|AnchorRaffle |21.03.27 |天选时刻 |
+|AwardRecord |21.03.27 |获奖通知 |
+|Statistics |21.03.27 |数据统计 |
+|Competition |21.03.27 |赛事竞猜 |
+|SmallHeart |21.03.27 |小心心 |
+|ActivityLottery |21.03.27 |主站活动 |
+|CapsuleLottery |21.03.27 |直播扭蛋活动 |
+|Forward |21.03.27 |动态抽奖转发 |
## 打赏赞助
diff --git a/LICENSE b/LICENSE
index 610b7f2..dd68ab2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2019 lkeme
+Copyright (c) 2021 Lkeme
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 4d4d8f8..cf48b01 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **仅用于BUG提交
## 公告
-> Currently for Personal Edition **0.7.0.210119 alpha**
+> Personal Edition **0.8.0.210327 alpha**
```notice
---- 免费的东西总是得不到人的珍惜。
@@ -15,6 +15,7 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **仅用于BUG提交
```
## 文档
+> 有疑问一定要先看看文档或Issue里是否存在相同的问题,再考虑其他渠道咨询。
* [使用文档 / DOC.md](./DOC.md)
* [更新日志 / CHANGELOG.md](./CHANGELOG.md)
diff --git a/composer.json b/composer.json
index df5f982..1ad3703 100644
--- a/composer.json
+++ b/composer.json
@@ -10,13 +10,15 @@
"ext-json": "*",
"ext-zlib": "*",
"ext-mbstring": "*",
- "monolog/monolog": "^1.23",
- "bramus/monolog-colored-line-formatter": "^2.0",
- "clue/socket-raw": "^1.4.1",
- "vlucas/phpdotenv": "^4.1",
- "amphp/amp": "^2.4",
- "guzzlehttp/guzzle": "^6.5",
- "mathieuviossat/arraytotexttable": "^1.0"
+ "monolog/monolog": "^1.26.0",
+ "bramus/monolog-colored-line-formatter": "^2.0.3",
+ "clue/socket-raw": "^1.5.0",
+ "vlucas/phpdotenv": "^4.2.0",
+ "amphp/amp": "^2.5.2",
+ "guzzlehttp/guzzle": "^6.5.5",
+ "mathieuviossat/arraytotexttable": "^1.0.8",
+ "klkvsk/json-decode-stream": "^1.0",
+ "sven/file-config": "^3.1"
},
"license": "MIT",
"authors": [
diff --git a/composer.lock b/composer.lock
index 116dc01..6f574d2 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": "773a1bbd829be3a7bb684f926002ac37",
+ "content-hash": "a9407272d4bb9ca1632a2aa728429bf0",
"packages": [
{
"name": "amphp/amp",
- "version": "v2.5.1",
+ "version": "v2.5.2",
"source": {
"type": "git",
"url": "https://github.com/amphp/amp.git",
- "reference": "ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c"
+ "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/amphp/amp/zipball/ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c",
- "reference": "ecdc3c476b3ccff02f8e5d5bcc04f7ccfd18751c",
+ "url": "https://api.github.com/repos/amphp/amp/zipball/efca2b32a7580087adb8aabbff6be1dc1bb924a9",
+ "reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9",
"shasum": "",
"mirrors": [
{
@@ -91,7 +91,7 @@
"support": {
"irc": "irc://irc.freenode.org/amphp",
"issues": "https://github.com/amphp/amp/issues",
- "source": "https://github.com/amphp/amp/tree/v2.5.1"
+ "source": "https://github.com/amphp/amp/tree/v2.5.2"
},
"funding": [
{
@@ -99,7 +99,7 @@
"type": "github"
}
],
- "time": "2020-11-03T16:23:45+00:00"
+ "time": "2021-01-10T17:06:37+00:00"
},
{
"name": "bramus/ansi-php",
@@ -205,16 +205,16 @@
},
{
"name": "clue/socket-raw",
- "version": "v1.4.1",
+ "version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/clue/php-socket-raw.git",
- "reference": "00ab102d061f6cdb895e79dd4d69140c7bda31cc"
+ "reference": "089ffa05fa75bdc4e919aac44bbc435b3ef640ef"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/clue/php-socket-raw/zipball/00ab102d061f6cdb895e79dd4d69140c7bda31cc",
- "reference": "00ab102d061f6cdb895e79dd4d69140c7bda31cc",
+ "url": "https://api.github.com/repos/clue/php-socket-raw/zipball/089ffa05fa75bdc4e919aac44bbc435b3ef640ef",
+ "reference": "089ffa05fa75bdc4e919aac44bbc435b3ef640ef",
"shasum": "",
"mirrors": [
{
@@ -228,7 +228,7 @@
"php": ">=5.3"
},
"require-dev": {
- "phpunit/phpunit": "^7.0 || ^6.0 || ^5.2 || ^4.8.35"
+ "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
},
"type": "library",
"autoload": {
@@ -246,7 +246,7 @@
"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",
@@ -264,9 +264,19 @@
],
"support": {
"issues": "https://github.com/clue/php-socket-raw/issues",
- "source": "https://github.com/clue/php-socket-raw/tree/v1.4.1"
+ "source": "https://github.com/clue/php-socket-raw/tree/v1.5.0"
},
- "time": "2019-10-28T12:32:07+00:00"
+ "funding": [
+ {
+ "url": "https://clue.engineering/support",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2020-11-27T13:16:18+00:00"
},
{
"name": "container-interop/container-interop",
@@ -389,16 +399,16 @@
},
{
"name": "guzzlehttp/promises",
- "version": "1.4.0",
+ "version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
- "reference": "60d379c243457e073cff02bc323a2a86cb355631"
+ "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631",
- "reference": "60d379c243457e073cff02bc323a2a86cb355631",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d",
+ "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d",
"shasum": "",
"mirrors": [
{
@@ -444,22 +454,22 @@
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
- "source": "https://github.com/guzzle/promises/tree/1.4.0"
+ "source": "https://github.com/guzzle/promises/tree/1.4.1"
},
- "time": "2020-09-30T07:37:28+00:00"
+ "time": "2021-03-07T09:25:29+00:00"
},
{
"name": "guzzlehttp/psr7",
- "version": "1.7.0",
+ "version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
- "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3"
+ "reference": "35ea11d335fd638b5882ff1725228b3d35496ab1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/53330f47520498c0ae1f61f7e2c90f55690c06a3",
- "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/35ea11d335fd638b5882ff1725228b3d35496ab1",
+ "reference": "35ea11d335fd638b5882ff1725228b3d35496ab1",
"shasum": "",
"mirrors": [
{
@@ -525,22 +535,82 @@
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
- "source": "https://github.com/guzzle/psr7/tree/1.7.0"
+ "source": "https://github.com/guzzle/psr7/tree/1.8.1"
},
- "time": "2020-09-30T07:37:11+00:00"
+ "time": "2021-03-21T16:25:00+00:00"
},
{
- "name": "laminas/laminas-servicemanager",
- "version": "3.4.1",
+ "name": "klkvsk/json-decode-stream",
+ "version": "v1.0.2",
"source": {
"type": "git",
- "url": "https://github.com/laminas/laminas-servicemanager.git",
- "reference": "0d4c8628a71fae9f7bd0b1b74b76382e5e9a04b1"
+ "url": "https://github.com/klkvsk/json-decode-stream.git",
+ "reference": "76cbcd9eb9f1860293b82b4f071e76826bc90c82"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/0d4c8628a71fae9f7bd0b1b74b76382e5e9a04b1",
- "reference": "0d4c8628a71fae9f7bd0b1b74b76382e5e9a04b1",
+ "url": "https://api.github.com/repos/klkvsk/json-decode-stream/zipball/76cbcd9eb9f1860293b82b4f071e76826bc90c82",
+ "reference": "76cbcd9eb9f1860293b82b4f071e76826bc90c82",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-json": "*",
+ "php": ">=7.1"
+ },
+ "require-dev": {
+ "nyholm/psr7": "^1.3",
+ "phpunit/phpunit": "*",
+ "psr/http-message": "^1.0",
+ "vimeo/psalm": "*"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "JsonDecodeStream\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Mikhail Kulakovskiy",
+ "email": "m@klkvsk.ru"
+ }
+ ],
+ "description": "JSON streaming reader",
+ "homepage": "https://github.com/klkvsk/json-decode-stream",
+ "keywords": [
+ "decode",
+ "json",
+ "parse",
+ "stream"
+ ],
+ "support": {
+ "issues": "https://github.com/klkvsk/json-decode-stream/issues",
+ "source": "https://github.com/klkvsk/json-decode-stream/tree/v1.0.2"
+ },
+ "time": "2021-03-23T14:26:50+00:00"
+ },
+ {
+ "name": "laminas/laminas-servicemanager",
+ "version": "3.6.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/laminas/laminas-servicemanager.git",
+ "reference": "b1445e1a7077c21b0fad0974a1b7a11b9dbe0828"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/b1445e1a7077c21b0fad0974a1b7a11b9dbe0828",
+ "reference": "b1445e1a7077c21b0fad0974a1b7a11b9dbe0828",
"shasum": "",
"mirrors": [
{
@@ -553,9 +623,13 @@
"container-interop/container-interop": "^1.2",
"laminas/laminas-stdlib": "^3.2.1",
"laminas/laminas-zendframework-bridge": "^1.0",
- "php": "^5.6 || ^7.0",
+ "php": "^7.3 || ~8.0.0",
"psr/container": "^1.0"
},
+ "conflict": {
+ "laminas/laminas-code": "<3.3.1",
+ "zendframework/zend-code": "<3.3.1"
+ },
"provide": {
"container-interop/container-interop-implementation": "^1.2",
"psr/container-implementation": "^1.0"
@@ -564,27 +638,24 @@
"zendframework/zend-servicemanager": "^3.4.0"
},
"require-dev": {
+ "composer/package-versions-deprecated": "^1.0",
"laminas/laminas-coding-standard": "~1.0.0",
- "mikey179/vfsstream": "^1.6.5",
- "ocramius/proxy-manager": "^1.0 || ^2.0",
- "phpbench/phpbench": "^0.13.0",
- "phpunit/phpunit": "^5.7.25 || ^6.4.4"
+ "laminas/laminas-container-config-test": "^0.3",
+ "laminas/laminas-dependency-plugin": "^2.1",
+ "mikey179/vfsstream": "^1.6.8",
+ "ocramius/proxy-manager": "^2.2.3",
+ "phpbench/phpbench": "^1.0.0-alpha3",
+ "phpspec/prophecy-phpunit": "^2.0",
+ "phpunit/phpunit": "^9.4"
},
"suggest": {
- "laminas/laminas-stdlib": "laminas-stdlib ^2.5 if you wish to use the MergeReplaceKey or MergeRemoveKey features in Config instances",
- "ocramius/proxy-manager": "ProxyManager 1.* to handle lazy initialization of services"
+ "ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services"
},
"bin": [
"bin/generate-deps-for-config-factory",
"bin/generate-factory-for-class"
],
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.3-dev",
- "dev-develop": "4.0-dev"
- }
- },
"autoload": {
"psr-4": {
"Laminas\\ServiceManager\\": "src/"
@@ -619,20 +690,20 @@
"type": "community_bridge"
}
],
- "time": "2020-05-11T14:43:22+00:00"
+ "time": "2021-02-03T08:44:41+00:00"
},
{
"name": "laminas/laminas-stdlib",
- "version": "3.3.0",
+ "version": "3.3.1",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-stdlib.git",
- "reference": "b9d84eaa39fde733356ea948cdef36c631f202b6"
+ "reference": "d81c7ffe602ed0e6ecb18691019111c0f4bf1efe"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/b9d84eaa39fde733356ea948cdef36c631f202b6",
- "reference": "b9d84eaa39fde733356ea948cdef36c631f202b6",
+ "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/d81c7ffe602ed0e6ecb18691019111c0f4bf1efe",
+ "reference": "d81c7ffe602ed0e6ecb18691019111c0f4bf1efe",
"shasum": "",
"mirrors": [
{
@@ -651,15 +722,9 @@
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"phpbench/phpbench": "^0.17.1",
- "phpunit/phpunit": "^9.3.7"
+ "phpunit/phpunit": "~9.3.7"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.3.x-dev",
- "dev-develop": "3.4.x-dev"
- }
- },
"autoload": {
"psr-4": {
"Laminas\\Stdlib\\": "src/"
@@ -689,20 +754,20 @@
"type": "community_bridge"
}
],
- "time": "2020-08-25T09:08:16+00:00"
+ "time": "2020-11-19T20:18:59+00:00"
},
{
"name": "laminas/laminas-text",
- "version": "2.8.0",
+ "version": "2.8.1",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-text.git",
- "reference": "76fccc8f79a6fb61689e96ab300566c0065deaaa"
+ "reference": "d696fa1fb3880b9b8f02c08be58685013b421608"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-text/zipball/76fccc8f79a6fb61689e96ab300566c0065deaaa",
- "reference": "76fccc8f79a6fb61689e96ab300566c0065deaaa",
+ "url": "https://api.github.com/repos/laminas/laminas-text/zipball/d696fa1fb3880b9b8f02c08be58685013b421608",
+ "reference": "d696fa1fb3880b9b8f02c08be58685013b421608",
"shasum": "",
"mirrors": [
{
@@ -755,20 +820,20 @@
"type": "community_bridge"
}
],
- "time": "2020-10-31T13:21:17+00:00"
+ "time": "2021-02-17T21:24:58+00:00"
},
{
"name": "laminas/laminas-zendframework-bridge",
- "version": "1.1.1",
+ "version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-zendframework-bridge.git",
- "reference": "6ede70583e101030bcace4dcddd648f760ddf642"
+ "reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6ede70583e101030bcace4dcddd648f760ddf642",
- "reference": "6ede70583e101030bcace4dcddd648f760ddf642",
+ "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6cccbddfcfc742eb02158d6137ca5687d92cee32",
+ "reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32",
"shasum": "",
"mirrors": [
{
@@ -778,11 +843,13 @@
]
},
"require": {
- "php": "^5.6 || ^7.0 || ^8.0"
+ "php": "^7.3 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3",
- "squizlabs/php_codesniffer": "^3.5"
+ "psalm/plugin-phpunit": "^0.15.1",
+ "squizlabs/php_codesniffer": "^3.5",
+ "vimeo/psalm": "^4.6"
},
"type": "library",
"extra": {
@@ -821,7 +888,7 @@
"type": "community_bridge"
}
],
- "time": "2020-09-14T14:23:00+00:00"
+ "time": "2021-02-25T21:54:58+00:00"
},
{
"name": "mathieuviossat/arraytotexttable",
@@ -882,16 +949,16 @@
},
{
"name": "monolog/monolog",
- "version": "1.25.5",
+ "version": "1.26.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
- "reference": "1817faadd1846cd08be9a49e905dc68823bc38c0"
+ "reference": "2209ddd84e7ef1256b7af205d0717fb62cfc9c33"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Seldaek/monolog/zipball/1817faadd1846cd08be9a49e905dc68823bc38c0",
- "reference": "1817faadd1846cd08be9a49e905dc68823bc38c0",
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/2209ddd84e7ef1256b7af205d0717fb62cfc9c33",
+ "reference": "2209ddd84e7ef1256b7af205d0717fb62cfc9c33",
"shasum": "",
"mirrors": [
{
@@ -913,7 +980,7 @@
"graylog2/gelf-php": "~1.0",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
- "php-parallel-lint/php-parallel-lint": "^1.0",
+ "phpstan/phpstan": "^0.12.59",
"phpunit/phpunit": "~4.5",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
@@ -933,11 +1000,6 @@
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
@@ -963,7 +1025,7 @@
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
- "source": "https://github.com/Seldaek/monolog/tree/1.25.5"
+ "source": "https://github.com/Seldaek/monolog/tree/1.26.0"
},
"funding": [
{
@@ -975,7 +1037,7 @@
"type": "tidelift"
}
],
- "time": "2020-07-23T08:35:51+00:00"
+ "time": "2020-12-14T12:56:38+00:00"
},
{
"name": "phpoption/phpoption",
@@ -1054,16 +1116,16 @@
},
{
"name": "psr/container",
- "version": "1.0.0",
+ "version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
+ "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
+ "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"shasum": "",
"mirrors": [
{
@@ -1073,14 +1135,9 @@
]
},
"require": {
- "php": ">=5.3.0"
+ "php": ">=7.2.0"
},
"type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
@@ -1093,7 +1150,7 @@
"authors": [
{
"name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
+ "homepage": "https://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
@@ -1107,9 +1164,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
- "source": "https://github.com/php-fig/container/tree/master"
+ "source": "https://github.com/php-fig/container/tree/1.1.1"
},
- "time": "2017-02-14T16:28:37+00:00"
+ "time": "2021-03-05T17:36:06+00:00"
},
{
"name": "psr/http-message",
@@ -1277,17 +1334,78 @@
"time": "2019-03-08T08:55:37+00:00"
},
{
- "name": "symfony/polyfill-ctype",
- "version": "v1.20.0",
+ "name": "sven/file-config",
+ "version": "v3.1.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41"
+ "url": "https://github.com/svenluijten/file-config.git",
+ "reference": "6151381cf8b4d18beecf6605f2db64226abe58d0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41",
- "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41",
+ "url": "https://api.github.com/repos/svenluijten/file-config/zipball/6151381cf8b4d18beecf6605f2db64226abe58d0",
+ "reference": "6151381cf8b4d18beecf6605f2db64226abe58d0",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "ext-json": "*",
+ "php": "^7.1 || ^8.0"
+ },
+ "require-dev": {
+ "league/flysystem": "^2.0",
+ "phpunit/phpunit": "^7.5 || ^8.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Sven\\FileConfig\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Sven Luijten",
+ "email": "contact@svenluijten.com",
+ "homepage": "https://svenluijten.com"
+ }
+ ],
+ "description": "Store and read configuration values using files on disk",
+ "keywords": [
+ "config",
+ "configuration",
+ "env",
+ "file",
+ "flat",
+ "flatfile",
+ "json"
+ ],
+ "support": {
+ "issues": "https://github.com/svenluijten/file-config/issues",
+ "source": "https://github.com/svenluijten/file-config/tree/v3.1.0"
+ },
+ "time": "2021-01-19T12:14:40+00:00"
+ },
+ {
+ "name": "symfony/polyfill-ctype",
+ "version": "v1.22.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-ctype.git",
+ "reference": "c6c942b1ac76c82448322025e084cadc56048b4e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e",
+ "reference": "c6c942b1ac76c82448322025e084cadc56048b4e",
"shasum": "",
"mirrors": [
{
@@ -1305,7 +1423,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.20-dev"
+ "dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1343,7 +1461,7 @@
"portable"
],
"support": {
- "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0"
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1"
},
"funding": [
{
@@ -1359,20 +1477,20 @@
"type": "tidelift"
}
],
- "time": "2020-10-23T14:02:19+00:00"
+ "time": "2021-01-07T16:49:33+00:00"
},
{
"name": "symfony/polyfill-intl-idn",
- "version": "v1.20.0",
+ "version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
- "reference": "3b75acd829741c768bc8b1f84eb33265e7cc5117"
+ "reference": "2d63434d922daf7da8dd863e7907e67ee3031483"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/3b75acd829741c768bc8b1f84eb33265e7cc5117",
- "reference": "3b75acd829741c768bc8b1f84eb33265e7cc5117",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/2d63434d922daf7da8dd863e7907e67ee3031483",
+ "reference": "2d63434d922daf7da8dd863e7907e67ee3031483",
"shasum": "",
"mirrors": [
{
@@ -1392,7 +1510,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.20-dev"
+ "dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1436,7 +1554,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.20.0"
+ "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.22.1"
},
"funding": [
{
@@ -1452,20 +1570,20 @@
"type": "tidelift"
}
],
- "time": "2020-10-23T14:02:19+00:00"
+ "time": "2021-01-22T09:19:47+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
- "version": "v1.20.0",
+ "version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
- "reference": "727d1096295d807c309fb01a851577302394c897"
+ "reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/727d1096295d807c309fb01a851577302394c897",
- "reference": "727d1096295d807c309fb01a851577302394c897",
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/43a0283138253ed1d48d352ab6d0bdb3f809f248",
+ "reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248",
"shasum": "",
"mirrors": [
{
@@ -1483,7 +1601,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.20-dev"
+ "dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1526,7 +1644,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.20.0"
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.22.1"
},
"funding": [
{
@@ -1542,20 +1660,20 @@
"type": "tidelift"
}
],
- "time": "2020-10-23T14:02:19+00:00"
+ "time": "2021-01-22T09:19:47+00:00"
},
{
"name": "symfony/polyfill-php72",
- "version": "v1.20.0",
+ "version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
- "reference": "cede45fcdfabdd6043b3592e83678e42ec69e930"
+ "reference": "cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/cede45fcdfabdd6043b3592e83678e42ec69e930",
- "reference": "cede45fcdfabdd6043b3592e83678e42ec69e930",
+ "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9",
+ "reference": "cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9",
"shasum": "",
"mirrors": [
{
@@ -1570,7 +1688,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-main": "1.20-dev"
+ "dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
@@ -1608,7 +1726,7 @@
"shim"
],
"support": {
- "source": "https://github.com/symfony/polyfill-php72/tree/v1.20.0"
+ "source": "https://github.com/symfony/polyfill-php72/tree/v1.22.1"
},
"funding": [
{
@@ -1624,20 +1742,20 @@
"type": "tidelift"
}
],
- "time": "2020-10-23T14:02:19+00:00"
+ "time": "2021-01-07T16:49:33+00:00"
},
{
"name": "vlucas/phpdotenv",
- "version": "v4.1.8",
+ "version": "v4.2.0",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
- "reference": "572af79d913627a9d70374d27a6f5d689a35de32"
+ "reference": "da64796370fc4eb03cc277088f6fede9fde88482"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/572af79d913627a9d70374d27a6f5d689a35de32",
- "reference": "572af79d913627a9d70374d27a6f5d689a35de32",
+ "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/da64796370fc4eb03cc277088f6fede9fde88482",
+ "reference": "da64796370fc4eb03cc277088f6fede9fde88482",
"shasum": "",
"mirrors": [
{
@@ -1655,7 +1773,7 @@
"bamarni/composer-bin-plugin": "^1.4.1",
"ext-filter": "*",
"ext-pcre": "*",
- "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0"
+ "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20"
},
"suggest": {
"ext-filter": "Required to use the boolean validator.",
@@ -1696,7 +1814,7 @@
],
"support": {
"issues": "https://github.com/vlucas/phpdotenv/issues",
- "source": "https://github.com/vlucas/phpdotenv/tree/4.1"
+ "source": "https://github.com/vlucas/phpdotenv/tree/v4.2.0"
},
"funding": [
{
@@ -1708,7 +1826,7 @@
"type": "tidelift"
}
],
- "time": "2020-07-14T19:22:52+00:00"
+ "time": "2021-01-20T15:11:48+00:00"
}
],
"packages-dev": [],
diff --git a/conf/user.conf.example b/conf/user.conf.example
index 18b0697..1d4a3c4 100644
--- a/conf/user.conf.example
+++ b/conf/user.conf.example
@@ -18,35 +18,59 @@ COOKIE=
# 功能设置 #
#######################
-# 主站助手
-USE_MASTER_SITE=true
+# 主站每日任务(每日登录、观看、投币、分享)
+USE_MAIN_SITE=true
-# 统一活动
-USE_ACTIVE=true
-
-# 舰长总督
-USE_GUARD=true
-
-# 大乱斗
+# 直播大乱斗
USE_PK=true
+# 直播箱子实物抽奖
+USE_LIVE_BOX=true
+
+# 每日24个小心心|依赖加密心跳服务器
+USE_HEARTBEAT=true
+
+# 直播扭蛋活动抽奖|依赖加密心跳服务器
+USE_CAPSULE=true
+
+# 主站九宫格抽奖活动助手
+USE_ACTIVITY=true
+
+# 银瓜子兑换硬币
+USE_SILVER2COIN=true
+
+# 风纪委员
+USE_JUDGE=false
+
+# 直播统一活动
+USE_ACTIVE=false
+
+# 直播舰长总督
+USE_GUARD=false
+
+# 漫画助手
+USE_MANGA=false
+
+# 赛事助手
+USE_MATCH=false
+
+# 节奏风暴|丢弃率(0-100)|尝试数(范围值)
+USE_STORM=true
+STORM_DROPRATE=0
+STORM_ATTEMPT=10,20
+
+# 破产机|每日竞猜次数|每次竞猜硬币(1-10)|下注(1.压大,2.压小,3.随机)
+USE_COMPETITION=false
+COMPET_MAX_NUM=20
+COMPET_MAX_COIN=10
+COMPET_STAKE=1
+
# 天选时刻|抽取类型(0: 无限制; 1: 关注主播; 2: 粉丝勋章; 3大航海; 4用户等级;5主站等级)|自动取关(测试功能)|过滤关键词|逗号分隔
USE_ANCHOR=false
ANCHOR_UNFOLLOW=false
ANCHOR_TYPE=0,1
ANCHOR_FILTER_WORDS=
-# 实物抽奖
-USE_MO=true
-
-# 银瓜子兑换硬币
-USE_SILVER2COIN=true
-
-# 节奏风暴|丢弃率(0-100)|尝试数(范围值)
-USE_STORM=true
-STORM_DROPRATE=0
-STORM_ATTEMPT=30,50
-
# 活跃弹幕|弹幕房间(为空则随机)|弹幕内容(为空则随机)
USE_DANMU=true
DANMU_ROOMID=9522051
@@ -57,34 +81,37 @@ USE_ADD_COIN=false
ADD_COIN_MODE=random
ADD_COIN_NUM=5
-# 休眠时间|时间区间(0-23)|逗号分隔
-USE_SLEEP=true
-SLEEP_SECTION=2,3,4,5,6
-
-# 漫画助手
-USE_MANGA=false
-
-# 赛事助手
-USE_MATCH=false
-
-# 活动助手
-USE_ACTIVITY=false
-
-# 破产机|每日竞猜次数|每次竞猜硬币(1-10)|下注(1.压大,2.压小,3.随机)
-USE_COMPETITION=false
-COMPET_MAX_NUM=20
-COMPET_MAX_COIN=10
-COMPET_STAKE=1
-
-# 风纪委员
-USE_JUDGE=false
-
# 自动转发抽奖动态
AUTO_DYNAMIC = false
# 自动取关未中奖动态
CLEAR_DYNAMIC = false
# 强制清除抽奖组关注
CLEAR_GROUP_FOLLOW = false
+# 更改自动回复语言
+AUTO_REPLY_TEXT = 从未中奖,从未放弃[doge]
+
+# 休眠时间|时间区间(0-23)|逗号分隔
+USE_SLEEP=true
+SLEEP_SECTION=2,3,4,5,6
+
+#######################
+# 通知设置 #
+#######################
+
+# 消息推送|消息推送过滤词|逗号分割|优先级从上到下
+USE_NOTIFY=false
+NOTIFY_FILTER_WORDS=
+## Dingtalk机器人|token|依赖USE_NOTIFY
+NOTIFY_DINGTALK_TOKEN=
+## Tele机器人|token|chatid|依赖USE_NOTIFY
+NOTIFY_TELE_BOTTOKEN=
+NOTIFY_TELE_CHATID=
+## Pushplus酱|token|依赖USE_NOTIFY
+NOTIFY_PUSHPLUS_TOKEN=
+## Sever酱(原版)|令牌Key|依赖USE_NOTIFY
+NOTIFY_SCKEY=
+## Server酱(Turbo版)|令牌Key|依赖USE_NOTIFY
+NOTIFY_SCTKEY=
#######################
# 基础设置 #
@@ -99,14 +126,8 @@ ALONE_SERVER_KEY=
USE_ZONE_SERVER=true
ZONE_SERVER_ADDR=tcp://broadcastlv.chat.bilibili.com:2243/sub
-# SERVER酱|令牌KEY|过滤关键词|逗号分隔
-USE_SC=false
-SC_KEY=
-SC_FILTER_WORDS=
-
-# 小心心|加密服务器(开源)|
-USE_HEARTBEAT=true
-ENC_SERVER=http://116.85.43.27:3000/enc
+# 加密心跳服务器(开源)|如失效自行搭建
+ENC_SERVER=http://heartbeat-1.mudew.com:3000/enc
#######################
# 房间设置 #
@@ -140,10 +161,10 @@ NETWORK_PROXY=http://127.0.0.1:8888
#######################
# 写入日志
-APP_WRITELOG=false
+APP_WRITE_LOG=false
# 日志路径
-APP_WRITELOGPATH=log
+APP_LOG_PATH=log
# 调试模式
APP_DEBUG=false
diff --git a/data/activity_infos.json b/data/activity_infos.json
new file mode 100644
index 0000000..f17831b
--- /dev/null
+++ b/data/activity_infos.json
@@ -0,0 +1,81 @@
+{
+ "remarks": "有需要可以自己添加,或者提pr",
+ "data": [
+ {
+ "_url": "注释: 活动地址",
+ "url": "https://www.bilibili.com/blackboard/activity-S9PC.html",
+ "_title": "注释: 活动标题",
+ "title": "vivo S9系列照亮我的美",
+ "_description": "注释: 活动描述",
+ "description": "vivo S9系列照亮我的美",
+ "_sid": "注释: 活动SID",
+ "sid": "f3ae9322-817d-11eb-8597-246e966235d8",
+ "_login": "注释: 登录+1次机会",
+ "login": "true",
+ "_follow": "注释: 关注+1次机会",
+ "follow": "false",
+ "_share": "注释: 分享+1次机会",
+ "share": "true",
+ "_draw_times": "抽奖次数",
+ "draw_times": 2,
+ "_expire_at": "注释: 到期时间",
+ "expire_at": "2021-03-30 23:59:59"
+ },
+ {
+ "url": "https://www.bilibili.com/blackboard/BDF2021.html",
+ "title": "哔哩哔哩舞蹈嘉年华2021",
+ "description": "BDF2021等你来玩!活动期间每天分享页面,新增一次机会。",
+ "sid": "12a6d7e9-7813-11eb-8597-246e966235d8",
+ "login": "true",
+ "follow": "false",
+ "share": "true",
+ "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-04-15 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/activity-YxhUEb7UwQ.html",
+ "title": "种草大作战特别篇",
+ "description": "活动期间每天分享页面,新增一次机会。",
+ "sid": "0cc8ffd7-8d56-11eb-8597-246e966235d8",
+ "login": "true",
+ "follow": "false",
+ "share": "true",
+ "draw_times": 2,
+ "expire_at": "2021-01-01 11:11:11",
+ "remarks": "2021年4月02日开始,先指定为过期。"
+ },
+ {
+ "url": "https://www.bilibili.com/blackboard/activity-M22oqFLY1w.html",
+ "title": "最强搞事王",
+ "description": "活动期间每天分享页面,新增一次机会。",
+ "sid": "e168f825-8be6-11eb-8597-246e966235d8",
+ "login": "true",
+ "follow": "false",
+ "share": "true",
+ "draw_times": 1,
+ "expire_at": "2021-04-23 23:59:59"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/data/capsule_infos.json b/data/capsule_infos.json
new file mode 100644
index 0000000..fff65fb
--- /dev/null
+++ b/data/capsule_infos.json
@@ -0,0 +1,77 @@
+{
+ "pool": "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/get_pool_detail?pool_id=131&_=1616829671726",
+ "v3": "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/get_capsule_info_v3?id=79&from=web&_=1608110093802",
+ "remarks": "有需要可以自己添加,或者提pr",
+ "data": [
+ {
+ "_url": "注释: 活动地址",
+ "url": "https://www.bilibili.com/blackboard/activity-c_fu2inm-.html",
+ "_title": "注释: 活动标题",
+ "title": "原神1.4版本「风花的邀约」激励计划",
+ "_description": "注释: 活动描述",
+ "description": "每日在原神分区任意直播间观看,20分钟1张、1小时2张、2小时3张,每日最高6张。",
+ "_room_id": "注释: 活动直播间,如果为0,则取分区随机一个",
+ "room_id": 0,
+ "_area_id": "注释: 子分区id",
+ "area_id": 321,
+ "_parent_area_id": "注释: 主分区id",
+ "parent_area_id": 3,
+ "_coin_id": "注释: 抽奖id",
+ "coin_id": 112,
+ "_watch_time": "注释: 观看时长 单位秒",
+ "watch_time": 7320,
+ "_draw_times": "注释: 抽奖次数",
+ "draw_times": 1,
+ "_expire_at": "注释: 活动有效时间",
+ "expire_at": "2021-04-27 23:59:59"
+ },
+ {
+ "url": "https://www.bilibili.com/blackboard/activity-MHRISE.html",
+ "title": "《怪物猎人:崛起》直播挑战",
+ "description": "每日在怪物猎人分区任意直播间观看,10分钟1张、30分钟3张、60分钟5张",
+ "room_id": 0,
+ "area_id": 412,
+ "parent_area_id": 6,
+ "coin_id": 121,
+ "watch_time": 3720,
+ "draw_times": 9,
+ "expire_at": "2021-04-26 23:59:59"
+ },
+ {
+ "url": "https://live.bilibili.com/11218604",
+ "title": "PGI全球邀请赛",
+ "description": "每日在PGI直播间观看,10分钟1张",
+ "room_id": 11218604,
+ "area_id": 0,
+ "parent_area_id": 2,
+ "coin_id": 91,
+ "watch_time": 3720,
+ "draw_times": 6,
+ "expire_at": "2021-03-28 23:59:59"
+ },
+ {
+ "url": "https://live.bilibili.com/blackboard/2021-lpl-main.html",
+ "title": "2021LPL春季赛",
+ "description": "每日在LOL直播间观看,5分钟1张,15分钟1张",
+ "room_id": 7734200,
+ "area_id": 86,
+ "parent_area_id": 2,
+ "coin_id": 76,
+ "watch_time": 3720,
+ "draw_times": 3,
+ "expire_at": "2021-03-28 23:59:59"
+ },
+ {
+ "url": "https://live.bilibili.com/23",
+ "title": "PEL和平精英职业联赛",
+ "description": "每日在PEL直播间观看,5分钟1张",
+ "room_id": 13242892,
+ "area_id": 0,
+ "parent_area_id": 2,
+ "coin_id": 109,
+ "watch_time": 3720,
+ "draw_times": 6,
+ "expire_at": "2021-04-11 23:59:59"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/data/filter_words.json b/data/filter_words.json
new file mode 100644
index 0000000..bbe3b69
--- /dev/null
+++ b/data/filter_words.json
@@ -0,0 +1,225 @@
+{
+ "MaterialObject": {
+ "sensitive": [
+ "测试",
+ "加密",
+ "test",
+ "TEST",
+ "钓鱼",
+ "炸鱼",
+ "调试",
+ "123",
+ "1111",
+ "测试",
+ "測試",
+ "Test",
+ "测一测",
+ "ce-shi",
+ "test",
+ "T-E-S-T",
+ "lala",
+ "我是抽奖标题",
+ "压测",
+ "測一測",
+ "t-e-s-t"
+ ]
+ },
+ "Anchor": {
+ "default": [
+ "拉黑",
+ "黑名单",
+ "脸皮厚",
+ "没有奖品",
+ "无奖",
+ "脸皮厚",
+ "ceshi",
+ "测试",
+ "测试",
+ "测试",
+ "脚本",
+ "抽奖号",
+ "星段位",
+ "星段位",
+ "圣晶石",
+ "圣晶石",
+ "水晶",
+ "水晶",
+ "万兴神剪手",
+ "万兴神剪手",
+ "自付邮费",
+ "自付邮费",
+ "test",
+ "Test",
+ "TEST",
+ "加密",
+ "QQ",
+ "测试",
+ "測試",
+ "VX",
+ "vx",
+ "ce",
+ "shi",
+ "这是一个",
+ "lalall",
+ "第一波",
+ "第二波",
+ "第三波",
+ "测试用",
+ "抽奖标题",
+ "策是",
+ "房间抽奖",
+ "CESHI",
+ "ceshi",
+ "奖品A",
+ "奖品B",
+ "奖品C",
+ "硬币",
+ "无奖品",
+ "白名单",
+ "我是抽奖",
+ "0.1",
+ "五毛二",
+ "一分",
+ "一毛",
+ "0.52",
+ "0.66",
+ "0.01",
+ "0.77",
+ "0.16",
+ "照片",
+ "穷",
+ "0.5",
+ "0.88",
+ "双排",
+ "1毛",
+ "1分",
+ "1角",
+ "P口罩",
+ "素颜",
+ "写真",
+ "图包",
+ "五毛",
+ "一角",
+ "冥币",
+ "自拍",
+ "日历",
+ "0.22",
+ "加速器",
+ "越南盾",
+ "毛",
+ "分",
+ "限",
+ "0.",
+ "角",
+ "〇点",
+ "①元",
+ "一起玩",
+ "不包邮",
+ "邮费",
+ "续期卡",
+ "儿时",
+ "闪宠",
+ "大师球",
+ "一元",
+ "两元",
+ "两块",
+ "赛车",
+ "代币",
+ "一块",
+ "一局",
+ "好友位",
+ "通话",
+ "首胜",
+ "代金券",
+ "辣条",
+ "补贴",
+ "抵用券",
+ "主播素颜照",
+ "武器箱棺材板",
+ "游戏道具",
+ "优惠券",
+ "日元",
+ "发音课",
+ "壹元",
+ "零点",
+ "舰长五折券",
+ "上车",
+ "没有钱",
+ "女装",
+ "肥宅快乐水",
+ "哥斯拉",
+ "公主连结",
+ "pokemmo",
+ "宝可>梦",
+ "明日方舟",
+ "雪碧",
+ "公主连接",
+ "专属头衔",
+ "FF14",
+ "韩元",
+ "空洞骑士",
+ "老婆饼",
+ "稀世时装",
+ "洛克衣服",
+ "帮过图",
+ "证件照",
+ "自抽号",
+ "晶耀之星",
+ "伊洛纳",
+ "〇.",
+ "②元",
+ "③元",
+ "0·",
+ "繁华美化",
+ "喵喵喵",
+ "闪伊布",
+ "①圆",
+ "o点",
+ "金达摩",
+ "嗷呜",
+ "游戏位",
+ "S-追光者",
+ "OWL",
+ "勾玉",
+ "跟yo宝游戏",
+ "三元",
+ "怡宝",
+ "蛋闪迷>你冰",
+ "哥伦比亚比索",
+ "油条",
+ "代金卷",
+ "小堂包",
+ "返现券",
+ "上舰",
+ "舰长",
+ "开舰",
+ "帅照",
+ "靓照",
+ "1元红包",
+ "红包3.3元",
+ "5.2元红包",
+ "2.33元红包"
+ ]
+ },
+ "CapsuleLottery": {
+ "default": [
+ "谢谢参与",
+ "未中奖",
+ "辣条"
+ ]
+ },
+ "ActivityLottery": {
+ "default": [
+ "谢谢参与",
+ "未中奖",
+ "辣条"
+ ]
+ },
+ "Notice": {
+ "default": [
+ "谢谢参与",
+ "未中奖",
+ "辣条"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index 803addb..c977764 100644
--- a/index.php
+++ b/index.php
@@ -14,6 +14,6 @@ require 'vendor/autoload.php';
$filename = isset($argv[1]) ? $argv[1] : 'user.conf';
-$app = new BiliHelper\Core\App();
-$app->load(__DIR__, $filename);
+$app = new BiliHelper\Core\App(__DIR__);
+$app->load($filename);
$app->start();
diff --git a/src/core/App.php b/src/core/App.php
index 4c51d6a..93117f1 100644
--- a/src/core/App.php
+++ b/src/core/App.php
@@ -19,21 +19,23 @@ class App
{
/**
* App constructor.
+ * @param string $app_path
*/
- public function __construct()
+ public function __construct(string $app_path)
{
+ define('APP_CONF_PATH', $app_path . "/conf/");
+ define('APP_DATA_PATH', $app_path . "/data/");
+ define('APP_LOG_PATH', $app_path . "/log/");
(new Env())->inspect_configure()->inspect_extension();
}
/**
* @use 加载配置
- * @param $app_path
* @param string $load_file
* @return $this
*/
- public function load($app_path, $load_file = 'user.conf')
+ public function load($load_file = 'user.conf')
{
- define('APP_PATH', $app_path);
Config::load($load_file);
return $this;
}
@@ -69,12 +71,11 @@ class App
'MasterSite',
'Daily',
'ManGa',
- 'Match',
+ 'GameMatch',
'ActivityLottery',
'Competition',
'Heart',
- 'Task',
-// 'Silver',
+ 'DailyTask',
'Barrage',
'Silver2Coin',
'Judge',
@@ -92,7 +93,10 @@ class App
'AnchorRaffle',
'AwardRecord',
'Statistics',
- 'Forward'
+ 'Forward',
+ 'CapsuleLottery',
+ // 'Silver',
+
];
foreach ($plugins as $plugin) {
$this->newTask($plugin);
diff --git a/src/core/Config.php b/src/core/Config.php
index 965db0a..1b8ce99 100644
--- a/src/core/Config.php
+++ b/src/core/Config.php
@@ -49,7 +49,7 @@ class Config
*/
private static function _load($load_file)
{
- $config_path = str_replace("\\", "/", APP_PATH . "/conf/{$load_file}");
+ $config_path = str_replace("\\", "/", APP_CONF_PATH . $load_file);
if (!is_file($config_path)) {
die("配置文件 {$load_file} 加载错误,请参照文档添加配置文件!");
}
diff --git a/src/core/Curl.php b/src/core/Curl.php
index 467b65c..65f356e 100644
--- a/src/core/Curl.php
+++ b/src/core/Curl.php
@@ -153,7 +153,7 @@ class Curl
'timeout' => $timeout,
),
);
- $result = @file_get_contents($url, false, stream_context_create($options));
+ $result = $url ? @file_get_contents($url, false, stream_context_create($options)) : null;
Log::debug($result);
return $result ? $result : null;
}
@@ -243,7 +243,7 @@ class Curl
'Connection' => 'keep-alive',
// 'Content-Type' => 'application/x-www-form-urlencoded',
// 'User-Agent' => 'Mozilla/5.0 BiliDroid/5.51.1 (bbcallen@gmail.com)',
- 'User-Agent' => 'Mozilla/5.0 BiliDroid/6.17.1 (bbcallen@gmail.com) os/android model/MuMu mobi_app/android build/6171000 channel/bili innerVer/6171000 osVer/6.0.1 network/2',
+ 'User-Agent' => 'Mozilla/5.0 BiliDroid/6.20.5 (bbcallen@gmail.com) os/android model/MuMu mobi_app/android build/6205500 channel/bili innerVer/6205500 osVer/6.0.1 network/2',
// 'Referer' => 'https://live.bilibili.com/',
];
$pc_headers = [
@@ -251,11 +251,11 @@ class Curl
'Accept-Encoding' => 'gzip, deflate',
'Accept-Language' => "zh-CN,zh;q=0.9",
// 'Content-Type' => 'application/x-www-form-urlencoded',
- 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4056.0 Safari/537.36 Edg/82.0.431.0',
+ 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.30 Safari/537.36 Edg/90.0.818.8',
// 'Referer' => 'https://live.bilibili.com/',
];
$other_headers = [
- 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
+ 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4450.0 Safari/537.36',
];
$default_headers = isset(${$os . "_headers"}) ? ${$os . "_headers"} : $other_headers;
if (in_array($os, ['app', 'pc']) && getenv('COOKIE') != "") {
diff --git a/src/core/Env.php b/src/core/Env.php
index 3a0020b..49ab0a7 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.7.0.*';
+ private $app_version = '0.8.0.*';
/**
* Env constructor.
@@ -58,9 +58,9 @@ class Env
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
die("Please upgrade PHP version > 7.0.0 .");
}
- if (version_compare(PHP_VERSION, '8.0.0', '>')) {
- die("Please upgrade PHP version < 8.0.0 .");
- }
+// if (version_compare(PHP_VERSION, '8.0.0', '>')) {
+// die("Please upgrade PHP version < 8.0.0 .");
+// }
return $this;
}
}
diff --git a/src/core/Log.php b/src/core/Log.php
index d7d8dab..38b9459 100644
--- a/src/core/Log.php
+++ b/src/core/Log.php
@@ -13,7 +13,6 @@ namespace BiliHelper\Core;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Bramus\Monolog\Formatter\ColoredLineFormatter;
-use function GuzzleHttp\Psr7\str;
class Log
{
@@ -27,7 +26,7 @@ class Log
return self::$instance;
}
- protected static function configureInstance()
+ private static function configureInstance()
{
$logger = new Logger('BH');
$handler = new StreamHandler('php://stdout', getenv('APP_DEBUG') == 'true' ? Logger::DEBUG : Logger::INFO);
@@ -46,8 +45,8 @@ class Log
private static function writeLog($type, $message)
{
- if (getenv('APP_WRITELOG') == 'true') {
- $path = './' . getenv("APP_WRITELOGPATH") . '/';
+ if (getenv('APP_WRITE_LOG') == 'true') {
+ $path = './' . getenv("APP_LOG_PATH") . '/';
if (!file_exists($path)) {
mkdir($path);
chmod($path, 0777);
@@ -57,7 +56,12 @@ class Log
$data = $date . ' Log.' . $type . ' ' . $message . PHP_EOL;
file_put_contents($filename, $data, FILE_APPEND);
}
- return;
+ }
+
+ private static function backtrace(): string
+ {
+ $backtraces = debug_backtrace();
+ return "(". pathinfo(basename($backtraces[1]['file']))['filename'] . ") => ";
}
public static function debug($message, array $context = [])
@@ -68,7 +72,7 @@ class Log
public static function info($message, array $context = [])
{
- $message = self::prefix() . $message;
+ $message = self::prefix() .self::backtrace() . $message;
self::writeLog('INFO', $message);
self::getLogger()->addInfo($message, $context);
self::callback(Logger::INFO, 'INFO', $message);
@@ -76,7 +80,7 @@ class Log
public static function notice($message, array $context = [])
{
- $message = self::prefix() . $message;
+ $message = self::prefix() .self::backtrace() . $message;
self::writeLog('NOTICE', $message);
self::getLogger()->addNotice($message, $context);
self::callback(Logger::NOTICE, 'NOTICE', $message);
@@ -84,7 +88,7 @@ class Log
public static function warning($message, array $context = [])
{
- $message = self::prefix() . $message;
+ $message = self::prefix() .self::backtrace() . $message;
self::writeLog('WARNING', $message);
self::getLogger()->addWarning($message, $context);
self::callback(Logger::WARNING, 'WARNING', $message);
@@ -92,7 +96,7 @@ class Log
public static function error($message, array $context = [])
{
- $message = self::prefix() . $message;
+ $message = self::prefix() .self::backtrace() . $message;
self::writeLog('ERROR', $message);
self::getLogger()->addError($message, $context);
self::callback(Logger::ERROR, 'ERROR', $message);
diff --git a/src/plugin/ActivityLottery.php b/src/plugin/ActivityLottery.php
index c930959..98284fd 100644
--- a/src/plugin/ActivityLottery.php
+++ b/src/plugin/ActivityLottery.php
@@ -12,54 +12,111 @@ namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
+use BiliHelper\Util\AllotTasks;
use BiliHelper\Util\TimeLock;
class ActivityLottery
{
use TimeLock;
+ use AllotTasks;
- private static $activity_infos = [
- '2020SummerMusic' => [
- 'sid' => 'dd83a687-c800-11ea-8597-246e966235d8',
- 'action_types' => [3, 4], // 4 关注 3 分享
- 'referer' => 'https://www.bilibili.com/blackboard/2020SummerMusic.html',
- 'expired_time' => 1599318000, // 2020-09-05 23:00:00
- 'draw_times' => 3,
- ],
- ];
+ private static $repository = APP_DATA_PATH . 'activity_infos.json';
public static function run()
{
if (self::getLock() > time() || getenv('USE_ACTIVITY') == 'false') {
return;
}
- self::workTask();
- self::setLock(self::timing(5) + mt_rand(1, 180));
+ self::allotTasks();
+ if (self::workTask()) {
+ self::setLock(5 * 60);
+ } else {
+ self::setLock(self::timing(5) + mt_rand(1, 180));
+ }
}
/**
- * @use 运行任务
+ * @use 分配任务
+ * @return bool
+ * @throws \JsonDecodeStream\Exception\CollectorException
+ * @throws \JsonDecodeStream\Exception\ParserException
+ * @throws \JsonDecodeStream\Exception\SelectorException
+ * @throws \JsonDecodeStream\Exception\TokenizerException
+ */
+ private static function allotTasks(): bool
+ {
+ if (self::$work_status['work_updated'] == date("Y/m/d")) {
+ return false;
+ }
+ $parser = self::loadJsonData();
+ foreach ($parser->items('data[]') as $act) {
+ // 活动无效
+ if (is_null($act->sid)) {
+ continue;
+ }
+ // 活动实效过期
+ if (strtotime($act->expire_at) < time()) {
+ continue;
+ }
+ // init
+ if ($act->login == 'true') {
+ self::pushTask('login', $act);
+ }
+ // follow
+ if ($act->follow == 'true') {
+ self::pushTask('follow', $act);
+ }
+ // share
+ if ($act->share == 'true') {
+ self::pushTask('share', $act);
+ }
+ // draw_times
+ $arr = range(1, $act->draw_times);
+ foreach ($arr as $_) {
+ self::pushTask('draw', $act);
+ }
+ }
+ self::$work_status['work_updated'] = date("Y/m/d");
+ Log::info('活动抽奖任务分配完成 ' . count(self::$tasks) . ' 个任务待执行');
+ return true;
+ }
+
+ /**
+ * @use 执行任务
+ * @return bool
*/
private static function workTask()
{
- foreach (self::$activity_infos as $title => $activity) {
- // 过期
- if ($activity['expired_time'] < time()) {
- Log::info('跳过');
- continue;
- }
- Log::info("启动 {$title} 抽奖任务");
- self::initTimes($activity['sid'], $activity['referer']);
- foreach ($activity['action_types'] as $action_type) {
- sleep(1);
- self::addTimes($activity['sid'], $activity['referer'], $action_type);
- }
- foreach (range(1, $activity['draw_times']) as $num) {
- sleep(5);
- self::doLottery($activity['sid'], $activity['referer'], $num);
- }
+ if (self::$work_status['work_completed'] == date("Y/m/d")) {
+ return false;
}
+ $task = self::pullTask();
+ // 所有任务完成 标记
+ if (!$task) {
+ self::$work_status['work_completed'] = date("Y/m/d");
+ return false;
+ }
+ Log::info("执行 {$task['act']->title} #{$task['operation']} 任务");
+ // 执行任务
+ switch ($task['operation']) {
+ case 'login':
+ self::initTimes($task['act']->sid, $task['act']->url);
+ break;
+ case 'follow':
+ self::addTimes($task['act']->sid, $task['act']->url, 4);
+ break;
+ case 'share':
+ self::addTimes($task['act']->sid, $task['act']->url, 3);
+ break;
+ case 'draw':
+ self::doLottery($task['act']->sid, $task['act']->url, 0);
+ break;
+ default:
+ Log::info("当前 {$task['act']->title} #{$task['operation']} 任务不存在哦");
+ break;
+ }
+ return true;
}
@@ -81,11 +138,12 @@ class ActivityLottery
];
$raw = Curl::get('pc', $url, $payload, $headers);
$de_raw = json_decode($raw, true);
- Log::info("获取抽奖机会 {$raw}");
// {"code":0,"message":"0","ttl":1,"data":{"times":2}}
if ($de_raw['code'] == 0) {
+ Log::info("获取抽奖机会成功 {$raw}");
return true;
}
+ Log::warning("获取抽奖机会失败 {$raw}");
return false;
}
@@ -104,6 +162,7 @@ class ActivityLottery
'referer' => $referer
];
$user_info = User::parseCookies();
+ // $action_type 4 关注 3 分享
$payload = [
'sid' => $sid,
'action_type' => $action_type,
@@ -143,7 +202,10 @@ class ActivityLottery
$de_raw = json_decode($raw, true);
Log::notice("开始抽奖#{$num} {$raw}");
// {"code":0,"message":"0","ttl":1,"data":[{"id":0,"mid":4133274,"num":1,"gift_id":1152,"gift_name":"硬币x6","gift_type":0,"img_url":"https://i0.hdslb.com/bfs/activity-plat/static/b6e956937ee4aefd1e19c01283145fc0/JQ9Y9-KCm_w96_h102.png","type":5,"ctime":1596255796,"cid":0}]}
+ // {"code":0,"message":"0","ttl":1,"data":[{"id":0,"mid":4133274,"ip":0,"num":1,"gift_id":0,"gift_name":"未中奖0","gift_type":0,"img_url":"","type":1,"ctime":1616825625,"cid":0,"extra":{}}]}
if ($de_raw['code'] == 0) {
+ $result = "活动->{$referer} 获得->{$de_raw[0]['gift_name']}";
+ Notice::push('activity_lottery', $result);
return true;
}
return false;
diff --git a/src/plugin/AnchorRaffle.php b/src/plugin/AnchorRaffle.php
index ca52dd2..1845a3c 100644
--- a/src/plugin/AnchorRaffle.php
+++ b/src/plugin/AnchorRaffle.php
@@ -13,6 +13,7 @@ namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
+use BiliHelper\Util\BaseRaffle;
class AnchorRaffle extends BaseRaffle
{
@@ -129,24 +130,7 @@ class AnchorRaffle extends BaseRaffle
*/
protected static function filterPrizeWords(string $prize_name): bool
{
- $default_words = [
- '拉黑', '黑名单', '脸皮厚', '没有奖品', '无奖', '脸皮厚', 'ceshi', '测试', '测试', '测试', '脚本',
- '抽奖号', '星段位', '星段位', '圣晶石', '圣晶石', '水晶', '水晶', '万兴神剪手', '万兴神剪手',
- '自付邮费', '自付邮费', 'test', 'Test', 'TEST', '加密', 'QQ', '测试', '測試', 'VX', 'vx',
- 'ce', 'shi', '这是一个', 'lalall', '第一波', '第二波', '第三波', '测试用', '抽奖标题', '策是',
- '房间抽奖', 'CESHI', 'ceshi', '奖品A', '奖品B', '奖品C', '硬币', '无奖品', '白名单', '我是抽奖',
- '0.1', '五毛二', '一分', '一毛', '0.52', '0.66', '0.01', '0.77', '0.16', '照片', '穷', '0.5',
- '0.88', '双排', '1毛', '1分', '1角', 'P口罩', '素颜', '写真', '图包', '五毛', '一角', '冥币',
- '自拍', '日历', '0.22', '加速器', '越南盾', '毛', '分', '限', '0.', '角', '〇点', '①元',
- '一起玩', '不包邮', '邮费', '续期卡', '儿时', '闪宠', '大师球', '一元', '两元', '两块', '赛车',
- '代币', '一块', '一局', '好友位', '通话', '首胜', '代金券', '辣条', '补贴', '抵用券', '主播素颜照',
- '武器箱棺材板', '游戏道具', '优惠券', '日元', '发音课', '壹元', '零点', '舰长五折券', '上车',
- '没有钱', '女装', '肥宅快乐水', '哥斯拉', '公主连结', 'pokemmo', '宝可>梦', '明日方舟', '雪碧', '公主连接',
- '专属头衔', 'FF14', '韩元', '空洞骑士', '老婆饼', '稀世时装', '洛克衣服', '帮过图', '证件照', '自抽号',
- '晶耀之星', '伊洛纳', '〇.', '②元', '③元', '0·', '繁华美化', '喵喵喵', '闪伊布', '①圆', 'o点', '金达摩', '嗷呜',
- '游戏位', 'S-追光者', 'OWL', '勾玉', '跟yo宝游戏', '三元', '怡宝', '蛋闪迷>你冰', '哥伦比亚比索', '油条', '代金卷',
- '小堂包', '返现券', '上舰', '舰长', '开舰', '帅照', '靓照', '1元红包', '红包3.3元', '5.2元红包', '2.33元红包',
- ];
+ $default_words = self::$store->get("Anchor.default");
$custom_words = empty(getenv('ANCHOR_FILTER_WORDS')) ? [] : explode(',', getenv('ANCHOR_FILTER_WORDS'));
$total_words = array_merge($default_words, $custom_words);
foreach ($total_words as $word) {
diff --git a/src/plugin/CapsuleLottery.php b/src/plugin/CapsuleLottery.php
new file mode 100644
index 0000000..151a61f
--- /dev/null
+++ b/src/plugin/CapsuleLottery.php
@@ -0,0 +1,363 @@
+ time() || !self::init()) {
+ return;
+ }
+ self::allotTasks();
+ if (self::workTask()) {
+ self::setLock(self::$heartbeat_interval);
+ } else {
+ self::setLock(self::timing(5) + mt_rand(1, 180));
+ }
+ }
+
+ /**
+ * @use init
+ * @return bool
+ */
+ private static function init(): bool
+ {
+ if (getenv('USE_CAPSULE') == 'false' || getenv('ENC_SERVER') == '') {
+ return false;
+ }
+ if (is_null(self::$enc_server)) {
+ self::$enc_server = getenv('ENC_SERVER');
+ }
+ return true;
+ }
+
+
+ /**
+ * @use 分配任务
+ * @return bool
+ * @throws \JsonDecodeStream\Exception\CollectorException
+ * @throws \JsonDecodeStream\Exception\ParserException
+ * @throws \JsonDecodeStream\Exception\SelectorException
+ * @throws \JsonDecodeStream\Exception\TokenizerException
+ */
+ private static function allotTasks(): bool
+ {
+ if (self::$work_status['work_updated'] == date("Y/m/d")) {
+ return false;
+ }
+ $parser = self::loadJsonData();
+ foreach ($parser->items('data[]') as $act) {
+ // 活动无效
+ if (is_null($act->coin_id)) {
+ continue;
+ }
+ // 活动实效过期
+ if (strtotime($act->expire_at) < time()) {
+ continue;
+ }
+ if ($act->room_id == 0) {
+ $room_ids = Live::getAreaRoomList($act->parent_area_id, $act->area_id);
+ $act->room_id = array_shift($room_ids);
+ }
+ // 观看时间
+ self::pushTask('watch', $act, true);
+ // 抽奖次数
+ $arr = range(1, $act->draw_times);
+ foreach ($arr as $_) {
+ self::pushTask('draw', $act);
+ }
+ }
+ self::$work_status['work_updated'] = date("Y/m/d");
+ Log::info('扭蛋抽奖任务分配完成 ' . count(self::$tasks) . ' 个任务待执行');
+ return true;
+ }
+
+
+ /**
+ * @use 执行任务
+ * @return bool
+ */
+ private static function workTask()
+ {
+ if (self::$work_status['work_completed'] == date("Y/m/d")) {
+ return false;
+ }
+ $task = self::pullTask();
+ // 所有任务完成 标记
+ if (!$task) {
+ self::$work_status['work_completed'] = date("Y/m/d");
+ return false;
+ }
+ if ($task['time'] && is_null(self::$work_status['estimated_time'])) {
+ self::$work_status['estimated_time'] = time() + $task['act']->watch_time;
+ }
+ Log::info("执行 {$task['act']->title} #{$task['operation']} 任务");
+ // 执行任务
+ switch ($task['operation']) {
+ case 'watch':
+ self::heartBeat($task['act']->room_id);
+ break;
+ case 'draw':
+ self::doLottery($task['act']->coin_id, $task['act']->url, 0);
+ break;
+ default:
+ Log::info("当前 {$task['act']->title} #{$task['operation']} 任务不存在哦");
+ break;
+ }
+ return true;
+ }
+
+
+ /**
+ * @use 重置变量
+ * @param false $reset_num
+ */
+ private static function resetVar($reset_num = false)
+ {
+ self::$hb_payload = []; // 心跳请求数据
+ self::$hb_headers = []; // 心跳请求头
+ if ($reset_num) {
+ self::$hb_count_total = 0;
+ }
+ self::$hb_room_info = []; // 心跳带勋章房间信息
+ self::$hb_count = 0; // 心跳次数 max 24
+ self::$heartbeat_interval = 60; // 跳变时间
+ }
+
+
+ /**
+ * @use 心跳处理
+ * @param int $room_id
+ */
+ private static function heartBeat(int $room_id)
+ {
+ if (self::$work_room_id != $room_id) {
+ self::resetVar();
+ self::$work_room_id = $room_id;
+ }
+ if (empty(self::$hb_room_info)) {
+ self::$hb_room_info = Live::webGetRoomInfo($room_id);
+ }
+ if (!self::$hb_count) {
+ $e_data = self::eHeartBeat(self::$hb_room_info['data']['room_info']);
+ if (!$e_data['status']) {
+ // 错误级别
+ return;
+ }
+ self::$hb_count += 1;
+ self::$hb_count_total += 1;
+ self::$hb_payload = $e_data['payload'];
+ self::$hb_headers = $e_data['headers'];
+ return;
+ }
+ $x_data = self::xHeartBeat(self::$hb_count);
+ if (!$x_data['status']) {
+ // 错误级别
+ self::resetVar();
+ return;
+ }
+ self::$hb_count_total += 1;
+ self::$hb_count += 1;
+ }
+
+ /**
+ * @use E心跳
+ * @param array $room_info
+ * @param int $index
+ * @return array|bool[]
+ */
+ private static function eHeartBeat(array $room_info, $index = 0): array
+ {
+ $url = 'https://live-trace.bilibili.com/xlive/data-interface/v1/x25Kn/E';
+ $headers = [
+ 'Content-Type' => 'application/x-www-form-urlencoded',
+ 'Origin' => 'https://live.bilibili.com',
+ 'Referer' => 'https://live.bilibili.com/' . $room_info['room_id'],
+ ];
+ $user_info = User::parseCookies();
+ $payload = [
+ 'id' => json_encode([$room_info['parent_area_id'], $room_info['area_id'], $index, $room_info['room_id']], true),
+ 'device' => json_encode([
+ Generator::hash(), Generator::uuid4()
+ ], true),
+ 'ts' => time() * 1000,
+ 'is_patch' => 0,
+ 'heart_beat' => [],
+ 'ua' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0',
+ 'csrf_token' => $user_info['token'],
+ 'csrf' => $user_info['token'],
+ 'visit_id' => ''
+ ];
+ $raw = Curl::post('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ // {"code":0,"message":"0","ttl":1,"data":{"timestamp":1595342828,"heartbeat_interval":300,"secret_key":"seacasdgyijfhofiuxoannn","secret_rule":[2,5,1,4],"patch_status":2}}
+ if ($de_raw['code'] != 0) {
+ Log::warning("小心心礼物E-{$index}心跳失败");
+ return ['status' => false];
+ }
+ Log::info("小心心礼物E-{$index}心跳成功");
+ // Log::info($raw);
+ $payload['ets'] = $de_raw['data']['timestamp'];
+ $payload['secret_key'] = $de_raw['data']['secret_key'];
+ $payload['heartbeat_interval'] = $de_raw['data']['heartbeat_interval'];
+ $payload['secret_rule'] = $de_raw['data']['secret_rule'];
+ // 自动跳变时间
+ self::$heartbeat_interval = $de_raw['data']['heartbeat_interval'];
+ return [
+ 'status' => true,
+ 'payload' => $payload,
+ 'headers' => $headers,
+ ];
+ }
+
+ /**
+ * @use X心跳
+ * @param int $index
+ * @return array|bool[]
+ */
+ private static function xHeartBeat(int $index = 1): array
+ {
+ $s_data = self::encParamS($index);
+ $s = $s_data['s'];
+ $t = $s_data['payload'];
+
+ $url = 'https://live-trace.bilibili.com/xlive/data-interface/v1/x25Kn/X';
+ $user_info = User::parseCookies();
+ $payload = [
+ 's' => $s,
+ 'id' => $t['id'],
+ 'device' => $t['device'],
+ 'ets' => $t['ets'],
+ 'benchmark' => $t['benchmark'],
+ 'time' => $t['time'],
+ 'ts' => $t['ts'],
+ 'ua' => $t['ua'],
+ 'csrf_token' => $user_info['token'],
+ 'csrf' => $user_info['token'],
+ 'visit_id' => ''
+ ];
+ // print_r($payload);
+ $raw = Curl::post('pc', $url, $payload, self::$hb_headers);
+ $de_raw = json_decode($raw, true);
+ # {"code":0,"message":"0","ttl":1,"data":{"heartbeat_interval":300,"timestamp":1595346846,"secret_rule":[2,5,1,4],"secret_key":"seacasdgyijfhofiuxoannn"}}
+ if ($de_raw['code'] != 0) {
+ Log::warning("小心心礼物X-{$index}心跳失败");
+ return ['status' => false];
+ }
+ self::$hb_payload['ets'] = $de_raw['data']['timestamp'];
+ self::$hb_payload['secret_key'] = $de_raw['data']['secret_key'];
+ self::$hb_payload['heartbeat_interval'] = $de_raw['data']['heartbeat_interval'];
+ // 自动跳变时间
+ self::$heartbeat_interval = $de_raw['data']['heartbeat_interval'];
+ Log::info("小心心礼物X-{$index}心跳成功");
+ return ['status' => true];
+ }
+
+
+ /**
+ * @use 加密参数S
+ * @param int $index
+ * @return array
+ */
+ private static function encParamS(int $index): array
+ {
+ // 转换index
+ $temp = json_decode(self::$hb_payload['id'], true);
+ $temp[2] += 1;
+ self::$hb_payload['id'] = json_encode($temp, true);
+ // 加密部分
+ $payload = [
+ 't' => [
+ 'id' => self::$hb_payload['id'],
+ 'device' => self::$hb_payload['device'],
+ 'ets' => self::$hb_payload['ets'],
+ 'benchmark' => self::$hb_payload['secret_key'],
+ 'time' => self::$hb_payload['heartbeat_interval'],
+ 'ts' => time() * 1000,
+ 'ua' => self::$hb_payload['ua']
+ ],
+ 'r' => self::$hb_payload['secret_rule']
+ ];
+ $headers = [
+ 'Content-Type' => 'application/json',
+ ];
+ $data = Curl::put('other', self::$enc_server, $payload, $headers);
+ $de_raw = json_decode($data, true);
+ Log::info("S参数加密 {$de_raw['s']}");
+
+ return [
+ 's' => $de_raw['s'],
+ 'payload' => $payload['t']
+ ];
+ }
+
+ /**
+ * @use 开始抽奖
+ * @param int $coin_id
+ * @param string $referer
+ * @param int $num
+ * @return bool
+ */
+ private static function doLottery(int $coin_id, string $referer, int $num)
+ {
+ $url = 'https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id';
+ $headers = [
+ 'origin' => 'https://live.bilibili.com',
+ 'referer' => $referer
+ ];
+ $user_info = User::parseCookies();
+ $payload = [
+ 'id' => $coin_id,
+ 'count' => 1,
+ 'type' => 1,
+ 'platform' => 'web',
+ '_' => time() * 1000,
+ 'csrf' => $user_info['token'],
+ 'csrf_token' => $user_info['token'],
+ 'visit_id' => ''
+ ];
+ $raw = Curl::post('pc', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ Log::notice("开始抽奖#{$num} {$raw}");
+ // {"code":0,"message":"0","ttl":1,"data":{"status":false,"isEntity":false,"info":{"coin":1},"awards":[{"name":"谢谢参与","num":1,"text":"谢谢参与 X 1","web_url":"https://i0.hdslb.com/bfs/live/b0fccfb3bac2daae35d7e514a8f6d31530b9add2.png","mobile_url":"https://i0.hdslb.com/bfs/live/b0fccfb3bac2daae35d7e514a8f6d31530b9add2.png","usage":{"text":"很遗憾您未能中奖","url":""},"type":32,"expire":"当天","gift_type":"7290bc172e5ab9e151eb141749adb9dd","gift_value":""}],"text":["谢谢参与 X 1"],"isExCode":false}}
+ if ($de_raw['code'] == 0) {
+ $result = "活动->{$referer} 获得->{$de_raw['text'][0]}";
+ Notice::push('capsule_lottery', $result);
+ return true;
+ }
+ return false;
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/plugin/Task.php b/src/plugin/DailyTask.php
similarity index 95%
rename from src/plugin/Task.php
rename to src/plugin/DailyTask.php
index 64e2690..f07ef08 100644
--- a/src/plugin/Task.php
+++ b/src/plugin/DailyTask.php
@@ -14,7 +14,7 @@ use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
-class Task
+class DailyTask
{
use TimeLock;
@@ -71,9 +71,9 @@ class Task
$data = json_decode($data, true);
if (isset($data['code']) && $data['code']) {
- Log::warning('签到失败', ['msg' => $data['message']]);
+ Log::warning("签到失败: {$data['message']}");
} else {
- Log::info('签到成功');
+ Log::info("签到成功: {$data['text']}");
// 推送签到信息
Notice::push('todaySign', $data['message']);
}
diff --git a/src/plugin/Forward.php b/src/plugin/Forward.php
index fc12b7e..5e93fb0 100644
--- a/src/plugin/Forward.php
+++ b/src/plugin/Forward.php
@@ -1,10 +1,24 @@
'web',
+ 'parent_area_id' => $parent_area_id,
+ 'area_id' => $area_id,
+ 'sort_type' => 'sort_type_282',
+ 'page' => $page
+ ];
+ $raw = Curl::get('other', $url, $payload);
+ $de_raw = json_decode($raw, true);
+ $room_ids = [];
+
+ if ($de_raw['code'] == 0) {
+ foreach ($de_raw['data']['list'] as $room) {
+ array_push($room_ids, $room['roomid']);
+ }
+ }
+ return $room_ids;
+ }
}
diff --git a/src/plugin/Login.php b/src/plugin/Login.php
index e45d7ab..e5bfd8a 100644
--- a/src/plugin/Login.php
+++ b/src/plugin/Login.php
@@ -13,6 +13,7 @@ use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Core\Config;
use BiliHelper\Util\TimeLock;
+use BiliHelper\Tool\Common;
class Login
@@ -199,9 +200,10 @@ class Login
private static function publicKeyEnc($plaintext): string
{
Log::info('正在载入公钥');
- $url = 'https://passport.bilibili.com/api/oauth2/getKey';
+ // $url = 'https://passport.bilibili.com/api/oauth2/getKey';
+ $url = 'https://passport.bilibili.com/x/passport-login/web/key';
$payload = [];
- $data = Curl::post('app', $url, Sign::login($payload));
+ $data = Curl::get('app', $url, Sign::login($payload));
$data = json_decode($data, true);
if (isset($data['code']) && $data['code']) {
Log::error('公钥载入失败', ['msg' => $data['message']]);
@@ -209,6 +211,7 @@ class Login
} else {
Log::info('公钥载入完毕');
}
+ print_r($data);
$public_key = $data['data']['key'];
$hash = $data['data']['hash'];
openssl_public_encrypt($hash . $plaintext, $crypt, $public_key);
@@ -314,7 +317,7 @@ class Login
switch ($de_raw['code']) {
case 0:
// 二次判断
- switch ($de_raw['data']['status']){
+ switch ($de_raw['data']['status']) {
case 0:
// 正常登录
Log::info("{$mode}登录成功");
@@ -472,7 +475,7 @@ class Login
private static function saveConfig(string $key, string $value, $hide = true)
{
Config::put($key, $value);
- Log::info(" > {$key}: " . ($hide ? substr_replace($value, '********', mb_strlen($value) / 2, 8) : $value));
+ Log::info(" > {$key}: " . ($hide ? Common::replaceStar($value,4,4) : $value));
}
/**
diff --git a/src/plugin/MaterialObject.php b/src/plugin/MaterialObject.php
index b7d0f0d..0c49331 100644
--- a/src/plugin/MaterialObject.php
+++ b/src/plugin/MaterialObject.php
@@ -13,10 +13,13 @@ namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
+use BiliHelper\Util\FilterWords;
+
class MaterialObject
{
use TimeLock;
+ use FilterWords;
private static $invalid_aids = [];
private static $start_aid = 0;
@@ -24,21 +27,19 @@ class MaterialObject
public static function run()
{
- if (getenv('USE_MO') == 'false') {
+ if (getenv('USE_LIVE_BOX') == 'false') {
return;
}
self::setPauseStatus();
if (self::getLock() > time()) {
return;
}
- // TODO 优化计算AID算法
- self::calcAid(650, 850);
+ self::calcAid(700, 900);
$lottery_list = self::fetchLottery();
self::drawLottery($lottery_list);
self::setLock(mt_rand(6, 10) * 60);
}
-
/**
* @use 过滤抽奖Title
* @param string $title
@@ -46,10 +47,8 @@ class MaterialObject
*/
private static function filterTitleWords(string $title): bool
{
- $sensitive_words = [
- '测试', '加密', 'test', 'TEST', '钓鱼', '炸鱼', '调试', "123", "1111", "测试", "測試", "Test",
- "测一测", "ce-shi", "test", "T-E-S-T", "lala", "我是抽奖标题", "压测", "測一測", "t-e-s-t"
- ];
+ self::loadJsonData();
+ $sensitive_words = self::$store->get("MaterialObject.sensitive");
foreach ($sensitive_words as $word) {
if (strpos($title, $word) !== false) {
return true;
@@ -204,6 +203,7 @@ class MaterialObject
*/
private static function calcAid($min, $max): bool
{
+ // TODO 优化计算AID算法
if (self::$end_aid != 0 && self::$start_aid != 0) {
return false;
}
diff --git a/src/plugin/Notice.php b/src/plugin/Notice.php
index b2c34b2..9def721 100644
--- a/src/plugin/Notice.php
+++ b/src/plugin/Notice.php
@@ -12,15 +12,11 @@ namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
-use BiliHelper\Util\TimeLock;
+use BiliHelper\Util\FilterWords;
class Notice
{
- protected static $type = '';
- protected static $result = '';
- protected static $uname = '';
- protected static $sckey = '';
-
+ use FilterWords;
/**
* @use 推送消息
@@ -29,17 +25,14 @@ class Notice
*/
public static function push(string $type, string $result = '')
{
- if (getenv('USE_SC') == 'false' || getenv('SC_KEY') == "") {
+ if (getenv('USE_NOTIFY') == 'false') {
return;
}
- self::$type = $type;
- self::$result = $result;
- self::$sckey = getenv('SC_KEY');
- self::$uname = User::userInfo() ? getenv('APP_UNAME') : getenv('APP_USER');
if (self::filterResultWords($result)) {
return;
}
- self::sendInfoHandle();
+ $uname = User::userInfo() ? getenv('APP_UNAME') : getenv('APP_USER');
+ self::sendInfoHandle($type, $uname, $result);
}
/**
@@ -49,8 +42,9 @@ class Notice
*/
private static function filterResultWords(string $result): bool
{
- $default_words = [];
- $custom_words = empty(getenv('SC_FILTER_WORDS')) ? [] : explode(',', getenv('SC_FILTER_WORDS'));
+ self::loadJsonData();
+ $default_words = self::$store->get("Notice.default");;
+ $custom_words = empty(getenv('NOTIFY_FILTER_WORDS')) ? [] : explode(',', getenv('NOTIFY_FILTER_WORDS'));
$total_words = array_merge($default_words, $custom_words);
foreach ($total_words as $word) {
if (strpos($result, $word) !== false) {
@@ -60,97 +54,252 @@ class Notice
return false;
}
+
/**
* @use 处理信息
+ * @param string $type
+ * @param string $uname
+ * @param string $result
* @return bool
*/
- private static function sendInfoHandle(): bool
+ private static function sendInfoHandle(string $type, string $uname, string $result): bool
{
$now_time = date('Y-m-d H:i:s');
- switch (self::$type) {
+ switch ($type) {
case 'update':
$info = [
'title' => '程序更新通知',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 程序更新通知' . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 程序更新通知: {$result}"
];
break;
case 'anchor':
$info = [
'title' => '天选时刻获奖记录',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 在天选时刻中获得: ' . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 在天选时刻中获得: {$result}"
];
break;
case 'raffle':
$info = [
'title' => '实物奖励获奖纪录',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 在实物奖励中获得: ' . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 在实物奖励中获得: {$result}"
];
break;
case 'gift':
$info = [
'title' => '活动礼物获奖纪录',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 在活动礼物中获得: ' . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 在活动礼物中获得: {$result}"
];
break;
case 'storm':
$info = [
'title' => '节奏风暴获奖纪录',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 在节奏风暴中获得: ' . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 在节奏风暴中获得: {$result}"
];
break;
case 'cookieRefresh':
$info = [
'title' => 'Cookie刷新',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 刷新Cookie: ' . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 刷新Cookie: {$result}"
];
break;
case 'todaySign':
$info = [
'title' => '每日签到',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 签到: ' . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 签到: {$result}"
];
break;
case 'banned':
$info = [
'title' => '任务小黑屋',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 小黑屋: ' . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 小黑屋: {$result}"
];
break;
case 'error':
$info = [
- 'title' => '程序错误',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 程序运行错误: ' . self::$result,
+ 'title' => '程序运行错误',
+ 'content' => "[{$now_time}] 用户: {$uname} 错误详情: {$result}"
];
break;
case 'key_expired':
$info = [
'title' => '监控KEY异常',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 监控KEY到期或者错误,请及时查错或续期后重试哦~',
+ 'content' => "[{$now_time}] 用户: {$uname} 监控KEY到期或者错误,请及时查错或续期后重试哦~"
+ ];
+ break;
+ case 'capsule_lottery':
+ $info = [
+ 'title' => '直播扭蛋抽奖活动',
+ 'content' => "[{$now_time}] 用户: {$uname} 详情: {$result}"
+ ];
+ break;
+ case 'activity_lottery':
+ $info = [
+ 'title' => '主站九宫格抽奖活动',
+ 'content' => "[{$now_time}] 用户: {$uname} 详情: {$result}"
];
break;
default:
$info = [
'title' => '推送消息异常记录',
- 'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 推送消息key错误' . self::$type . self::$result,
+ 'content' => "[{$now_time}] 用户: {$uname} 推送消息key错误: {$type}->{$result}"
];
break;
}
- self::scSend($info);
+ self::sendLog($info);
return true;
}
+ /**
+ * @use 推送消息
+ * @param array $info
+ */
+ private static function sendLog(array $info)
+ {
+ if (getenv('NOTIFY_SCTKEY')) {
+ self::sctSend($info);
+ }
+ if (getenv('NOTIFY_SCKEY')) {
+ self::scSend($info);
+ }
+ if (getenv('NOTIFY_TELE_BOTTOKEN') && getenv('NOTIFY_TELE_CHATID')) {
+ self::teleSend($info);
+ }
+ if (getenv('NOTIFY_DINGTALK_TOKEN')) {
+ self::dingTalkSend($info);
+ }
+ if (getenv('NOTIFY_PUSHPLUS_TOKEN')) {
+ self::pushPlusSend($info);
+ }
+ }
+
/**
- * @use ServerChan发送信息
+ * @use 钉钉bot推送
+ * @doc https://developers.dingtalk.com/document/app/document-upgrade-notice#/serverapi2/qf2nxq
+ * @param array $info
+ */
+ private static function dingTalkSend(array $info)
+ {
+ Log::info('使用DingTalk机器人推送消息');
+ $url = 'https://oapi.dingtalk.com/robot/send?access_token=' . getenv('NOTIFY_DINGTALK_TOKEN');
+ $payload = [
+ 'msgtype' => 'markdown',
+ 'markdown' => [
+ 'title' => $info['title'],
+ 'content' => $info['content'],
+ ]
+ ];
+ $headers = [
+ 'Content-Type' => 'application/json;charset=utf-8'
+ ];
+ $raw = Curl::put('other', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ if ($de_raw['errcode'] == 0) {
+ Log::info("推送消息成功: {$de_raw['errmsg']}");
+ } else {
+ Log::warning("推送消息失败: {$raw}");
+ }
+ }
+
+
+ /**
+ * @use TeleBot推送
+ * @doc https://core.telegram.org/bots/api#sendmessage
+ * @param array $info
+ */
+ private static function teleSend(array $info)
+ {
+ Log::info('使用Tele机器人推送消息');
+ $url = 'https://api.telegram.org/bot' . getenv('NOTIFY_TELE_BOTTOKEN');
+ $payload = [
+ 'method' => 'sendMessage',
+ 'chat_id' => getenv('NOTIFY_TELE_CHATID'),
+ 'text' => $info['content']
+ ];
+ $raw = Curl::post('other', $url, $payload);
+ $de_raw = json_decode($raw, true);
+ if (array_key_exists('message_id', $de_raw)) {
+ Log::info("推送消息成功: {$de_raw['message_id']}");
+ } else {
+ Log::info("推送消息失败: {$raw}");
+ }
+ }
+
+
+ /**
+ * @use ServerChan推送
+ * @use https://sc.ftqq.com/
* @param array $info
*/
private static function scSend(array $info)
{
- $url = "https://sc.ftqq.com/" . self::$sckey . ".send?text=" . urlencode($info['title']) . "&desp=" . urlencode($info['content']);
- $data = Curl::request('get', $url);
- if (is_null($data)) {
- Log::warning('Server酱推送信息失败,请检查!');
- };
+ Log::info('使用ServerChan推送消息');
+ $url = 'https://sc.ftqq.com/' . getenv('NOTIFY_SCKEY') . '.send';
+ $payload = [
+ 'text' => $info['title'],
+ 'desp' => $info['content'],
+ ];
+ $raw = Curl::post('other', $url, $payload);
+ $de_raw = json_decode($raw, true);
+
+ if ($de_raw['errno'] == 0) {
+ Log::info("推送消息成功: {$de_raw['errmsg']}");
+ } else {
+ Log::warning("推送消息失败: {$raw}");
+ }
}
+
+
+ /**
+ * @use ServerChan(Turbo)推送
+ * @doc https://sct.ftqq.com/
+ * @param array $info
+ */
+ private static function sctSend(array $info)
+ {
+ Log::info('使用ServerChan(Turbo)推送消息');
+ $url = 'https://sctapi.ftqq.com/' . getenv('NOTIFY_SCTKEY') . '.send';
+ $payload = [
+ 'text' => $info['title'],
+ 'desp' => $info['content'],
+ ];
+ $raw = Curl::post('other', $url, $payload);
+ $de_raw = json_decode($raw, true);
+ // {'message': '[AUTH]用户不存在或者权限不足', 'code': 40001, 'info': '用户不存在或者权限不足', 'args': [None]}
+ // {'code': 0, 'message': '', 'data': {'pushid': 'xxxx', 'readkey': 'xxxxx', 'error': 'SUCCESS', 'errno': 0}}
+ if ($de_raw['code'] == 0) {
+ Log::info("推送消息成功: {$de_raw['data']['pushid']}");
+ } else {
+ Log::warning("推送消息失败: {$raw}");
+ }
+ }
+
+ /**
+ * @use PushPlus酱推送
+ * @doc http://pushplus.hxtrip.com/doc/
+ * @param array $info
+ */
+ private static function pushPlusSend(array $info)
+ {
+ Log::info('使用PushPlus酱推送消息');
+ $url = 'http://pushplus.hxtrip.com/send';
+ $payload = [
+ 'token' => getenv('NOTIFY_PUSHPLUS_TOKEN'),
+ 'title' => $info['title'],
+ 'content' => $info['content']
+ ];
+ $headers = [
+ 'Content-Type' => 'application/json'
+ ];
+ $raw = Curl::put('other', $url, $payload, $headers);
+ $de_raw = json_decode($raw, true);
+ if ($de_raw['code'] == 200) {
+ Log::info("推送消息成功: {$de_raw['data']}");
+ } else {
+ Log::warning("推送消息失败: {$raw}");
+ }
+ }
+
+
}
\ No newline at end of file
diff --git a/src/plugin/PkRaffle.php b/src/plugin/PkRaffle.php
index 952d708..55271d8 100644
--- a/src/plugin/PkRaffle.php
+++ b/src/plugin/PkRaffle.php
@@ -13,6 +13,7 @@ namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
+use BiliHelper\Util\BaseRaffle;
class PkRaffle extends BaseRaffle
diff --git a/src/plugin/Schedule.php b/src/plugin/Schedule.php
index 5e4dfeb..680a420 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', 'ManGa', 'Match', 'GroupSignIn', 'AwardRecord', 'Statistics'];
+ private static $fillable = ['Login', 'Schedule', 'Daily', 'Judge', 'MasterSite', 'GiftSend', 'DailyTask', 'Silver2Coin', 'ManGa', 'GameMatch', 'GroupSignIn', 'AwardRecord', 'Statistics'];
// 任务类
private static $guarded_first = ['Barrage', 'GiftHeart', 'Silver', 'MaterialObject'];
// 监控类
@@ -32,6 +32,8 @@ class Schedule
private static $guarded_third = ['StormRaffle', 'GuardRaffle', 'PkRaffle', 'GiftRaffle', 'AnchorRaffle'];
// 特殊 老爷处理
private static $guarded_fourth = ['Heart'];
+ // 暂定不做处理,后期看情况再定
+ private static $release = ['ActivityLottery', 'SmallHeart', 'Competition', 'SmallHeart', 'Forward', 'CapsuleLottery'];
public static function run()
{
diff --git a/src/plugin/Sign.php b/src/plugin/Sign.php
index 3ff225f..fca7219 100644
--- a/src/plugin/Sign.php
+++ b/src/plugin/Sign.php
@@ -55,8 +55,8 @@ class Sign
'access_key' => getenv('ACCESS_TOKEN'),
'actionKey' => 'appkey',
'appkey' => $appkey,
- 'build' => 6030600,
- 'channel'=>'bili',
+ 'build' => 6205500,
+ 'channel' => 'bili',
'device' => 'phone',
'mobi_app' => 'android',
'platform' => 'android',
@@ -84,7 +84,7 @@ class Sign
'access_key' => getenv('ACCESS_TOKEN'),
'actionKey' => 'appkey',
'appkey' => $appkey,
- 'build' => 5511400,
+ 'build' => 6205500,
'device' => 'android',
'mobi_app' => 'android',
'platform' => 'android',
diff --git a/src/plugin/Silver2Coin.php b/src/plugin/Silver2Coin.php
index d737236..64a3a9c 100644
--- a/src/plugin/Silver2Coin.php
+++ b/src/plugin/Silver2Coin.php
@@ -46,7 +46,7 @@ class Silver2Coin
if (!$de_raw['code'] && $de_raw['msg'] == '兑换成功') {
Log::info('[APP]银瓜子兑换硬币: ' . $de_raw['msg']);
} elseif ($de_raw['code'] == 403) {
- Log::info('[APP]银瓜子兑换硬币: ' . $de_raw['msg']);
+ Log::warning('[APP]银瓜子兑换硬币: ' . $de_raw['msg']);
} else {
Log::warning('[APP]银瓜子兑换硬币: ' . $de_raw['msg']);
return false;
diff --git a/src/plugin/SmallHeart.php b/src/plugin/SmallHeart.php
index 4915d2d..fae39ac 100644
--- a/src/plugin/SmallHeart.php
+++ b/src/plugin/SmallHeart.php
@@ -13,7 +13,6 @@ namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
-use BiliHelper\Tool\Faker;
use BiliHelper\Util\TimeLock;
use BiliHelper\Tool\Generator;
@@ -131,10 +130,10 @@ class SmallHeart
}
if (empty(self::$hb_room_info)) {
$metal = self::$fans_medals[array_rand(self::$fans_medals)];
- $room_info = Live::webGetRoomInfo($metal['roomid']);
+ self::$hb_room_info = Live::webGetRoomInfo($metal['roomid']);
}
if (self::$hb_count == 0) {
- $e_data = self::eHeartBeat($room_info['data']['room_info']);
+ $e_data = self::eHeartBeat(self::$hb_room_info['data']['room_info']);
if (!$e_data['status']) {
// 错误级别
return;
diff --git a/src/plugin/StormRaffle.php b/src/plugin/StormRaffle.php
index 151b91d..e1a86f2 100644
--- a/src/plugin/StormRaffle.php
+++ b/src/plugin/StormRaffle.php
@@ -13,6 +13,7 @@ namespace BiliHelper\Plugin;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
+use BiliHelper\Util\BaseRaffle;
class StormRaffle extends BaseRaffle
{
diff --git a/src/plugin/ZoneTcpClient.php b/src/plugin/ZoneTcpClient.php
index 47d5d78..2d6bc8c 100644
--- a/src/plugin/ZoneTcpClient.php
+++ b/src/plugin/ZoneTcpClient.php
@@ -495,15 +495,17 @@ class ZoneTcpClient
throw new Exception("Socket error: [{$ret}] [{$length}]");
}
$cnt = 0;
- $r = array($socket);
$w = NULL;
$e = NULL;
while ($cnt++ < 60) {
+ // reset read fdset when timeout
+ $r = array($socket);
$ret = socket_select($r, $w, $e, 1);
if ($ret === false)
throw new Exception("Socket error: ret == false");
if ($ret)
break;
+ Log::debug("Socket debug: select timeout" . PHP_EOL);
}
// TODO unable to read from socket[104]: Connection reset by peer
$ret = socket_recv($socket, $buffer, $length, 0);
diff --git a/src/tool/Common.php b/src/tool/Common.php
new file mode 100644
index 0000000..0738cd4
--- /dev/null
+++ b/src/tool/Common.php
@@ -0,0 +1,52 @@
+ $len) {
+ $start = 1;
+ }
+ if ($end != 0 && $end > $len) {
+ $end = $len - 2;
+ }
+ $endStart = $len - $end;
+ $top = mb_substr($str, 0, $start, $charset);
+ $bottom = "";
+ if ($endStart > 0) {
+ $bottom = mb_substr($str, $endStart, $end, $charset);
+ }
+ $len = $len - mb_strlen($top, $charset);
+ $len = $len - mb_strlen($bottom, $charset);
+ $newStr = $top;
+ for ($i = 0; $i < $len; $i++) {
+ $newStr .= $dot;
+ }
+ $newStr .= $bottom;
+ return $newStr;
+ }
+
+
+}
+
+
diff --git a/src/tool/File.php b/src/tool/File.php
new file mode 100644
index 0000000..30abcb8
--- /dev/null
+++ b/src/tool/File.php
@@ -0,0 +1,274 @@
+ basename($filename),
+ "文件类型" => filetype($filename),
+ "文件大小" => trans_byte(filesize($filename)),
+ "创建时间" => date('Y-m-d H:i:s', filectime($filename)),
+ "修改时间" => date('Y-m-d H:i:s', filemtime($filename)),
+ "上一次访问时间" => date('Y-m-d H:i:s', fileatime($filename)),
+ ];
+ }
+
+
+ /**
+ * @use 转换字节大小
+ * @param int $byte 字节大小
+ * @param int $precision 小数点保留位数
+ * @return string 转换后的单位
+ */
+ public static function transByte(int $byte, $precision = 2): string
+ {
+ $kb = 1024;
+ $mb = 1024 * $kb;
+ $gb = 1024 * $mb;
+ $tb = 1024 * $gb;
+
+ if ($byte < $kb) {
+ return $byte . 'B';
+ }
+
+ if ($byte < $mb) {
+ // 默认四舍五入, 保留两位小数
+ return round($byte / $kb, $precision) . ' KB';
+ }
+
+ if ($byte < $gb) {
+ return round($byte / $mb, $precision) . ' MB';
+ }
+
+ if ($byte < $tb) {
+ return round($byte / $tb, $precision) . ' GB';
+ }
+ }
+
+
+ /**
+ * @use 以字符串形式读取内容
+ * @param string $filename
+ * @return false|string
+ */
+ public static function readString(string $filename)
+ {
+ if (is_file($filename) && is_readable($filename)) {
+ return file_get_contents($filename);
+ }
+ return false;
+ }
+
+
+ /**
+ * @use 以数组形式读取内容
+ * @param string $filename
+ * @param bool $skip_empty_lines
+ * @return array|false
+ */
+ public static function readArray(string $filename, bool $skip_empty_lines = false)
+ {
+ if (is_file($filename) && is_readable($filename)) {
+ if ($skip_empty_lines) {
+ // 忽略空行读取
+ return file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ } else {
+ // 以数组形式直接读取, 不忽略空行
+ return file($filename);
+ }
+ }
+ }
+
+
+ /**
+ * @use 增加文件内容升级版
+ * @param string $filename 路径名称
+ * @param mixed $data 需要写入的数据
+ * @param boolean $clear_content 是否清空原始内容再写入
+ * @return bool true|false
+ */
+ public static function write(string $filename, $data, bool $clear_content = false)
+ {
+ $dirname = dirname($filename);
+ // 检测目标路径是否存在
+ if (!file_exists($dirname)) {
+ mkdir($dirname, 0777, true);
+ }
+ // 文件存在并且不清空原始文件
+ if (is_file($filename) && !$clear_content) {
+ $srcData = file_get_contents($filename);
+ }
+
+ // 检测数据是否为数组或者对象
+ if (is_array($data) || is_object($data)) {
+ // 序列化数据
+ $data = serialize($data);
+ }
+ // 拼装数据
+ $data = $srcData . $data;
+ // 写入数据
+ if (file_put_contents($filename, $data) !== false) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @use 截断文本
+ * @param string $filename 文件名称
+ * @param int $length 截断文本长度
+ * @return boolean true|false
+ */
+ public static function truncate(string $filename, int $length): bool
+ {
+ // 判断文件是否存在并且是可写的
+ if (is_file($filename) && is_writeable($filename)) {
+ // 创建文件句柄, 以读写方式打开
+ $handler = fopen($filename, 'rb+');
+ $length = $length < 0 ? 0 : $length;
+ ftruncate($handler, $length);
+ fclose($handler);
+ }
+ return false;
+ }
+
+}
diff --git a/src/util/AllotTasks.php b/src/util/AllotTasks.php
new file mode 100644
index 0000000..8602049
--- /dev/null
+++ b/src/util/AllotTasks.php
@@ -0,0 +1,92 @@
+ null,
+ 'estimated_time' => null,
+ 'work_completed' => null,
+ ];
+
+
+ /**
+ * @use 加载json数据
+ * @return Parser
+ */
+ protected static function loadJsonData()
+ {
+ return Parser::fromFile(static::$repository);
+ }
+
+ /**
+ * @use 提交任务
+ * @param string $operation
+ * @param \stdClass $act
+ * @param bool $time
+ * @return bool
+ */
+ protected static function pushTask(string $operation, \stdClass $act, bool $time = false): bool
+ {
+ $task = [
+ 'operation' => $operation,
+ 'act' => $act,
+ 'time' => false
+ ];
+ if ($time) {
+ $task['time'] = $time;
+ }
+ array_push(static::$tasks, $task);
+ return true;
+ }
+
+ /**
+ * @use 拉取任务
+ * @return false|mixed
+ */
+ protected static function pullTask()
+ {
+ // 任务列表为空
+ if (empty(static::$tasks)) {
+ return false;
+ }
+ // 先进先出 弹出一个任务
+ $task = array_shift(static::$tasks);
+ if ($task['time']) {
+ if (is_null(static::$work_status['estimated_time']) || time() < intval(static::$work_status['estimated_time'])) {
+ array_unshift(static::$tasks, $task);
+ }
+ }
+ return $task;
+ }
+
+
+
+// /**
+// * @use 执行任务
+// * @return bool
+// */
+// abstract protected function workTask(): bool;
+//
+//
+// /**
+// * @use 分配任务
+// * @return bool
+// */
+// abstract protected function allotTasks(): bool;
+}
diff --git a/src/plugin/BaseRaffle.php b/src/util/BaseRaffle.php
similarity index 98%
rename from src/plugin/BaseRaffle.php
rename to src/util/BaseRaffle.php
index 7e1149d..eaf2374 100644
--- a/src/plugin/BaseRaffle.php
+++ b/src/util/BaseRaffle.php
@@ -9,13 +9,14 @@
* Updated: 2021 ~ 2022
*/
-namespace BiliHelper\Plugin;
+namespace BiliHelper\Util;
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
abstract class BaseRaffle
{
+ use FilterWords;
const ACTIVE_TITLE = '';
const ACTIVE_SWITCH = '';
@@ -33,6 +34,7 @@ abstract class BaseRaffle
return;
}
static::setPauseStatus();
+ static::loadJsonData();
static::startLottery();
}
diff --git a/src/util/FilterWords.php b/src/util/FilterWords.php
new file mode 100644
index 0000000..2bd744d
--- /dev/null
+++ b/src/util/FilterWords.php
@@ -0,0 +1,39 @@
+