[add] Task

This commit is contained in:
Lkeme 2021-06-16 17:26:26 +08:00
parent ad3263da30
commit b77940801d
15 changed files with 286 additions and 370 deletions

9
.gitignore vendored
View File

@ -27,4 +27,11 @@ conf/user1.ini
/conf/test.ini
/conf/test1.ini
/log/
/src/backup/
/src/backup/
# ignore all files in lib/
task/*
# except for .gitkeep
!.gitkeep
# ignore TODO file in root directory,not subdir/TODO
/TODO

View File

@ -2,6 +2,28 @@
# 本项目Log
## v0.9.3.210616 alpha (2021-06-16)
### Added
- 任务排程
-
### Changed
- 配置热更新
-
### Fixed
- 修复弹幕
- 修复独立监控
-
### Remarks
-
## v0.9.2.210602 alpha (2021-06-02)
### Added
@ -20,7 +42,7 @@
### Remarks
--
-
## v0.9.1.210518 alpha (2021-05-18)

View File

@ -15,7 +15,7 @@
<p align="center">
<img src="https://img.shields.io/badge/Version-0.9.2.210602-orange.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/Version-0.9.3.210616-orange.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/PHP-7.3+-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge">
@ -37,40 +37,40 @@
| plugin | status | version | description |
|-----------------|--------|----------|---------------------------------------------|
| CheckUpdate | true | 21.06.02 | 程序检查更新 |
| Login | true | 21.06.02 | 账号登录、刷新、维持 |
| Schedule | true | 21.06.02 | 控制插件运行周期 |
| MainSite | true | 21.06.02 | 投币、观看、分享视频 (速升6级不是梦) |
| DailyBag | true | 21.06.02 | 双端领取日常/周常礼包 |
| ManGa | true | 21.06.02 | 漫画签到、分享 |
| ActivityLottery | true | 21.06.02 | 主站活动九宫格抽奖 |
| Competition | true | 21.06.02 | 游戏赛事竞猜 |
| DoubleHeart | true | 21.06.02 | 双端心跳 (姥爷直播经验) |
| DailyTask | true | 21.06.02 | 直播每日任务(签到、观看) |
| Barrage | true | 21.06.02 | 保持活跃弹幕 |
| Silver2Coin | true | 21.06.02 | 银瓜子兑换硬币 |
| Judge | true | 21.06.02 | 风纪委员投票 |
| GiftSend | true | 21.06.02 | 礼物赠送、维持每日勋章亲密度 |
| GroupSignIn | true | 21.06.02 | 友爱社签到 |
| GiftHeart | true | 21.06.02 | 日常心跳每日礼包礼物 |
| SmallHeart | true | 21.06.02 | 直播挂机每日24个小心心 |
| MaterialObject | true | 21.06.02 | 直播金色宝箱实物抽奖 |
| AloneTcpClient | true | 21.06.02 | 作者的独立直播监控(可支持本项目哦) |
| ZoneTcpClient | true | 21.06.02 | 官方的分区直播监控 |
| StormRaffle | true | 21.06.02 | 直播节奏风暴抽奖、亿元 |
| GiftRaffle | true | 21.06.02 | 直播礼物抽奖 |
| PkRaffle | true | 21.06.02 | 直播大乱斗抽奖 |
| GuardRaffle | true | 21.06.02 | 直播大航海抽奖 |
| AnchorRaffle | true | 21.06.02 | 直播天选时刻抽奖 |
| GiftRaffle | true | 21.06.02 | 直播礼物抽奖 |
| AwardRecord | true | 21.06.02 | 最新的中奖纪录通知 |
| Forward | true | 21.06.02 | 主站动态抽奖转发 |
| CapsuleLottery | true | 21.06.02 | 直播扭蛋活动抽奖 |
| PolishTheMedal | true | 21.06.02 | 每日自动点亮灰色勋章 |
| CapsuleLottery | true | 21.06.02 | 直播扭蛋活动抽奖 |
| VipPrivilege | true | 21.06.02 | 每月领取年度大会员特权(B币券、会员购优惠券) |
| BpConsumption | true | 21.06.02 | 每月消费使用年度大会员特权的B币券 |
| Statistics | true | 21.06.02 | 全局抽奖结果统计 |
| CheckUpdate | true | 21.06.16 | 程序检查更新 |
| Login | true | 21.06.16 | 账号登录、刷新、维持 |
| Schedule | true | 21.06.16 | 控制插件运行周期 |
| MainSite | true | 21.06.16 | 投币、观看、分享视频 (速升6级不是梦) |
| DailyBag | true | 21.06.16 | 双端领取日常/周常礼包 |
| ManGa | true | 21.06.16 | 漫画签到、分享 |
| ActivityLottery | true | 21.06.16 | 主站活动九宫格抽奖 |
| Competition | true | 21.06.16 | 游戏赛事竞猜 |
| DoubleHeart | true | 21.06.16 | 双端心跳 (姥爷直播经验) |
| DailyTask | true | 21.06.16 | 直播每日任务(签到、观看) |
| Barrage | true | 21.06.16 | 保持活跃弹幕 |
| Silver2Coin | true | 21.06.16 | 银瓜子兑换硬币 |
| Judge | true | 21.06.16 | 风纪委员投票 |
| GiftSend | true | 21.06.16 | 礼物赠送、维持每日勋章亲密度 |
| GroupSignIn | true | 21.06.16 | 友爱社签到 |
| GiftHeart | true | 21.06.16 | 日常心跳每日礼包礼物 |
| SmallHeart | true | 21.06.16 | 直播挂机每日24个小心心 |
| MaterialObject | true | 21.06.16 | 直播金色宝箱实物抽奖 |
| AloneTcpClient | true | 21.06.16 | 作者的独立直播监控(可支持本项目哦) |
| ZoneTcpClient | true | 21.06.16 | 官方的分区直播监控 |
| StormRaffle | true | 21.06.16 | 直播节奏风暴抽奖、亿元 |
| GiftRaffle | true | 21.06.16 | 直播礼物抽奖 |
| PkRaffle | true | 21.06.16 | 直播大乱斗抽奖 |
| GuardRaffle | true | 21.06.16 | 直播大航海抽奖 |
| AnchorRaffle | true | 21.06.16 | 直播天选时刻抽奖 |
| GiftRaffle | true | 21.06.16 | 直播礼物抽奖 |
| AwardRecord | true | 21.06.16 | 最新的中奖纪录通知 |
| Forward | true | 21.06.16 | 主站动态抽奖转发 |
| CapsuleLottery | true | 21.06.16 | 直播扭蛋活动抽奖 |
| PolishTheMedal | true | 21.06.16 | 每日自动点亮灰色勋章 |
| CapsuleLottery | true | 21.06.16 | 直播扭蛋活动抽奖 |
| VipPrivilege | true | 21.06.16 | 每月领取年度大会员特权(B币券、会员购优惠券) |
| BpConsumption | true | 21.06.16 | 每月消费使用年度大会员特权的B币券 |
| Statistics | true | 21.06.16 | 全局抽奖结果统计 |
| Silver | false | 21.03.27 | 直播银瓜子自动开启宝箱 |
## 交流反馈

View File

@ -13,7 +13,6 @@
"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",

302
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e70802004e3c9d66674b79cba60e91ad",
"content-hash": "224c6b1ce9f6f5220d3de9434a44da42",
"packages": [
{
"name": "amphp/amp",
@ -1081,16 +1081,16 @@
},
{
"name": "monolog/monolog",
"version": "1.26.0",
"version": "1.26.1",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "2209ddd84e7ef1256b7af205d0717fb62cfc9c33"
"reference": "c6b00f05152ae2c9b04a448f99c7590beb6042f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/2209ddd84e7ef1256b7af205d0717fb62cfc9c33",
"reference": "2209ddd84e7ef1256b7af205d0717fb62cfc9c33",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/c6b00f05152ae2c9b04a448f99c7590beb6042f5",
"reference": "c6b00f05152ae2c9b04a448f99c7590beb6042f5",
"shasum": "",
"mirrors": [
{
@ -1157,7 +1157,7 @@
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/1.26.0"
"source": "https://github.com/Seldaek/monolog/tree/1.26.1"
},
"funding": [
{
@ -1169,82 +1169,7 @@
"type": "tidelift"
}
],
"time": "2020-12-14T12:56:38+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.7.5",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/php-option.git",
"reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/994ecccd8f3283ecf5ac33254543eb0ac946d525",
"reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.5.9 || ^7.0 || ^8.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0 || ^8.0 || ^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
}
},
"autoload": {
"psr-4": {
"PhpOption\\": "src/PhpOption/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com"
}
],
"description": "Option Type for PHP",
"keywords": [
"language",
"option",
"php",
"type"
],
"support": {
"issues": "https://github.com/schmittjoh/php-option/issues",
"source": "https://github.com/schmittjoh/php-option/tree/1.7.5"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
"type": "tidelift"
}
],
"time": "2020-07-20T17:29:33+00:00"
"time": "2021-05-28T08:32:12+00:00"
},
{
"name": "psr/container",
@ -1526,103 +1451,18 @@
},
"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": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.1"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-07T16:49:33+00:00"
},
{
"name": "symfony/polyfill-intl-idn",
"version": "v1.22.1",
"version": "v1.23.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
"reference": "2d63434d922daf7da8dd863e7907e67ee3031483"
"reference": "65bd267525e82759e7d8c4e8ceea44f398838e65"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/2d63434d922daf7da8dd863e7907e67ee3031483",
"reference": "2d63434d922daf7da8dd863e7907e67ee3031483",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/65bd267525e82759e7d8c4e8ceea44f398838e65",
"reference": "65bd267525e82759e7d8c4e8ceea44f398838e65",
"shasum": "",
"mirrors": [
{
@ -1642,7 +1482,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
"dev-main": "1.23-dev"
},
"thanks": {
"name": "symfony/polyfill",
@ -1686,7 +1526,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.22.1"
"source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.23.0"
},
"funding": [
{
@ -1702,20 +1542,20 @@
"type": "tidelift"
}
],
"time": "2021-01-22T09:19:47+00:00"
"time": "2021-05-27T09:27:20+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
"version": "v1.22.1",
"version": "v1.23.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
"reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248"
"reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/43a0283138253ed1d48d352ab6d0bdb3f809f248",
"reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8",
"reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8",
"shasum": "",
"mirrors": [
{
@ -1733,7 +1573,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
"dev-main": "1.23-dev"
},
"thanks": {
"name": "symfony/polyfill",
@ -1776,7 +1616,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.22.1"
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0"
},
"funding": [
{
@ -1792,20 +1632,20 @@
"type": "tidelift"
}
],
"time": "2021-01-22T09:19:47+00:00"
"time": "2021-02-19T12:13:01+00:00"
},
{
"name": "symfony/polyfill-php72",
"version": "v1.22.1",
"version": "v1.23.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
"reference": "cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9"
"reference": "9a142215a36a3888e30d0a9eeea9766764e96976"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9",
"reference": "cc6e6f9b39fe8075b3dabfbaf5b5f645ae1340c9",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976",
"reference": "9a142215a36a3888e30d0a9eeea9766764e96976",
"shasum": "",
"mirrors": [
{
@ -1820,7 +1660,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
"dev-main": "1.23-dev"
},
"thanks": {
"name": "symfony/polyfill",
@ -1858,7 +1698,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php72/tree/v1.22.1"
"source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0"
},
"funding": [
{
@ -1874,91 +1714,7 @@
"type": "tidelift"
}
],
"time": "2021-01-07T16:49:33+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v4.2.0",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "da64796370fc4eb03cc277088f6fede9fde88482"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/da64796370fc4eb03cc277088f6fede9fde88482",
"reference": "da64796370fc4eb03cc277088f6fede9fde88482",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.5.9 || ^7.0 || ^8.0",
"phpoption/phpoption": "^1.7.3",
"symfony/polyfill-ctype": "^1.17"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"ext-filter": "*",
"ext-pcre": "*",
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20"
},
"suggest": {
"ext-filter": "Required to use the boolean validator.",
"ext-pcre": "Required to use most of the library."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
}
},
"autoload": {
"psr-4": {
"Dotenv\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"homepage": "https://gjcampbell.co.uk/"
},
{
"name": "Vance Lucas",
"email": "vance@vancelucas.com",
"homepage": "https://vancelucas.com/"
}
],
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
"keywords": [
"dotenv",
"env",
"environment"
],
"support": {
"issues": "https://github.com/vlucas/phpdotenv/issues",
"source": "https://github.com/vlucas/phpdotenv/tree/v4.2.0"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
"type": "tidelift"
}
],
"time": "2021-01-20T15:11:48+00:00"
"time": "2021-05-27T09:17:38+00:00"
}
],
"packages-dev": [],
@ -1977,5 +1733,5 @@
"ext-mbstring": "*"
},
"platform-dev": [],
"plugin-api-version": "2.0.0"
"plugin-api-version": "2.1.0"
}

View File

@ -24,6 +24,7 @@ class App
define('APP_CONF_PATH', $app_path . "/conf/");
define('APP_DATA_PATH', $app_path . "/data/");
define('APP_LOG_PATH', $app_path . "/log/");
define('APP_TASK_PATH', $app_path . "/task/");
}
/**

View File

@ -15,8 +15,71 @@ use Jelix\IniFile\IniModifier;
class Config
{
private static $app_config;
private static $load_file;
private static $last_time;
private static $config_path;
private static $instance;
private static function getInstance(): Config
{
if (is_null(self::$instance)) {
self::$instance = new static;
}
return self::$instance;
}
/**
* @use 加载配置
* @param string $load_file
*/
public static function load(string $load_file)
{
$config_path = str_replace("\\", "/", APP_CONF_PATH . $load_file);
if (!is_file($config_path)) {
die("配置文件 {$load_file} 加载错误,请参照文档添加配置文件!");
}
// 给静态参数赋值
self::$load_file = $load_file;
self::$config_path = $config_path;
// $config_path = dirname($config_path).DIRECTORY_SEPARATOR.$load_file;
self::$app_config = new IniModifier(self::$config_path);
self::$last_time = fileatime(self::$config_path);
}
public static function _set($name, $value, $section = 0, $key = null)
{
$_instance = self::getInstance();
$_instance::$app_config->setValue($name, $value, $section, $key);
$_instance::$app_config->save();
// 保存修改时间
$_instance::$last_time = fileatime($_instance::$config_path);
}
public static function _get($name, $section = 0, $key = null)
{
$_instance = self::getInstance();
// 判断是否被修改 重新加载文件
// echo $_instance::$last_time.PHP_EOL;
// echo fileatime($_instance::$config_path);
if (fileatime($_instance::$config_path) != $_instance::$last_time) {
$_instance::load($_instance::$load_file);
}
return $_instance::$app_config->getValue($name, $section, $key);
}
public static function _put()
{
$_instance = self::getInstance();
}
public static function _del()
{
$_instance = self::getInstance();
}
/**
* 不允许从外部调用以防止创建多个实例
* 要使用单例,必须通过 Singleton::getInstance() 方法获取实例
@ -39,52 +102,4 @@ class Config
{
}
private static function getInstance(): Config
{
if (is_null(self::$instance)) {
self::$instance = new static;
}
return self::$instance;
}
/**
* @use 加载配置
* @param string $load_file
*/
public static function load(string $load_file)
{
$config_path = str_replace("\\", "/", APP_CONF_PATH . $load_file);
if (!is_file($config_path)) {
die("配置文件 {$load_file} 加载错误,请参照文档添加配置文件!");
}
// $config_path = dirname($config_path).DIRECTORY_SEPARATOR.$load_file;
self::$app_config = new IniModifier($config_path);
}
public static function _set($name, $value, $section = 0, $key = null)
{
$_instance = self::getInstance();
$_instance::$app_config->setValue($name, $value, $section, $key);
$_instance::$app_config->save();
}
public static function _get($name, $section = 0, $key = null)
{
$_instance = self::getInstance();
return $_instance::$app_config->getValue($name, $section, $key);
}
public static function _put()
{
$_instance = self::getInstance();
}
public static function _del()
{
$_instance = self::getInstance();
}
}

