From 279bfcf959b7ac93f3333400839cb0c101105bec Mon Sep 17 00:00:00 2001 From: lkeme <1462364497@qq.com> Date: Wed, 16 Jun 2021 17:26:26 +0800 Subject: [PATCH] [add] Task --- .gitignore | 9 +- CHANGELOG.md | 24 ++- README.md | 70 ++++---- composer.json | 1 - composer.lock | 302 ++++------------------------------ src/core/App.php | 1 + src/core/Config.php | 111 +++++++------ src/core/Curl.php | 2 +- src/core/Task.php | 104 ++++++++++++ src/plugin/AloneTcpClient.php | 6 +- src/plugin/Barrage.php | 2 +- src/plugin/GiftSend.php | 4 +- src/plugin/Sign.php | 4 +- src/util/TimeLock.php | 16 +- task/.gitkeep | 0 15 files changed, 286 insertions(+), 370 deletions(-) create mode 100644 src/core/Task.php create mode 100644 task/.gitkeep diff --git a/.gitignore b/.gitignore index 418f31d..c598a49 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,11 @@ conf/user1.ini /conf/test.ini /conf/test1.ini /log/ -/src/backup/ \ No newline at end of file +/src/backup/ + +# ignore all files in lib/ +task/* +# except for .gitkeep +!.gitkeep +# ignore TODO file in root directory,not subdir/TODO +/TODO \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ab65e2f..8fc3c1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 961e752..78edf41 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@

- + @@ -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 | 直播银瓜子自动开启宝箱 | ## 交流反馈 diff --git a/composer.json b/composer.json index f1a7956..05d380a 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 62f4a6e..8deaef9 100644 --- a/composer.lock +++ b/composer.lock @@ -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" } diff --git a/src/core/App.php b/src/core/App.php index 1a8b1dd..25ccbae 100644 --- a/src/core/App.php +++ b/src/core/App.php @@ -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/"); } /** diff --git a/src/core/Config.php b/src/core/Config.php index 7f9266f..627034c 100644 --- a/src/core/Config.php +++ b/src/core/Config.php @@ -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(); - - } } \ No newline at end of file diff --git a/src/core/Curl.php b/src/core/Curl.php index 6833b83..f1ac25a 100644 --- a/src/core/Curl.php +++ b/src/core/Curl.php @@ -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 = [ diff --git a/src/core/Task.php b/src/core/Task.php new file mode 100644 index 0000000..5f6a4b4 --- /dev/null +++ b/src/core/Task.php @@ -0,0 +1,104 @@ + $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('直播间信息生成完毕!'); diff --git a/src/plugin/Sign.php b/src/plugin/Sign.php index 2f4c4a3..cc245ea 100644 --- a/src/plugin/Sign.php +++ b/src/plugin/Sign.php @@ -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', diff --git a/src/util/TimeLock.php b/src/util/TimeLock.php index 19137e5..eace2fe 100644 --- a/src/util/TimeLock.php +++ b/src/util/TimeLock.php @@ -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; } /** diff --git a/task/.gitkeep b/task/.gitkeep new file mode 100644 index 0000000..e69de29