mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 01:20:08 +08:00
[fix(*)] Parameter
This commit is contained in:
parent
1f4eb53473
commit
bf8398bc3b
@ -88,7 +88,7 @@ class App
|
||||
* @param string $taskName
|
||||
* @param string $dir
|
||||
*/
|
||||
private function newTask(string $taskName, string $dir)
|
||||
private function newTask(string $taskName, string $dir): void
|
||||
{
|
||||
asyncCall(function () use ($taskName, $dir) {
|
||||
while (true) {
|
||||
@ -111,7 +111,7 @@ class App
|
||||
/**
|
||||
* @use Script模式
|
||||
*/
|
||||
private function script_m()
|
||||
private function script_m(): void
|
||||
{
|
||||
$scripts = [
|
||||
'UnFollow' => '批量取消关注(暂测试)',
|
||||
@ -125,7 +125,7 @@ class App
|
||||
/**
|
||||
* @use Loop模式
|
||||
*/
|
||||
private function loop_m()
|
||||
private function loop_m(): void
|
||||
{
|
||||
$plugins = [
|
||||
'CheckUpdate',
|
||||
@ -174,7 +174,7 @@ class App
|
||||
* @use 选择模式
|
||||
* @param object $args
|
||||
*/
|
||||
private function selectMode(object $args)
|
||||
private function selectMode(object $args): void
|
||||
{
|
||||
// 可能会有其他模式出现 暂定
|
||||
// 0 默认值 默认模式,1 脚本模式 ...
|
||||
@ -187,7 +187,7 @@ class App
|
||||
* @use 复位模式
|
||||
* @param object $args
|
||||
*/
|
||||
private function restoreMode(object $args)
|
||||
private function restoreMode(object $args): void
|
||||
{
|
||||
// 复位 后期添加其他复位
|
||||
if ($args->restore) {
|
||||
@ -199,7 +199,7 @@ class App
|
||||
/**
|
||||
* @use 核心运行
|
||||
*/
|
||||
public function start()
|
||||
public function start(): void
|
||||
{
|
||||
switch ($this->mode) {
|
||||
case 0:
|
||||
@ -213,8 +213,7 @@ class App
|
||||
$this->script_m();
|
||||
break;
|
||||
default:
|
||||
Log::error("请检查,没有选定的执行模式");
|
||||
exit();
|
||||
Env::failExit('请检查,没有选定的执行模式');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ class BCommand
|
||||
$this->argv = $argv;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run(): Command
|
||||
{
|
||||
$cli = new Command('BHP-S', 'BHP命令行工具.');
|
||||
$cli->version('0.0.1-dev')
|
||||
@ -36,8 +36,7 @@ class BCommand
|
||||
try {
|
||||
$args = $cli->parse($this->argv);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
die('解析命令行参数错误');
|
||||
Env::failExit('解析命令行参数错误', ['msg' => $e->getMessage()]);
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class Cache
|
||||
/**
|
||||
* @use 加载一个缓存
|
||||
* @param string $classname
|
||||
* @return \BiliHelper\Core\Cache
|
||||
* @return Cache
|
||||
*/
|
||||
private function load(string $classname): static
|
||||
{
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
namespace BiliHelper\Core;
|
||||
|
||||
use BiliHelper\Util\Singleton;
|
||||
use Jelix\IniFile\IniException;
|
||||
use Jelix\IniFile\IniModifier;
|
||||
|
||||
class Config
|
||||
@ -27,11 +28,11 @@ class Config
|
||||
* @use 加载配置
|
||||
* @param string $load_file
|
||||
*/
|
||||
public function load(string $load_file)
|
||||
public function load(string $load_file): void
|
||||
{
|
||||
$config_path = str_replace("\\", "/", APP_CONF_PATH . $load_file);
|
||||
if (!is_file($config_path)) {
|
||||
die("配置文件 $load_file 加载错误,请参照文档添加配置文件!");
|
||||
Env::failExit("配置文件 $load_file 加载错误,请参照文档添加配置文件!");
|
||||
}
|
||||
$this->load_file = $load_file;
|
||||
$this->config_path = $config_path;
|
||||
@ -47,9 +48,9 @@ class Config
|
||||
* @param $value
|
||||
* @param int|string $section
|
||||
* @param null $key
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
public function _set($name, $value, int|string $section = 0, $key = null)
|
||||
public function _set($name, $value, int|string $section = 0, $key = null): void
|
||||
{
|
||||
$this->app_config->setValue($name, $value, $section, $key);
|
||||
$this->app_config->save();
|
||||
|
||||
@ -165,7 +165,7 @@ class Curl
|
||||
/**
|
||||
* @use 计数搭配并发使用
|
||||
*/
|
||||
private static function countedAndCheckEnded()
|
||||
private static function countedAndCheckEnded(): void
|
||||
{
|
||||
if (self::$async_opt['counter'] < self::$async_opt['count']) {
|
||||
self::$async_opt['counter']++;
|
||||
@ -201,7 +201,7 @@ class Curl
|
||||
Log::warning("CURl -> RETRY: $retry ERROR: {$e->getMessage()} ERRNO: {$e->getCode()} STATUS: Waiting for recovery!");
|
||||
sleep(15);
|
||||
}
|
||||
exit('网络异常,超出最大尝试次数,退出程序~');
|
||||
Env::failExit('网络异常,超出最大尝试次数,退出程序~');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -37,7 +37,7 @@ class Device
|
||||
/**
|
||||
* @use 加载配置
|
||||
*/
|
||||
public function load(string $load_file)
|
||||
public function load(string $load_file): void
|
||||
{
|
||||
// 提前处理 后缀
|
||||
$custom_file = str_replace(strrchr($load_file, "."), "", $load_file) . '_';
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
namespace BiliHelper\Core;
|
||||
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
use function JBZoo\Data\json;
|
||||
|
||||
class Env
|
||||
@ -40,7 +41,7 @@ class Env
|
||||
/**
|
||||
* @use 检查扩展
|
||||
*/
|
||||
public function inspect_extension()
|
||||
public function inspect_extension(): void
|
||||
{
|
||||
$default_extensions = ['curl', 'openssl', 'sockets', 'json', 'zlib', 'mbstring'];
|
||||
foreach ($default_extensions as $extension) {
|
||||
@ -62,13 +63,10 @@ class Env
|
||||
Log::info("使用说明请移步 $this->app_source 查看");
|
||||
|
||||
if (PHP_SAPI != 'cli') {
|
||||
die("Please run this script from command line .");
|
||||
Env::failExit('Please run this script from command line .');
|
||||
}
|
||||
// if (version_compare(PHP_VERSION, '7.4.0', '<')) {
|
||||
// die("Please upgrade PHP version > 7.4.0 .");
|
||||
// }
|
||||
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||
die("Please upgrade PHP version < 8.0.0 .");
|
||||
Env::failExit('Please upgrade PHP version < 8.0.0 .');
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@ -76,7 +74,7 @@ class Env
|
||||
/**
|
||||
* @use 加载本地JSON DATA
|
||||
*/
|
||||
private function loadJsonData()
|
||||
private function loadJsonData(): void
|
||||
{
|
||||
$conf = json($this->repository);
|
||||
$this->app_name = $conf->get('project', 'BiliHelper-personal');
|
||||
@ -84,4 +82,46 @@ class Env
|
||||
$this->app_branch = $conf->get('branch', 'master');
|
||||
$this->app_source = $conf->get('source', 'https://github.com/lkeme/BiliHelper-personal');
|
||||
}
|
||||
|
||||
/**
|
||||
* @use Check: running in docker?
|
||||
* @return bool
|
||||
*/
|
||||
public static function isDocker(): bool
|
||||
{
|
||||
// Win直接跳出
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
return false;
|
||||
}
|
||||
if (!file_exists('/.dockerenv')) {
|
||||
return false;
|
||||
}
|
||||
// 检查/proc/1/cgroup内是否包含"docker"等字符串;
|
||||
if (!is_file('/proc/self/cgroup') || !preg_match('%^\d+:\w+:/(docker|actions_job)/' . preg_quote(gethostname(), '%') . '\w+%sm', file_get_contents('/proc/self/cgroup'))) {
|
||||
return false;
|
||||
}
|
||||
// $processStack = explode(PHP_EOL, shell_exec('cat /proc/self/cgroup | grep docker'));
|
||||
// $processStack = array_filter($processStack);
|
||||
// return count($processStack) > 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @use 错误退出
|
||||
* @param $message
|
||||
* @param array $context
|
||||
* @param int $delay
|
||||
* @return void
|
||||
*/
|
||||
#[NoReturn]
|
||||
public static function failExit($message, array $context = [],int $delay = 60 * 2): void
|
||||
{
|
||||
Log::error($message, $context);
|
||||
// 如果在docker环境中,延迟退出,方便查看错误
|
||||
if (self::isDocker()) {
|
||||
// 暂停两分钟后自动退出
|
||||
sleep($delay);
|
||||
}
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
use BiliHelper\Core\Cache;
|
||||
use BiliHelper\Core\Config;
|
||||
use BiliHelper\Core\Device;
|
||||
use Jelix\IniFile\IniException;
|
||||
|
||||
/**
|
||||
* @use 配置读取
|
||||
@ -30,9 +31,9 @@ function getConf($name, int|string $section = 0, $key = null): mixed
|
||||
* @param $value
|
||||
* @param int|string $section
|
||||
* @param null $key
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
function setConf($name, $value, int|string $section = 0, $key = null)
|
||||
function setConf($name, $value, int|string $section = 0, $key = null): void
|
||||
{
|
||||
Config::getInstance()->_set($name, $value, $section, $key);
|
||||
}
|
||||
@ -121,7 +122,7 @@ function getCache(string $key, string $extra_name = ''): mixed
|
||||
* @param $data
|
||||
* @param string $extra_name
|
||||
*/
|
||||
function setCache(string $key, $data, string $extra_name = '')
|
||||
function setCache(string $key, $data, string $extra_name = ''): void
|
||||
{
|
||||
Cache::getInstance()->_set($key, $data, $extra_name);
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class Log
|
||||
/**
|
||||
* @use 单例
|
||||
*/
|
||||
private static function configureInstance()
|
||||
private static function configureInstance(): void
|
||||
{
|
||||
$logger = new Logger('BH');
|
||||
$handler = new StreamHandler('php://stdout', getConf('enable', 'debug') ? Logger::DEBUG : Logger::INFO);
|
||||
@ -59,7 +59,7 @@ class Log
|
||||
* @param $type
|
||||
* @param $message
|
||||
*/
|
||||
private static function writeLog($type, $message)
|
||||
private static function writeLog($type, $message): void
|
||||
{
|
||||
if (getConf('enable', 'log')) {
|
||||
if ($type == 'DEBUG' && !getConf('enable', 'debug')) {
|
||||
@ -88,7 +88,7 @@ class Log
|
||||
* @param $message
|
||||
* @param array $context
|
||||
*/
|
||||
public static function debug($message, array $context = [])
|
||||
public static function debug($message, array $context = []): void
|
||||
{
|
||||
self::writeLog('DEBUG', $message);
|
||||
self::getLogger()->addDebug($message, $context);
|
||||
@ -99,7 +99,7 @@ class Log
|
||||
* @param $message
|
||||
* @param array $context
|
||||
*/
|
||||
public static function info($message, array $context = [])
|
||||
public static function info($message, array $context = []): void
|
||||
{
|
||||
$message = self::prefix() . self::backtrace() . $message;
|
||||
self::writeLog('INFO', $message);
|
||||
@ -112,7 +112,7 @@ class Log
|
||||
* @param $message
|
||||
* @param array $context
|
||||
*/
|
||||
public static function notice($message, array $context = [])
|
||||
public static function notice($message, array $context = []): void
|
||||
{
|
||||
$message = self::prefix() . self::backtrace() . $message;
|
||||
self::writeLog('NOTICE', $message);
|
||||
@ -125,7 +125,7 @@ class Log
|
||||
* @param $message
|
||||
* @param array $context
|
||||
*/
|
||||
public static function warning($message, array $context = [])
|
||||
public static function warning($message, array $context = []): void
|
||||
{
|
||||
$message = self::prefix() . self::backtrace() . $message;
|
||||
self::writeLog('WARNING', $message);
|
||||
@ -138,7 +138,7 @@ class Log
|
||||
* @param $message
|
||||
* @param array $context
|
||||
*/
|
||||
public static function error($message, array $context = [])
|
||||
public static function error($message, array $context = []): void
|
||||
{
|
||||
$message = self::prefix() . self::backtrace() . $message;
|
||||
self::writeLog('ERROR', $message);
|
||||
@ -152,7 +152,7 @@ class Log
|
||||
* @param $level
|
||||
* @param $message
|
||||
*/
|
||||
public static function callback($levelId, $level, $message)
|
||||
public static function callback($levelId, $level, $message): void
|
||||
{
|
||||
// $callback_level = Logger::ERROR ?? getConf('callback_level', 'log');
|
||||
$callback_level = getConf('callback_level', 'log') ?? Logger::ERROR;
|
||||
|
||||
@ -22,7 +22,7 @@ class Task
|
||||
/**
|
||||
* @use 初始化
|
||||
*/
|
||||
protected function init()
|
||||
protected function init(): void
|
||||
{
|
||||
// 赋值仓库地址
|
||||
if ($this->repository == '') {
|
||||
@ -89,7 +89,7 @@ class Task
|
||||
/**
|
||||
* @use 复位
|
||||
*/
|
||||
public function restore()
|
||||
public function restore(): void
|
||||
{
|
||||
Log::info('复位任务排程文件。');
|
||||
File::del($this->repository);
|
||||
|
||||
@ -25,7 +25,7 @@ class ActivityLottery
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('main_activity')) {
|
||||
return;
|
||||
|
||||
@ -10,27 +10,29 @@
|
||||
|
||||
namespace BiliHelper\Plugin;
|
||||
|
||||
use BiliHelper\Core\Env;
|
||||
use BiliHelper\Core\Log;
|
||||
use BiliHelper\Util\TimeLock;
|
||||
|
||||
use Exception;
|
||||
use Socket\Raw\Factory;
|
||||
use Socket\Raw\Socket;
|
||||
|
||||
class AloneTcpClient
|
||||
{
|
||||
use TimeLock;
|
||||
|
||||
private static int $heart_lock = 0;
|
||||
private static $client = null;
|
||||
private static $server_addr = null;
|
||||
private static $server_key = null;
|
||||
private static ?Socket $client = null;
|
||||
private static string|null $server_addr = null;
|
||||
private static string|null $server_key = null;
|
||||
private static int $socket_timeout = 0;
|
||||
private static int $max_errors_num = 0; // 最大连续错误5次
|
||||
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('alone_monitor')) {
|
||||
return;
|
||||
@ -44,10 +46,10 @@ class AloneTcpClient
|
||||
/**
|
||||
* @use 初始化
|
||||
*/
|
||||
private static function init()
|
||||
private static function init(): void
|
||||
{
|
||||
if (empty(getConf('server_addr', 'alone_monitor')) || empty(getConf('server_key', 'alone_monitor'))) {
|
||||
exit('推送服务器信息不完整, 请检查配置文件!');
|
||||
Env::failExit('推送服务器信息不完整, 请检查配置文件!');
|
||||
}
|
||||
if (!self::$server_addr || !self::$server_key) {
|
||||
self::$server_addr = getConf('server_addr', 'alone_monitor');
|
||||
@ -75,7 +77,7 @@ class AloneTcpClient
|
||||
* @param $value
|
||||
* @param string $fmt
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function unPackMsg($value, string $fmt = "N"): mixed
|
||||
{
|
||||
@ -85,7 +87,7 @@ class AloneTcpClient
|
||||
/**
|
||||
* @use 连接认证
|
||||
*/
|
||||
private static function handShake()
|
||||
private static function handShake(): void
|
||||
{
|
||||
self::writer(
|
||||
json_encode([
|
||||
@ -101,7 +103,7 @@ class AloneTcpClient
|
||||
/**
|
||||
* @use 心跳
|
||||
*/
|
||||
private static function heartBeat()
|
||||
private static function heartBeat(): void
|
||||
{
|
||||
if (self::$heart_lock <= time()) {
|
||||
if (self::writer("")) {
|
||||
@ -157,7 +159,7 @@ class AloneTcpClient
|
||||
/**
|
||||
* @use 打开连接
|
||||
*/
|
||||
private static function openConnect()
|
||||
private static function openConnect(): void
|
||||
{
|
||||
if (!self::$client) {
|
||||
try {
|
||||
@ -176,7 +178,7 @@ class AloneTcpClient
|
||||
/**
|
||||
* @use 重新连接
|
||||
*/
|
||||
private static function reConnect()
|
||||
private static function reConnect(): void
|
||||
{
|
||||
Log::info('重新连接到推送服务器');
|
||||
self::closeConnect();
|
||||
@ -186,7 +188,7 @@ class AloneTcpClient
|
||||
/**
|
||||
* @use 断开连接
|
||||
*/
|
||||
private static function closeConnect()
|
||||
private static function closeConnect(): void
|
||||
{
|
||||
Log::info('断开推送服务器');
|
||||
try {
|
||||
@ -201,7 +203,7 @@ class AloneTcpClient
|
||||
/**
|
||||
* @use 读取数据
|
||||
*/
|
||||
private static function receive()
|
||||
private static function receive(): void
|
||||
{
|
||||
$len_body = self::reader(4);
|
||||
if (!$len_body) {
|
||||
@ -253,8 +255,7 @@ class AloneTcpClient
|
||||
break;
|
||||
case 'exit':
|
||||
// 服务器发布命令
|
||||
Log::error("服务器发布退出命令 {$raw_data['data']['msg']}");
|
||||
exit();
|
||||
Env::failExit("服务器发布退出命令 {$raw_data['data']['msg']}");
|
||||
default:
|
||||
// 未知信息
|
||||
var_dump($raw_data);
|
||||
@ -269,7 +270,7 @@ class AloneTcpClient
|
||||
* @use 写入log
|
||||
* @param $message
|
||||
*/
|
||||
private static function writeLog($message)
|
||||
private static function writeLog($message): void
|
||||
{
|
||||
$path = './danmu/';
|
||||
if (!file_exists($path)) {
|
||||
|
||||
@ -221,9 +221,9 @@ class AnchorRaffle extends BaseRaffle
|
||||
/**
|
||||
* @use 解析抽奖信息
|
||||
* @param array $results
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
protected static function parseLottery(array $results): mixed
|
||||
protected static function parseLottery(array $results): string
|
||||
{
|
||||
foreach ($results as $result) {
|
||||
$data = $result['source'];
|
||||
|
||||
@ -28,7 +28,7 @@ class AwardRecord
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('award_record')) {
|
||||
return;
|
||||
@ -48,7 +48,7 @@ class AwardRecord
|
||||
/**
|
||||
* @use 获取天选时刻中奖纪录
|
||||
*/
|
||||
private static function anchorAward()
|
||||
private static function anchorAward(): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/Anchor/AwardRecord';
|
||||
$payload = [
|
||||
@ -95,7 +95,7 @@ class AwardRecord
|
||||
/**
|
||||
* @use 获取实物抽奖中奖纪录
|
||||
*/
|
||||
private static function raffleAward()
|
||||
private static function raffleAward(): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/lottery/v1/award/award_list';
|
||||
$payload = [
|
||||
@ -132,7 +132,7 @@ class AwardRecord
|
||||
/**
|
||||
* @use 获取活动礼物中奖纪录
|
||||
*/
|
||||
private static function giftAward()
|
||||
private static function giftAward(): void
|
||||
{
|
||||
// Web V3 Notice
|
||||
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v3/smalltv/Notice';
|
||||
|
||||
@ -22,7 +22,7 @@ class Barrage
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('barrage')) {
|
||||
return;
|
||||
@ -76,6 +76,7 @@ class Barrage
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
return '哔哩哔哩🍻!';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ class BpConsumption
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('bp_consumption')) {
|
||||
return;
|
||||
@ -88,7 +88,7 @@ class BpConsumption
|
||||
* @param int $uid
|
||||
* @param int $num
|
||||
*/
|
||||
private static function BP2charge(int $uid, int $num = 5)
|
||||
private static function BP2charge(int $uid, int $num = 5): void
|
||||
{
|
||||
$url = 'https://api.bilibili.com/x/ugcpay/web/v2/trade/elec/pay/quick';
|
||||
$payload = [
|
||||
@ -119,7 +119,7 @@ class BpConsumption
|
||||
* B币充值金瓜子
|
||||
* @param int $num
|
||||
*/
|
||||
private static function BP2gold(int $num)
|
||||
private static function BP2gold(int $num): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/xlive/revenue/v1/order/createOrder';
|
||||
$headers = [
|
||||
|
||||
@ -31,7 +31,7 @@ class CapsuleLottery
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('live_capsule')) {
|
||||
return;
|
||||
@ -167,7 +167,7 @@ class CapsuleLottery
|
||||
* @param int $act_id
|
||||
* @param string $referer
|
||||
*/
|
||||
private static function taskShare(int $act_id, string $referer)
|
||||
private static function taskShare(int $act_id, string $referer): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/xlive/activity-interface/v1/task/UserShare';
|
||||
$headers = [
|
||||
@ -191,7 +191,7 @@ class CapsuleLottery
|
||||
* @param int $pool_id
|
||||
* @param string $referer
|
||||
*/
|
||||
private static function getPoolDetail(int $pool_id, string $referer)
|
||||
private static function getPoolDetail(int $pool_id, string $referer): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/get_pool_detail';
|
||||
$headers = [
|
||||
@ -254,7 +254,7 @@ class CapsuleLottery
|
||||
* @param int $act_id
|
||||
* @param string $referer
|
||||
*/
|
||||
private static function userActTask(int $act_id, string $referer)
|
||||
private static function userActTask(int $act_id, string $referer): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info';
|
||||
$headers = [
|
||||
@ -277,7 +277,7 @@ class CapsuleLottery
|
||||
* @param int $cycle_id
|
||||
* @param string $referer
|
||||
*/
|
||||
private static function getTaskAward(int $act_id, int $task_id, int $level_id, int $cycle_id, string $referer)
|
||||
private static function getTaskAward(int $act_id, int $task_id, int $level_id, int $cycle_id, string $referer): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/getaward';
|
||||
$headers = [
|
||||
|
||||
@ -26,7 +26,7 @@ class CheckUpdate
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time()) {
|
||||
return;
|
||||
@ -38,7 +38,7 @@ class CheckUpdate
|
||||
/**
|
||||
* @use 检查
|
||||
*/
|
||||
private static function check()
|
||||
private static function check(): void
|
||||
{
|
||||
Log::info('开始检查项目更新');
|
||||
self::loadJsonData();
|
||||
@ -73,7 +73,7 @@ class CheckUpdate
|
||||
/**
|
||||
* @use 拉取最新
|
||||
*/
|
||||
private static function fetchLatest()
|
||||
private static function fetchLatest(): void
|
||||
{
|
||||
$url = self::$current_conf->get('raw_url');
|
||||
$payload = [];
|
||||
@ -84,7 +84,7 @@ class CheckUpdate
|
||||
/**
|
||||
* @use 加载本地JSON DATA
|
||||
*/
|
||||
private static function loadJsonData()
|
||||
private static function loadJsonData(): void
|
||||
{
|
||||
self::$current_conf = json(self::$repository);
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class Competition
|
||||
* @use run
|
||||
* @doc 赛事入口 https://www.bilibili.com/v/game/match/competition
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('match_forecast')) {
|
||||
return;
|
||||
@ -34,7 +34,7 @@ class Competition
|
||||
/**
|
||||
* @use 开始破产
|
||||
*/
|
||||
private static function startStake()
|
||||
private static function startStake(): void
|
||||
{
|
||||
$questions = self::fetchQuestions();
|
||||
$max_guess = getConf('max_num', 'match_forecast');
|
||||
@ -51,7 +51,7 @@ class Competition
|
||||
* @use 添加竞猜
|
||||
* @param array $guess
|
||||
*/
|
||||
private static function addGuess(array $guess)
|
||||
private static function addGuess(array $guess): void
|
||||
{
|
||||
Log::info($guess['title']);
|
||||
Log::info($guess['estimate']);
|
||||
|
||||
@ -21,7 +21,7 @@ class DailyBag
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('daily_bag')) {
|
||||
return;
|
||||
@ -34,7 +34,7 @@ class DailyBag
|
||||
/**
|
||||
* @use 领取每日包裹PC
|
||||
*/
|
||||
private static function dailyBagPC()
|
||||
private static function dailyBagPC(): void
|
||||
{
|
||||
sleep(1);
|
||||
$url = 'https://api.live.bilibili.com/gift/v2/live/receive_daily_bag';
|
||||
@ -52,7 +52,7 @@ class DailyBag
|
||||
/**
|
||||
* @use 领取每日包裹APP
|
||||
*/
|
||||
private static function dailyBagAPP()
|
||||
private static function dailyBagAPP(): void
|
||||
{
|
||||
sleep(1);
|
||||
$url = 'https://api.live.bilibili.com/AppBag/sendDaily';
|
||||
|
||||
@ -21,7 +21,7 @@ class DailyTask
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('daily_task')) {
|
||||
return;
|
||||
@ -58,7 +58,7 @@ class DailyTask
|
||||
* @use 每日签到
|
||||
* @param $info
|
||||
*/
|
||||
private static function sign_info($info)
|
||||
private static function sign_info($info): void
|
||||
{
|
||||
Log::info('检查任务「每日签到」...');
|
||||
|
||||
@ -92,7 +92,7 @@ class DailyTask
|
||||
* @use 双端任务
|
||||
* @param $info
|
||||
*/
|
||||
private static function double_watch_info($info)
|
||||
private static function double_watch_info($info): void
|
||||
{
|
||||
Log::info('检查任务「双端观看直播」...');
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ class DataTreating
|
||||
* @use 抽奖分发
|
||||
* @param array $data
|
||||
*/
|
||||
public static function distribute(array $data)
|
||||
public static function distribute(array $data): void
|
||||
{
|
||||
// var_dump($data);
|
||||
// room_id raffle_id raffle_title raffle_type
|
||||
|
||||
@ -21,7 +21,7 @@ class DoubleHeart
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('double_heart')) {
|
||||
return;
|
||||
@ -35,7 +35,7 @@ class DoubleHeart
|
||||
/**
|
||||
* @use Web 心跳
|
||||
*/
|
||||
protected static function webHeart()
|
||||
protected static function webHeart(): void
|
||||
{
|
||||
User::webGetUserInfo();
|
||||
$url = 'https://api.live.bilibili.com/User/userOnlineHeart';
|
||||
@ -61,7 +61,7 @@ class DoubleHeart
|
||||
/**
|
||||
* @use 手机端心跳
|
||||
*/
|
||||
protected static function appHeart()
|
||||
protected static function appHeart(): void
|
||||
{
|
||||
User::appGetUserInfo();
|
||||
$url = 'https://api.live.bilibili.com/mobile/userOnlineHeart';
|
||||
|
||||
@ -45,7 +45,7 @@ class Forward
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
|
||||
if (self::getLock() > time()) {
|
||||
@ -81,7 +81,7 @@ class Forward
|
||||
/**
|
||||
* 自动转发抽奖
|
||||
*/
|
||||
public static function autoRepost()
|
||||
public static function autoRepost(): void
|
||||
{
|
||||
$article_list = Dynamic::getAwardTopic();
|
||||
foreach ($article_list as $did => $article) {
|
||||
@ -110,7 +110,7 @@ class Forward
|
||||
/**
|
||||
* 清理无效的动态
|
||||
*/
|
||||
private static function clearDynamic()
|
||||
private static function clearDynamic(): void
|
||||
{
|
||||
$dynamicList = Dynamic::getMyDynamic();
|
||||
|
||||
@ -186,7 +186,7 @@ class Forward
|
||||
/**
|
||||
* @use 取关
|
||||
*/
|
||||
private static function clearFollowGroup()
|
||||
private static function clearFollowGroup(): void
|
||||
{
|
||||
$tags = User::fetchTags();
|
||||
foreach ($tags as $gid => $name) {
|
||||
@ -205,7 +205,7 @@ class Forward
|
||||
/**
|
||||
* @use 清理动态
|
||||
*/
|
||||
private static function clearAllDynamic()
|
||||
private static function clearAllDynamic(): void
|
||||
{
|
||||
$dynamicList = Dynamic::getMyDynamic();
|
||||
$msg_list = self::getReplyMsgList();
|
||||
@ -231,7 +231,7 @@ class Forward
|
||||
* @param int $anchor_id
|
||||
* @param int $time
|
||||
*/
|
||||
private static function addToGroup(int $need_follow_uid, int $anchor_id = 0, int $time = 0)
|
||||
private static function addToGroup(int $need_follow_uid, int $anchor_id = 0, int $time = 0): void
|
||||
{
|
||||
// 获取分组id
|
||||
if (is_null(self::$group_id)) {
|
||||
|
||||
@ -21,7 +21,7 @@ class GiftHeart
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('gift_heart')) {
|
||||
return;
|
||||
|
||||
@ -29,7 +29,7 @@ class GiftSend
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !self::inTime('23:50:00', '23:59:50')) {
|
||||
return;
|
||||
@ -99,7 +99,7 @@ class GiftSend
|
||||
/**
|
||||
* @use 方案2
|
||||
*/
|
||||
protected static function procTwo()
|
||||
protected static function procTwo(): void
|
||||
{
|
||||
$bag_list = self::fetchBagList();
|
||||
$expire_gift = self::checkExpireGift($bag_list);
|
||||
@ -175,7 +175,7 @@ class GiftSend
|
||||
/**
|
||||
* @use 获取勋章列表(过滤无勋章或已满)
|
||||
*/
|
||||
protected static function getMedalList()
|
||||
protected static function getMedalList(): void
|
||||
{
|
||||
self::$medal_list = [];
|
||||
$data = Live::fetchMedalList();
|
||||
@ -202,7 +202,7 @@ class GiftSend
|
||||
/**
|
||||
* @use 获取UID
|
||||
*/
|
||||
protected static function getUserInfo()
|
||||
protected static function getUserInfo(): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/xlive/web-ucenter/user/get_user_info';
|
||||
$payload = [];
|
||||
@ -220,7 +220,7 @@ class GiftSend
|
||||
/**
|
||||
* @use 获取直播间信息
|
||||
*/
|
||||
protected static function getRoomInfo()
|
||||
protected static function getRoomInfo(): void
|
||||
{
|
||||
Log::info('正在生成直播间信息...');
|
||||
$room_id = empty(self::$tid) ? getConf('room_id', 'global_room') : self::$tid;
|
||||
@ -263,7 +263,7 @@ class GiftSend
|
||||
* @param array $value
|
||||
* @param int $amt
|
||||
*/
|
||||
protected static function sendGift(array $value, int $amt)
|
||||
protected static function sendGift(array $value, int $amt): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/gift/v2/live/bag_send';
|
||||
$payload = [
|
||||
|
||||
@ -21,7 +21,7 @@ class GroupSignIn
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('love_club')) {
|
||||
return;
|
||||
|
||||
@ -43,7 +43,7 @@ class Judge
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
// 基础判断
|
||||
if (self::getLock() > time() || !getEnable('judgement')) {
|
||||
@ -105,7 +105,7 @@ class Judge
|
||||
* @param string $case_id
|
||||
* @param int $vote
|
||||
*/
|
||||
private static function vote(string $case_id, int $vote)
|
||||
private static function vote(string $case_id, int $vote): void
|
||||
{
|
||||
$url = 'https://api.bilibili.com/x/credit/v2/jury/vote';
|
||||
$payload = [
|
||||
@ -129,7 +129,7 @@ class Judge
|
||||
/**
|
||||
* @use 申请连任
|
||||
*/
|
||||
private static function juryApply()
|
||||
private static function juryApply(): void
|
||||
{
|
||||
$url = 'https://api.bilibili.com/x/credit/v2/jury/apply';
|
||||
$payload = [
|
||||
|
||||
@ -418,7 +418,7 @@ class Live
|
||||
* @param array $gift // 礼物信息
|
||||
* @param int $num // 数量
|
||||
*/
|
||||
public static function sendGift(array $guest, array $gift, int $num)
|
||||
public static function sendGift(array $guest, array $gift, int $num): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/gift/v2/live/bag_send';
|
||||
$payload = [
|
||||
|
||||
@ -21,7 +21,7 @@ class LiveReservation
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('live_reservation')) {
|
||||
return;
|
||||
@ -45,7 +45,7 @@ class LiveReservation
|
||||
* @use 尝试预约并抽奖
|
||||
* @param array $data
|
||||
*/
|
||||
private static function reserve(array $data)
|
||||
private static function reserve(array $data): void
|
||||
{
|
||||
$url = 'https://api.bilibili.com/x/space/reserve';
|
||||
$headers = [
|
||||
|
||||
@ -9,10 +9,12 @@
|
||||
|
||||
namespace BiliHelper\Plugin;
|
||||
|
||||
use BiliHelper\Core\Env;
|
||||
use BiliHelper\Core\Log;
|
||||
use BiliHelper\Core\Curl;
|
||||
use BiliHelper\Util\TimeLock;
|
||||
use BiliHelper\Tool\Common;
|
||||
use Jelix\IniFile\IniException;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
|
||||
@ -26,9 +28,9 @@ class Login
|
||||
|
||||
/**
|
||||
* @use run
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock()) {
|
||||
self::keepAuth();
|
||||
@ -53,9 +55,9 @@ class Login
|
||||
|
||||
/**
|
||||
* @use 登录控制中心
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function login()
|
||||
private static function login(): void
|
||||
{
|
||||
self::checkLogin();
|
||||
switch (getConf('mode', 'login.mode')) {
|
||||
@ -70,25 +72,22 @@ class Login
|
||||
case 3:
|
||||
// 行为验证码模式(暂未开放)
|
||||
// self::captchaLogin();
|
||||
Log::error('此登录模式暂未开放');
|
||||
die();
|
||||
Env::failExit('此登录模式暂未开放');
|
||||
default:
|
||||
Log::error('登录模式配置错误');
|
||||
die();
|
||||
Env::failExit('登录模式配置错误');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @use 检查登录
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function checkLogin()
|
||||
private static function checkLogin(): void
|
||||
{
|
||||
$username = getConf('username', 'login.account');
|
||||
$password = getConf('password', 'login.account');
|
||||
if (empty($username) || empty($password)) {
|
||||
Log::error('空白的帐号和口令');
|
||||
die();
|
||||
Env::failExit('空白的帐号和口令');
|
||||
}
|
||||
self::clearAccount();
|
||||
self::$username = $username;
|
||||
@ -98,7 +97,7 @@ class Login
|
||||
/**
|
||||
* @use 保持认证
|
||||
* @return bool
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function keepAuth(): bool
|
||||
{
|
||||
@ -141,7 +140,7 @@ class Login
|
||||
|
||||
/**
|
||||
* @use 刷新Token
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function refreshToken(): bool
|
||||
{
|
||||
@ -175,8 +174,7 @@ class Login
|
||||
$data = Curl::get('app', $url, Sign::login($payload));
|
||||
$data = json_decode($data, true);
|
||||
if (isset($data['code']) && $data['code']) {
|
||||
Log::error('公钥载入失败', ['msg' => $data['message']]);
|
||||
die();
|
||||
Env::failExit('公钥载入失败',['msg' => $data['message']]);
|
||||
} else {
|
||||
Log::info('公钥载入完毕');
|
||||
}
|
||||
@ -247,9 +245,9 @@ class Login
|
||||
* @param string $validate
|
||||
* @param string $challenge
|
||||
* @param string $mode
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function accountLogin(string $validate = '', string $challenge = '', string $mode = '账密模式')
|
||||
private static function accountLogin(string $validate = '', string $challenge = '', string $mode = '账密模式'): void
|
||||
{
|
||||
Log::info("尝试 $mode 登录");
|
||||
// $url = 'https://passport.bilibili.com/api/v3/oauth2/login';
|
||||
@ -278,9 +276,9 @@ class Login
|
||||
/**
|
||||
* @use 短信登录
|
||||
* @param string $mode
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function smsLogin(string $mode = '短信模式')
|
||||
private static function smsLogin(string $mode = '短信模式'): void
|
||||
{
|
||||
Log::info("尝试 $mode 登录");
|
||||
if (getConf('phone', 'login.check')) {
|
||||
@ -338,8 +336,7 @@ class Login
|
||||
$payload['captcha_key'] = $de_raw['data']['captcha_key'];
|
||||
return $payload;
|
||||
}
|
||||
Log::error("短信验证码发送失败 $raw");
|
||||
die();
|
||||
Env::failExit("短信验证码发送失败 $raw");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -347,9 +344,9 @@ class Login
|
||||
* @param $mode
|
||||
* @param $code
|
||||
* @param $data
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function loginAfter($mode, $code, $data)
|
||||
private static function loginAfter($mode, $code, $data): void
|
||||
{
|
||||
switch ($code) {
|
||||
case 0:
|
||||
@ -396,9 +393,9 @@ class Login
|
||||
* @use 登录成功
|
||||
* @param $mode
|
||||
* @param $data
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function loginSuccess($mode, $data)
|
||||
private static function loginSuccess($mode, $data): void
|
||||
{
|
||||
Log::info("$mode 登录成功");
|
||||
self::successHandle($data);
|
||||
@ -408,9 +405,9 @@ class Login
|
||||
/**
|
||||
* @use 刷新成功
|
||||
* @param $data
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function refreshSuccess($data)
|
||||
private static function refreshSuccess($data): void
|
||||
{
|
||||
Log::info('重新令牌生成完毕');
|
||||
self::successHandle($data);
|
||||
@ -420,9 +417,9 @@ class Login
|
||||
/**
|
||||
* @use 成功处理
|
||||
* @param $data
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function successHandle($data)
|
||||
private static function successHandle($data): void
|
||||
{
|
||||
$access_token = $data['data']['token_info']['access_token'];
|
||||
$refresh_token = $data['data']['token_info']['refresh_token'];
|
||||
@ -440,22 +437,21 @@ class Login
|
||||
* @param $data
|
||||
*/
|
||||
#[NoReturn]
|
||||
private static function loginFail($mode, $data)
|
||||
private static function loginFail($mode, $data): void
|
||||
{
|
||||
Log::error("$mode 登录失败", ['msg' => $data]);
|
||||
die();
|
||||
Env::failExit("$mode 登录失败", ['msg' => $data]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @use 检查手机号格式
|
||||
* @param string $phone
|
||||
*/
|
||||
private static function checkPhone(string $phone)
|
||||
private static function checkPhone(string $phone): void
|
||||
{
|
||||
// /^1[3456789]{1}\d{9}$/
|
||||
if (!preg_match("/^1[3456789]\d{9}$/", $phone)) {
|
||||
Log::error("当前用户名不是有效手机号格式");
|
||||
die();
|
||||
Env::failExit('当前用户名不是有效手机号格式');
|
||||
}
|
||||
}
|
||||
|
||||
@ -466,9 +462,9 @@ class Login
|
||||
* @param string $section
|
||||
* @param bool $print
|
||||
* @param bool $hide
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function saveConfig(string $key, string $value, string $section, bool $print = true, bool $hide = true)
|
||||
private static function saveConfig(string $key, string $value, string $section, bool $print = true, bool $hide = true): void
|
||||
{
|
||||
setConf($key, $value, $section);
|
||||
if ($print) {
|
||||
@ -493,9 +489,9 @@ class Login
|
||||
|
||||
/**
|
||||
* @use 清除已有
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function clearAccount()
|
||||
private static function clearAccount(): void
|
||||
{
|
||||
$variables = ['cookie', 'access_token', 'refresh_token'];
|
||||
foreach ($variables as $variable) {
|
||||
@ -526,14 +522,13 @@ class Login
|
||||
/**
|
||||
* @use 验证码登录
|
||||
* @param string $mode
|
||||
* @throws \Jelix\IniFile\IniException
|
||||
* @throws IniException
|
||||
*/
|
||||
private static function captchaLogin(string $mode = '验证码模式')
|
||||
private static function captchaLogin(string $mode = '验证码模式'): void
|
||||
{
|
||||
$captcha_ori = self::getCaptcha();
|
||||
$captcha = self::ocrCaptcha($captcha_ori);
|
||||
self::accountLogin($captcha['validate'], $captcha['challenge'], $mode);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -22,7 +22,7 @@ class MainSite
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('main_site')) {
|
||||
return;
|
||||
|
||||
@ -21,7 +21,7 @@ class ManGa
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('manga')) {
|
||||
return;
|
||||
|
||||
@ -27,7 +27,7 @@ class MaterialObject
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('live_box')) {
|
||||
return;
|
||||
|
||||
@ -30,7 +30,7 @@ class Notice
|
||||
* @param string $type
|
||||
* @param string $result
|
||||
*/
|
||||
public static function push(string $type, string $result = '')
|
||||
public static function push(string $type, string $result = ''): void
|
||||
{
|
||||
if (!getEnable('notify')) {
|
||||
return;
|
||||
@ -146,7 +146,7 @@ class Notice
|
||||
* @use 推送消息
|
||||
* @param array $info
|
||||
*/
|
||||
private static function sendLog(array $info)
|
||||
private static function sendLog(array $info): void
|
||||
{
|
||||
if (getConf('sctkey', 'notify.sct')) {
|
||||
self::sctSend($info);
|
||||
@ -185,7 +185,7 @@ class Notice
|
||||
* @doc https://developers.dingtalk.com/document/robots/custom-robot-access
|
||||
* @param array $info
|
||||
*/
|
||||
private static function dingTalkSend(array $info)
|
||||
private static function dingTalkSend(array $info): void
|
||||
{
|
||||
Log::info('使用DingTalk机器人推送消息');
|
||||
$url = 'https://oapi.dingtalk.com/robot/send?access_token=' . getConf('token', 'notify.dingtalk');
|
||||
@ -213,7 +213,7 @@ class Notice
|
||||
* @doc https://core.telegram.org/bots/api#sendmessage
|
||||
* @param array $info
|
||||
*/
|
||||
private static function teleSend(array $info)
|
||||
private static function teleSend(array $info): void
|
||||
{
|
||||
Log::info('使用Tele机器人推送消息');
|
||||
$base_url = getConf('url', 'notify.telegram') ?: 'https://api.telegram.org/bot';
|
||||
@ -237,7 +237,7 @@ class Notice
|
||||
* @use https://sc.ftqq.com/
|
||||
* @param array $info
|
||||
*/
|
||||
private static function scSend(array $info)
|
||||
private static function scSend(array $info): void
|
||||
{
|
||||
Log::info('使用ServerChan推送消息');
|
||||
$url = 'https://sc.ftqq.com/' . getConf('sckey', 'notify.sc') . '.send';
|
||||
@ -260,7 +260,7 @@ class Notice
|
||||
* @doc https://sct.ftqq.com/
|
||||
* @param array $info
|
||||
*/
|
||||
private static function sctSend(array $info)
|
||||
private static function sctSend(array $info): void
|
||||
{
|
||||
Log::info('使用ServerChan(Turbo)推送消息');
|
||||
$url = 'https://sctapi.ftqq.com/' . getConf('sctkey', 'notify.sct') . '.send';
|
||||
@ -284,7 +284,7 @@ class Notice
|
||||
* @doc http://www.pushplus.plus/doc/
|
||||
* @param array $info
|
||||
*/
|
||||
private static function pushPlusSend(array $info)
|
||||
private static function pushPlusSend(array $info): void
|
||||
{
|
||||
Log::info('使用PushPlus酱推送消息');
|
||||
$url = 'https://www.pushplus.plus/send';
|
||||
@ -308,7 +308,7 @@ class Notice
|
||||
* @doc https://docs.go-cqhttp.org/api/
|
||||
* @param array $info
|
||||
*/
|
||||
private static function goCqhttp(array $info)
|
||||
private static function goCqhttp(array $info): void
|
||||
{
|
||||
Log::info('使用GoCqhttp推送消息');
|
||||
$url = getConf('url', 'notify.gocqhttp');
|
||||
@ -332,7 +332,7 @@ class Notice
|
||||
* @doc https://localhost:8921/doc
|
||||
* @param array $info
|
||||
*/
|
||||
private static function debug(array $info)
|
||||
private static function debug(array $info): void
|
||||
{
|
||||
Log::info('使用Debug推送消息');
|
||||
$url = getConf('url', 'notify.debug');
|
||||
@ -345,7 +345,7 @@ class Notice
|
||||
$raw = Curl::post('other', $url, $payload);
|
||||
$de_raw = json_decode($raw, true);
|
||||
// {"success": true, "msg": null, "data": {"errcode": 0, "errmsg": "ok", "msgid": 1231, "token": "456"}}
|
||||
if ($de_raw['success'] == true) {
|
||||
if ($de_raw['success']) {
|
||||
Log::notice("推送消息成功: {$de_raw['data']['msgid']}");
|
||||
} else {
|
||||
Log::warning("推送消息失败: $raw");
|
||||
@ -357,7 +357,7 @@ class Notice
|
||||
* @doc https://open.work.weixin.qq.com/api/doc/90000/90136/91770
|
||||
* @param array $info
|
||||
*/
|
||||
private static function weCom(array $info)
|
||||
private static function weCom(array $info): void
|
||||
{
|
||||
Log::info('使用weCom推送消息');
|
||||
$url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=' . getConf('token', 'notify.we_com');
|
||||
@ -383,7 +383,7 @@ class Notice
|
||||
* @doc https://open.work.weixin.qq.com/wwopen/devtool/interface?doc_id=10167
|
||||
* @param array $info
|
||||
*/
|
||||
private static function weComApp(array $info)
|
||||
private static function weComApp(array $info): void
|
||||
{
|
||||
Log::info('使用weComApp推送消息');
|
||||
$corp_id = getConf('corp_id', 'notify.we_com_app');
|
||||
@ -432,7 +432,7 @@ class Notice
|
||||
* @doc https://developers.dingtalk.com/document/robots/custom-robot-access
|
||||
* @param array $info
|
||||
*/
|
||||
private static function feiShuSend(array $info)
|
||||
private static function feiShuSend(array $info): void
|
||||
{
|
||||
Log::info('使用飞书webhook机器人推送消息');
|
||||
$url = 'https://open.feishu.cn/open-apis/bot/v2/hook/' . getConf('token', 'notify.feishu');
|
||||
|
||||
@ -25,7 +25,7 @@ class PolishTheMedal
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (!getEnable('polish_the_medal')) {
|
||||
return;
|
||||
@ -60,7 +60,7 @@ class PolishTheMedal
|
||||
/**
|
||||
* @use 点亮勋章
|
||||
*/
|
||||
private static function polishTheMedal()
|
||||
private static function polishTheMedal(): void
|
||||
{
|
||||
$medal = array_pop(self::$grey_fans_medals);
|
||||
// 为空
|
||||
@ -83,7 +83,7 @@ class PolishTheMedal
|
||||
* @use 获取灰色勋章列表(过滤无勋章或已满)
|
||||
* @param bool $all
|
||||
*/
|
||||
private static function fetchGreyMedalList(bool $all = false)
|
||||
private static function fetchGreyMedalList(bool $all = false): void
|
||||
{
|
||||
$data = Live::fetchMedalList();
|
||||
foreach ($data as $vo) {
|
||||
|
||||
@ -72,9 +72,9 @@ class RedPocketRaffle extends BaseRaffle
|
||||
/**
|
||||
* @use 解析抽奖信息
|
||||
* @param array $results
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
protected static function parseLottery(array $results): mixed
|
||||
protected static function parseLottery(array $results): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class Schedule
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time()) {
|
||||
return;
|
||||
@ -92,7 +92,7 @@ class Schedule
|
||||
* @param $action
|
||||
* @param string $classname
|
||||
*/
|
||||
private static function handleBan($action, string $classname = '')
|
||||
private static function handleBan($action, string $classname = ''): void
|
||||
{
|
||||
switch ($action) {
|
||||
// 休眠
|
||||
@ -138,7 +138,7 @@ class Schedule
|
||||
* @param int $unlock_time
|
||||
* @param bool $force
|
||||
*/
|
||||
private static function stopProc(array $classname_list, int $unlock_time, bool $force = false)
|
||||
private static function stopProc(array $classname_list, int $unlock_time, bool $force = false): void
|
||||
{
|
||||
foreach ($classname_list as $classname) {
|
||||
Log::info("插件 $classname 黑名单,锁定状态将于" . date("Y-m-d H:i", time() + $unlock_time) . "解除");
|
||||
@ -155,7 +155,7 @@ class Schedule
|
||||
* @use 触发封禁
|
||||
* @param string $classname
|
||||
*/
|
||||
public static function triggerRefused(string $classname)
|
||||
public static function triggerRefused(string $classname): void
|
||||
{
|
||||
self::handleBan('pause', $classname);
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
namespace BiliHelper\Plugin;
|
||||
|
||||
use BiliHelper\Core\Env;
|
||||
use BiliHelper\Core\Log;
|
||||
use BiliHelper\Core\Curl;
|
||||
use BiliHelper\Util\TimeLock;
|
||||
@ -23,7 +24,7 @@ class Silver
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time()) {
|
||||
return;
|
||||
@ -40,7 +41,7 @@ class Silver
|
||||
/**
|
||||
* @use 获取宝箱
|
||||
*/
|
||||
private static function getSilverBox()
|
||||
private static function getSilverBox(): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/lottery/v1/SilverBox/getCurrentTask';
|
||||
$payload = [];
|
||||
@ -58,8 +59,7 @@ class Silver
|
||||
}
|
||||
|
||||
if (isset($data['code']) && $data['code']) {
|
||||
Log::error("check freeSilverCurrentTask failed! Error message: {$data['message']}");
|
||||
die();
|
||||
Env::failExit("check freeSilverCurrentTask failed! Error message: {$data['message']}");
|
||||
}
|
||||
|
||||
Log::info("获得一个宝箱,内含 {$data['data']['silver']} 个瓜子");
|
||||
@ -76,7 +76,7 @@ class Silver
|
||||
/**
|
||||
* @use 开启宝箱
|
||||
*/
|
||||
private static function openSilverBox()
|
||||
private static function openSilverBox(): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/mobile/freeSilverAward';
|
||||
$payload = [
|
||||
|
||||
@ -21,7 +21,7 @@ class Silver2Coin
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('silver2coin')) {
|
||||
return;
|
||||
|
||||
@ -27,7 +27,7 @@ class SmallHeart
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (!getEnable('small_heart')) {
|
||||
return;
|
||||
@ -51,7 +51,7 @@ class SmallHeart
|
||||
/**
|
||||
* @use 心跳处理
|
||||
*/
|
||||
private static function heartBeat()
|
||||
private static function heartBeat(): void
|
||||
{
|
||||
if (empty(self::$fans_medals)) {
|
||||
return;
|
||||
@ -69,7 +69,7 @@ class SmallHeart
|
||||
/**
|
||||
* @use 获取灰色勋章列表(过滤无勋章或已满)
|
||||
*/
|
||||
private static function fetchMedalList()
|
||||
private static function fetchMedalList(): void
|
||||
{
|
||||
$data = Live::fetchMedalList();
|
||||
foreach ($data as $vo) {
|
||||
|
||||
@ -27,7 +27,7 @@ class Statistics
|
||||
* @use run
|
||||
* @todo 统计开关 统计时间间隔 统计类型
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time()) {
|
||||
return;
|
||||
@ -267,7 +267,7 @@ class Statistics
|
||||
/**
|
||||
* @use 打印表格
|
||||
*/
|
||||
private static function outputResult()
|
||||
private static function outputResult(): void
|
||||
{
|
||||
$arr_tr_list = self::getTrList();
|
||||
foreach ($arr_tr_list as $tr_list) {
|
||||
|
||||
@ -152,9 +152,9 @@ class StormRaffle extends BaseRaffle
|
||||
/**
|
||||
* @use 解析抽奖信息
|
||||
* @param array $results
|
||||
* @return mixed
|
||||
* @return string
|
||||
*/
|
||||
protected static function parseLottery(array $results): mixed
|
||||
protected static function parseLottery(array $results): string
|
||||
{
|
||||
foreach ($results as $result) {
|
||||
$data = $result['source'];
|
||||
|
||||
@ -322,7 +322,7 @@ class User
|
||||
/**
|
||||
* @use 我的钱包
|
||||
*/
|
||||
public static function myWallet()
|
||||
public static function myWallet(): void
|
||||
{
|
||||
$url = 'https://api.live.bilibili.com/pay/v2/Pay/myWallet';
|
||||
$headers = [
|
||||
|
||||
@ -27,7 +27,7 @@ class VipPrivilege
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('vip_privilege')) {
|
||||
return;
|
||||
@ -52,7 +52,7 @@ class VipPrivilege
|
||||
* @use 领取我的大会员权益
|
||||
* @param int $type
|
||||
*/
|
||||
private static function myVipPrivilegeReceive(int $type)
|
||||
private static function myVipPrivilegeReceive(int $type): void
|
||||
{
|
||||
$url = 'https://api.bilibili.com/x/vip/privilege/receive';
|
||||
$headers = [
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
namespace BiliHelper\Plugin;
|
||||
|
||||
use BiliHelper\Core\Env;
|
||||
use BiliHelper\Core\Log;
|
||||
use BiliHelper\Util\TimeLock;
|
||||
|
||||
@ -17,6 +18,7 @@ use Amp\Delayed;
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Socket\Raw\Factory;
|
||||
use Socket\Raw\Socket;
|
||||
use function get_class;
|
||||
|
||||
class ZoneTcpClient
|
||||
@ -30,7 +32,7 @@ class ZoneTcpClient
|
||||
|
||||
private static int|string $area_id;
|
||||
private static int|string $room_id;
|
||||
private static $client;
|
||||
private static ?Socket $client;
|
||||
private static array $client_maps = [];
|
||||
private static array $trigger_restart = [];
|
||||
private static int $socket_timeout = 0;
|
||||
@ -39,7 +41,7 @@ class ZoneTcpClient
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (self::getLock() > time() || !getEnable('zone_monitor')) {
|
||||
return;
|
||||
@ -55,10 +57,10 @@ class ZoneTcpClient
|
||||
/**
|
||||
* @use 初始化
|
||||
*/
|
||||
private static function init()
|
||||
private static function init(): void
|
||||
{
|
||||
if (empty(getConf('server_addr', 'zone_monitor'))) {
|
||||
exit('推送服务器信息不完整, 请检查配置文件!');
|
||||
Env::failExit('推送服务器信息不完整, 请检查配置文件!');
|
||||
}
|
||||
if (!self::$client) {
|
||||
self::initConnect();
|
||||
@ -68,7 +70,7 @@ class ZoneTcpClient
|
||||
/**
|
||||
* @use 初始化连接
|
||||
*/
|
||||
private static function initConnect()
|
||||
private static function initConnect(): void
|
||||
{
|
||||
$areas = Live::fetchLiveAreas();
|
||||
foreach ($areas as $area_id) {
|
||||
@ -85,7 +87,7 @@ class ZoneTcpClient
|
||||
* @param array $area_data
|
||||
* @param string $reason
|
||||
*/
|
||||
private static function triggerReConnect(array $area_data, string $reason)
|
||||
private static function triggerReConnect(array $area_data, string $reason): void
|
||||
{
|
||||
Log::debug("Reconnect Reason: {$area_data['area_id']} -> $reason");
|
||||
self::$client_maps["server" . $area_data['area_id']]['status'] = false;
|
||||
@ -95,7 +97,7 @@ class ZoneTcpClient
|
||||
/**
|
||||
* @use 更新连接
|
||||
*/
|
||||
private static function updateConnection()
|
||||
private static function updateConnection(): void
|
||||
{
|
||||
$num = count(self::$trigger_restart);
|
||||
for ($i = 0; $i < $num; $i++) {
|
||||
@ -121,7 +123,7 @@ class ZoneTcpClient
|
||||
* @use 更新操作
|
||||
* @param array $area
|
||||
*/
|
||||
private static function update(array $area)
|
||||
private static function update(array $area): void
|
||||
{
|
||||
self::$area_id = $area['area_id'];
|
||||
self::$room_id = $area['room_id'];
|
||||
@ -388,7 +390,7 @@ class ZoneTcpClient
|
||||
/**
|
||||
* @推送到上游处理
|
||||
*/
|
||||
private static function pushHandle()
|
||||
private static function pushHandle(): void
|
||||
{
|
||||
foreach (self::$raffle_list as $type => $data) {
|
||||
$temp_room_id = 0;
|
||||
@ -406,7 +408,7 @@ class ZoneTcpClient
|
||||
* @use 响应关闭
|
||||
* @param $client
|
||||
*/
|
||||
private static function onClosed($client)
|
||||
private static function onClosed($client): void
|
||||
{
|
||||
}
|
||||
|
||||
@ -478,7 +480,7 @@ class ZoneTcpClient
|
||||
/**
|
||||
* @use 心跳
|
||||
*/
|
||||
private static function heartBeat()
|
||||
private static function heartBeat(): void
|
||||
{
|
||||
foreach (self::$client_maps as $key => $client_info) {
|
||||
// 如果重连状态 跳过
|
||||
@ -574,7 +576,7 @@ class ZoneTcpClient
|
||||
/**
|
||||
* @use 读取数据
|
||||
*/
|
||||
private static function receive()
|
||||
private static function receive(): void
|
||||
{
|
||||
foreach (self::$client_maps as $client_info) {
|
||||
// 如果重连状态 就跳过
|
||||
|
||||
@ -15,7 +15,7 @@ class BaseTask
|
||||
{
|
||||
public static $interactor = null;
|
||||
|
||||
public static function init()
|
||||
public static function init(): void
|
||||
{
|
||||
User::login();
|
||||
}
|
||||
@ -54,7 +54,7 @@ class BaseTask
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Ahc\Cli\IO\Interactor
|
||||
* @return Interactor
|
||||
*/
|
||||
public static function interactor(): Interactor
|
||||
{
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
|
||||
namespace BiliHelper\Script;
|
||||
|
||||
use BiliHelper\Core\Env;
|
||||
use BiliHelper\Core\Log;
|
||||
use BiliHelper\Core\Curl;
|
||||
use Exception;
|
||||
|
||||
class UnFollow extends BaseTask
|
||||
{
|
||||
@ -18,7 +20,7 @@ class UnFollow extends BaseTask
|
||||
|
||||
/**
|
||||
* @use run
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function run()
|
||||
{
|
||||
@ -37,7 +39,7 @@ class UnFollow extends BaseTask
|
||||
* @use 取消关注
|
||||
* @param $target_ups
|
||||
* @param $tag_id
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function relationModify($target_ups, $tag_id)
|
||||
{
|
||||
@ -76,7 +78,7 @@ class UnFollow extends BaseTask
|
||||
* @param int $max_pn
|
||||
* @param int $max_ps
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function relationTag($tag_id, int $max_pn = 60, int $max_ps = 20): array
|
||||
{
|
||||
@ -139,8 +141,7 @@ class UnFollow extends BaseTask
|
||||
Log::notice("已获取分组 $option - $options[$option]");
|
||||
return $option;
|
||||
} else {
|
||||
Log::error("获取关注分组失败 CODE -> {$data['code']} MSG -> {$data['message']} ");
|
||||
die();
|
||||
Env::failExit("获取关注分组失败 CODE -> {$data['code']} MSG -> {$data['message']} ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
namespace BiliHelper\Script;
|
||||
|
||||
use BiliHelper\Core\Env;
|
||||
use BiliHelper\Core\Log;
|
||||
use BiliHelper\Core\Curl;
|
||||
|
||||
@ -22,8 +23,7 @@ class User
|
||||
public static function login(): bool
|
||||
{
|
||||
if (getAccessToken() == '' || getCookie() == '' || getUid() == '' || getCsrf() == '') {
|
||||
Log::error('用户信息不全,请默认模式登录后使用。');
|
||||
die();
|
||||
Env::failExit('用户信息不全,请默认模式登录后使用。');
|
||||
}
|
||||
$data = User::userInfo();
|
||||
if ($data['code'] == 0 && $data['data']['isLogin']) {
|
||||
@ -31,8 +31,7 @@ class User
|
||||
$level = $nav['level_info'];
|
||||
Log::notice("登录成功 Uname={$nav['uname']} Uid={$nav['mid']} Lv={$level['current_level']} ({$level['current_exp']}/{$level['current_min']})");
|
||||
} else {
|
||||
Log::error("登录失败 CODE -> {$data['code']} MSG -> {$data['message']} ");
|
||||
die();
|
||||
Env::failExit("登录失败 CODE -> {$data['code']} MSG -> {$data['message']} ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -11,6 +11,8 @@
|
||||
|
||||
namespace BiliHelper\Tool;
|
||||
|
||||
use Closure;
|
||||
|
||||
class ArrayToTextTable
|
||||
{
|
||||
const AlignLeft = STR_PAD_RIGHT;
|
||||
@ -144,7 +146,7 @@ class ArrayToTextTable
|
||||
}
|
||||
|
||||
//执行formatter
|
||||
if ($this->formatter instanceof \Closure) {
|
||||
if ($this->formatter instanceof Closure) {
|
||||
foreach ($data as &$row) {
|
||||
array_walk($row, $this->formatter);
|
||||
}
|
||||
@ -162,7 +164,7 @@ class ArrayToTextTable
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function setWidth($key, $value)
|
||||
private function setWidth($key, $value): void
|
||||
{
|
||||
if (!isset($this->widths[$key])) {
|
||||
$this->widths[$key] = 0;
|
||||
|
||||
@ -15,7 +15,7 @@ use BiliHelper\Core\Log;
|
||||
|
||||
class DumpMemory
|
||||
{
|
||||
public static function dd($title)
|
||||
public static function dd($title): void
|
||||
{
|
||||
$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
|
||||
$size = memory_get_usage(true);
|
||||
|
||||
@ -135,7 +135,6 @@ class File
|
||||
* @param string $filename
|
||||
* @return array|bool
|
||||
*/
|
||||
#[Pure]
|
||||
public static function getInfo(string $filename): array|bool
|
||||
{
|
||||
// 如果不是文件 或者 不可读返回false
|
||||
|
||||
@ -193,7 +193,7 @@ class UserAgent
|
||||
* Get a random operating system
|
||||
* @param string|null $os
|
||||
* @return array|string|null *
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getOS(string $os = NULL): array|string|null
|
||||
{
|
||||
@ -226,7 +226,7 @@ class UserAgent
|
||||
* Get Mobile OS
|
||||
* @param string|null $os Can specifiy android, iphone, ipad, ipod, or null/blank for random
|
||||
* @return array|string|null *
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getMobileOS(string $os = NULL): array|string|null
|
||||
{
|
||||
@ -262,7 +262,7 @@ class UserAgent
|
||||
* static::processRandomNumbers
|
||||
* @param $selected_os
|
||||
* @return null|string|string[] *
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function processRandomNumbers($selected_os): array|string|null
|
||||
{
|
||||
@ -317,7 +317,7 @@ class UserAgent
|
||||
* static::chromeVersion
|
||||
* @param $version
|
||||
* @return string *
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function chromeVersion($version): string
|
||||
{
|
||||
@ -329,7 +329,7 @@ class UserAgent
|
||||
* static::firefoxVersion
|
||||
* @param $version
|
||||
* @return string *
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function firefoxVersion($version): string
|
||||
{
|
||||
@ -340,7 +340,7 @@ class UserAgent
|
||||
* static::windows
|
||||
* @param $version
|
||||
* @return string *
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function windows($version): string
|
||||
{
|
||||
@ -351,7 +351,7 @@ class UserAgent
|
||||
* generate
|
||||
* @param null $userAgent
|
||||
* @return string *
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function generate($userAgent = NULL, $locale = null): string
|
||||
{
|
||||
|
||||
@ -36,7 +36,7 @@ trait AllotTasks
|
||||
/**
|
||||
* @use 提交任务
|
||||
* @param string $operation
|
||||
* @param \stdClass $act
|
||||
* @param stdClass $act
|
||||
* @param bool $time
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@ -33,7 +33,7 @@ abstract class BaseRaffle
|
||||
/**
|
||||
* @use run
|
||||
*/
|
||||
public static function run()
|
||||
public static function run(): void
|
||||
{
|
||||
if (!getEnable(static::ACTIVE_SWITCH)) {
|
||||
return;
|
||||
|
||||
@ -24,7 +24,7 @@ trait TimeLock
|
||||
* @use 设置时间
|
||||
* @param int $lock
|
||||
*/
|
||||
public static function setLock(int $lock)
|
||||
public static function setLock(int $lock): void
|
||||
{
|
||||
if (!static::getpauseStatus()) {
|
||||
Task::getInstance()->_setLock(static::getBaseClass(), time() + $lock);
|
||||
@ -100,7 +100,7 @@ trait TimeLock
|
||||
/**
|
||||
* @use 暂停
|
||||
*/
|
||||
public static function pauseLock()
|
||||
public static function pauseLock(): void
|
||||
{
|
||||
// 备份几种获取方式 get_called_class()
|
||||
// basename(str_replace('\\', '/', $class));
|
||||
@ -113,7 +113,7 @@ trait TimeLock
|
||||
/**
|
||||
* @use 取消暂停
|
||||
*/
|
||||
public static function cancelPause()
|
||||
public static function cancelPause(): void
|
||||
{
|
||||
static::$pause_status = false;
|
||||
}
|
||||
@ -131,7 +131,7 @@ trait TimeLock
|
||||
* @use 设置状态
|
||||
* @param bool $status
|
||||
*/
|
||||
public static function setPauseStatus(bool $status = false)
|
||||
public static function setPauseStatus(bool $status = false): void
|
||||
{
|
||||
self::$pause_status = $status;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ class ConfigGenerator
|
||||
/**
|
||||
* @use Generator
|
||||
*/
|
||||
public function generate()
|
||||
public function generate(): void
|
||||
{
|
||||
$this->filename = $this->cliInput('请输入配置文件名: ');
|
||||
$this->template = file_get_contents($this->default_filename);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user