__CLASS__, // hook 'name' => 'VipPoint', // 插件名称 'version' => '0.0.1', // 插件版本 'desc' => '大会员积分', // 插件描述 'author' => 'Lkeme',// 作者 'priority' => 1112, // 插件优先级 'cycle' => '5(分钟)', // 运行周期 ]; /** * @var string */ protected string $home_task = 'https://big.bilibili.com/mobile/bigPoint/task'; /** * @var string */ protected string $home = 'https://big.bilibili.com/mobile/bigPoint'; /** * @var string */ protected string $title = '大会员积分'; /** * @var array|null */ protected ?array $tasks = []; /** * 目标任务 * @var array|string[] */ protected array $target_tasks = [ // 'dressUp' => '使用免费体验装扮权益', 'signIn' => '每日签到', 'bonus' => '大会员福利大积分', 'privilege' => '浏览大会员权益页面', 'viewAnimate' => '浏览追番频道页10秒', 'viewFilmChannel' => '浏览影视频道页10秒', 'viewVipMall' => '浏览会员购页面10秒', 'viewVideo' => '观看任意正片内容', 'buyVipVideo' => '购买单点付费影片', 'buyVipProduct' => '购买指定大会员产品', 'buyVipMall' => '购买指定会员购商品', 'dressView' => '浏览装扮商城主页', 'dressBuyAmount' => '购买装扮', 'pointInfo' => '积分信息' ]; /** * @param Plugin $plugin */ public function __construct(Plugin &$plugin) { // 时间锁 TimeLock::initTimeLock(); // 缓存 Cache::initCache(); // $this::class $plugin->register($this, 'execute'); } /** * 执行 * @return void */ public function execute(): void { if (TimeLock::getTimes() > time() || !getEnable('vip_point')) return; // $this->initTask(); // $this->receiveTask(); // 全部完成 if (TimeLock::getTimes() <= time()) { TimeLock::setTimes(TimeLock::timing(9)); } } /** * @return void */ protected function receiveTask(): void { // 如果为大会员 if (!User::isVip($this->title)) return; // 获取远程任务列表 if (!$this->getTaskList()) { TimeLock::setTimes(10 * 60); return; }; // foreach ($this->target_tasks as $target => $value) { // 任务完成跳过 if ($this->getTask($target)) continue; // 未完成执行 $this->executeTask($target, $value); // TimeLock::setTimes(5 * 60); // 每次执行一个任务 return; } } /** * 动态执行任务 * @param string $target * @param string $name * @return void */ protected function executeTask(string $target, string $name): void { $response = $this->getTask('TaskList'); // if (!method_exists($this, $target)) { failExit("VipPoint 不存在{$target}方法 请暂时关闭任务检查代码或通知开发者"); } // $this->setTask($target, $this->$target($response, $name)); } /** * @return void */ protected function initTask(): void { $now = date("Y-m-d"); if (isset($this->tasks[$now])) return; // $this->setTask('start', true); // foreach ($this->target_tasks as $target => $_) { $this->setTask($target, false); } } /** * @return bool */ protected function getTaskList(): bool { $response = ApiTask::combine(); if ($response['code']) { Log::warning('大会员积分: 获取任务列表失败'); return false; } // 设置任务 $this->setTask('TaskList', $response); return true; } /** * @param string $key * @param mixed $value * @return void */ protected function setTask(string $key, mixed $value): void { $now = date("Y-m-d"); // $this->tasks[$now][$key] = $value; } /** * @param string $key * @return mixed */ protected function getTask(string $key): mixed { $now = date("Y-m-d"); // return $this->tasks[$now][$key]; } /** * @param string $key * @return void */ protected function delTask(string $key): void { $now = date("Y-m-d"); // unset($this->tasks[$now][$key]); } }