View File

@ -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.25.0 (bbcallen@gmail.com) os/android model/MuMu mobi_app/android build/6250300 channel/bili innerVer/6250300 osVer/6.0.1 network/2',
'User-Agent' => 'Mozilla/5.0 BiliDroid/6.28.0 (bbcallen@gmail.com) os/android model/MuMu mobi_app/android build/6280300 channel/bili innerVer/6280300 osVer/6.0.1 network/2',
// 'Referer' => 'https://live.bilibili.com/',
];
$pc_headers = [

104
src/core/Task.php Normal file
View File

@ -0,0 +1,104 @@
<?php
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2021 ~ 2022
*/
namespace BiliHelper\Core;
class Task
{
private static $init = true;
private static $repository = null;
private static $instance;
/**
* @use 单例
* @return \BiliHelper\Core\Task
*/
public static function getInstance(): Task
{
if (is_null(self::$instance)) {
self::$instance = new static;
}
return self::$instance;
}
/**
* @use 初始化
*/
private static function init()
{
if (self::$init) {
// 赋值仓库地址
if (is_null(self::$repository)) {
self::$repository = APP_TASK_PATH . 'tasks_' . getConf('username', 'login.account') . '.json';
}
// 仓库不存在自动创建
if (!file_exists(self::$repository)) {
$fh = fopen(self::$repository, "w");
fwrite($fh, "{}");
fclose($fh);
Log::info('任务排程文件不存在,初始化所有任务。');
} else {
Log::info('任务排程文件存在,继续执行所有任务。');
}
}
// 限制初始化
self::$init = false;
}
/**
* @use
* @return array
*/
private static function read(): array
{
self::init();
$data = file_get_contents(self::$repository);
return json_decode($data, true);
}
/**
* @use
* @param array $data
* @return bool
*/
private static function write(array $data): bool
{
self::init();
return file_put_contents(self::$repository, json_encode($data));
}
/**
* @use 写入
* @param string $class
* @param int $lock
* @return bool
*/
public static function _setLock(string $class, int $lock): bool
{
$data = self::read();
$data[$class] = $lock;
return self::write($data);
}
/**
* @use 读取
* @param string $class
* @return int
*/
public static function _getLock(string $class): int
{
$data = self::read();
if (array_key_exists($class, $data)) {
return $data[$class];
}
return 0;
}
}

View File

@ -211,8 +211,8 @@ class AloneTcpClient
Log::debug("(len=$len_body)");
$body = self::reader($len_body);
$raw_data = json_decode($body, true);
// 人气值(或者在线人数或者类似)以及心跳
$data_type = $raw_data['type'];
// 数据可能出现不全 DECODE返回NULL 索引错误 交给default处理
$data_type = is_null($raw_data) ? "unknown" : $raw_data['type'];
switch ($data_type) {
case 'raffle':
// 抽奖推送
@ -259,6 +259,8 @@ class AloneTcpClient
// 未知信息
var_dump($raw_data);
Log::info("出现未知信息 {$body}");
// 出现未知信息 处理重连 防止内存益处
self::reConnect();
break;
}
}

View File

@ -45,8 +45,8 @@ class Barrage
*/
$punctuations = $sep ? ['', ',', '。', '!', '.', ';', '——'] : [];
$apis = [
'https://api.ly522.com/yan.php?format=text',
'https://v1.hitokoto.cn/?encode=text',
'https://api.ly522.com/Api/YiYan?format=text',
'https://api.jysafe.cn/yy/',
'https://api.imjad.cn/hitokoto/',
'https://www.ly522.com/hitokoto/',

View File

@ -207,7 +207,7 @@ class GiftSend
if (isset($data['code']) && $data['code']) {
Log::warning('获取帐号信息失败!', ['msg' => $data['message']]);
Log::warning('清空礼物功能禁用!');
self::$lock = time() + 100000000;
self::setLock(100000000);
return;
}
self::$uid = $data['data']['uid'];
@ -224,7 +224,7 @@ class GiftSend
if (isset($data['code']) && $data['code']) {
Log::warning('获取主播房间号失败!', ['msg' => $data['message']]);
Log::warning('清空礼物功能禁用!');
self::$lock = time() + 100000000;
self::setLock(100000000);
return;
}
Log::info('直播间信息生成完毕!');

View File

@ -55,7 +55,7 @@ class Sign
'access_key' => getConf('access_token', 'login.auth'),
'actionKey' => 'appkey',
'appkey' => $appkey,
'build' => 6250300,
'build' => 6280300,
'channel' => 'bili',
'device' => 'phone',
'mobi_app' => 'android',
@ -84,7 +84,7 @@ class Sign
'access_key' => getConf('access_token', 'login.auth'),
'actionKey' => 'appkey',
'appkey' => $appkey,
'build' => 6250300,
'build' => 6280300,
'device' => 'phone',
'mobi_app' => 'android',
'platform' => 'android',

View File

@ -11,6 +11,7 @@
namespace BiliHelper\Util;
use Amp\Delayed;
use BiliHelper\Core\Task;
use BiliHelper\Plugin\Schedule;
trait TimeLock
@ -25,7 +26,7 @@ trait TimeLock
public static function setLock(int $lock)
{
if (!static::getpauseStatus()) {
static::$lock = time() + $lock;
Task::getInstance()::_setLock(static::getBaseClass(), time() + $lock);
}
}
@ -35,7 +36,16 @@ trait TimeLock
*/
public static function getLock(): int
{
return static::$lock;
return Task::getInstance()::_getLock(static::getBaseClass());
}
/**
* @use 获取基础CLASS NAME
* @return string
*/
public static function getBaseClass(): string
{
return basename(str_replace('\\', '/', __CLASS__));
}
/**
@ -104,7 +114,7 @@ trait TimeLock
*/
public static function cancelPause()
{
static::$lock = false;
static::$pause_status = false;
}
/**

0
task/.gitkeep Normal file
View File