diff --git a/README.md b/README.md index 51adccf..c7ba98b 100644 --- a/README.md +++ b/README.md @@ -76,21 +76,22 @@ Group: [602815575](https://jq.qq.com/?_wv=1027&k=UaalVexM) | **请不要来问
点击展开 -| plugin | version | description | author | pid | cycle | status | -|-----------------|---------|--------------------------|--------|------|-------------|--------| -| CheckUpdate | 0.0.1 | 检查版本更新 | Lkeme | 1000 | 24(小时) | √ | -| Login | 0.0.1 | 账号登录、刷新、保活 | Lkeme | 1001 | 2(小时) | √ | -| MainSite | 0.0.1 | 主站任务(观看\分享\投币) | Lkeme | 1100 | 24(小时) | √ | -| Manga | 0.0.1 | 漫画签到/分享 | Lkeme | 1101 | 24(小时) | √ | -| LoveClub | 0.0.1 | 友爱社签到 | Lkeme | 1102 | 24(小时) | √ | -| LiveSignIn | 0.0.1 | 直播签到 | Lkeme | 1103 | 24(小时) | √ | -| GameForecast | 0.0.1 | 游戏赛事预测(破产机) | Lkeme | 1104 | 24(小时) | √ | -| Silver2Coin | 0.0.1 | 银瓜子兑换硬币 | Lkeme | 1105 | 24(小时) | √ | -| Judge | 0.0.1 | 風機委員投票 | Lkeme | 1106 | 15-30(分钟) | √ | -| VipPrivilege | 0.0.1 | 领取大会员权益 | Lkeme | 1107 | 24(小时) | √ | -| BpConsumption | 0.0.1 | 大会员B币券消费 | Lkeme | 1108 | 24(小时) | √ | -| LiveReservation | 0.0.1 | 预约直播有奖 | Lkeme | 1109 | 1-3(小时) | √ | -| LiveGoldBox | 0.0.1 | 直播金色宝箱(实物抽奖) | Lkeme | 1110 | 6-10(分钟) | √ | +| plugin | version | description | author | pid | cycle | status | +|-----------------|---------|----------------|--------|------|-----------|--------| +| CheckUpdate | 0.0.1 | 检查版本更新 | Lkeme | 1000 | 24(小时) | √ | +| Login | 0.0.1 | 账号登录、刷新、保活 | Lkeme | 1001 | 2(小时) | √ | +| MainSite | 0.0.1 | 主站任务(观看\分享\投币) | Lkeme | 1100 | 24(小时) | √ | +| Manga | 0.0.1 | 漫画签到/分享 | Lkeme | 1101 | 24(小时) | √ | +| LoveClub | 0.0.1 | 友爱社签到 | Lkeme | 1102 | 24(小时) | √ | +| LiveSignIn | 0.0.1 | 直播签到 | Lkeme | 1103 | 24(小时) | √ | +| GameForecast | 0.0.1 | 游戏赛事预测(破产机) | Lkeme | 1104 | 24(小时) | √ | +| Silver2Coin | 0.0.1 | 银瓜子兑换硬币 | Lkeme | 1105 | 24(小时) | √ | +| Judge | 0.0.1 | 風機委員投票 | Lkeme | 1106 | 15-30(分钟) | √ | +| VipPrivilege | 0.0.1 | 领取大会员权益 | Lkeme | 1107 | 24(小时) | √ | +| BpConsumption | 0.0.1 | 大会员B币券消费 | Lkeme | 1108 | 24(小时) | √ | +| LiveReservation | 0.0.1 | 预约直播有奖 | Lkeme | 1109 | 1-3(小时) | √ | +| LiveGoldBox | 0.0.1 | 直播金色宝箱(实物抽奖) | Lkeme | 1110 | 6-10(分钟) | √ | +| AwardRecords | 0.0.1 | 获奖记录 | Lkeme | 1111 | 5(分钟) | √ |
diff --git a/plugin/AwardRecords/AwardRecords.php b/plugin/AwardRecords/AwardRecords.php new file mode 100644 index 0000000..f8e9e66 --- /dev/null +++ b/plugin/AwardRecords/AwardRecords.php @@ -0,0 +1,255 @@ + 0, + 'award' => 0, + 'celestial' => 0, + 'bonus' => 0, + ]; + + /** + * 插件信息 + * @var array|string[] + */ + protected ?array $info = [ + 'hook' => __CLASS__, // hook + 'name' => 'AwardRecords', // 插件名称 + 'version' => '0.0.1', // 插件版本 + 'desc' => '获奖记录', // 插件描述 + 'author' => 'Lkeme',// 作者 + 'priority' => 1111, // 插件优先级 + 'cycle' => '5(分钟)', // 运行周期 + ]; + + /** + * @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('award_records')) return; + // + $this->awardRecordsTask(); + // + TimeLock::setTimes(5 * 60); + } + + /** + * @return void + */ + protected function awardRecordsTask(): void + { + // 缓存开始 + $this->records = ($tmp = Cache::get('records')) ? $tmp : $this->initRecords(); + // + if ($this->locks['operation'] < time()) { + $this->operation(); + } + if ($this->locks['award'] < time()) { + $this->award(); + } + if ($this->locks['celestial'] < time()) { + $this->celestial(); + } + if ($this->locks['bonus'] < time()) { + $this->bonus(); + } + // 缓存结束 + Cache::set('records', $this->records); + } + + /** + * 运营奖惩|false#6|true#24 + * @param string $title + * @return bool + */ + protected function operation(string $title = '运营奖惩'): bool + { + $response = ApiWallet::apCenterList(); + // + if ($response['code']) { + Log::warning("获奖记录: 获取{$title}失败 {$response['code']} -> {$response['message']}"); + $this->locks['operation'] = time() + 6 * 60 * 60; + return false; + } + // + $now = date("m") . '月' . date("d") . '日'; + foreach ($response['data']['list'] as $data) { + $info = $data['md'] . '-' . $data['desc']; + // + if (!in_array($info, $this->records['operation'])) { + $this->records['operation'][] = $info; + } + // 需要通知 + if ($now != $data['md']) continue; + Log::notice($info); + Notice::push($title, $info); + } + $this->locks['operation'] = time() + 24 * 60 * 60; + return true; + } + + /** + * 获奖记录|false#1|true#6 + * @param string $title + * @return bool + */ + protected function award(string $title = '获奖记录'): bool + { + $response = ApiAward::awardList(); + // + if ($response['code']) { + Log::warning("获奖记录: 获取{$title}失败 {$response['code']} -> {$response['message']}"); + $this->locks['award'] = time() + 60 * 60; + return false; + } + // + foreach ($response['data']['list'] as $data) { + $info = $data['create_time'] . '-' . $data['id'] . '-' . $data['source'] . '-' . $data['gift_name']; + // + if (!in_array($info, $this->records['award'])) { + $this->records['award'][] = $info; + } + // + $create_time = strtotime($data['create_time']); //礼物时间 + $day = ceil((time() - $create_time) / 86400); //60s*60min*24h + // + // 范围 + if ($day <= 2 && $data['update_time'] == '') { + Log::notice($info); + Notice::push($title, $info); + } + } + $this->locks['award'] = time() + 6 * 60 * 60; + return true; + } + + /** + * 天选时刻|false#30m|true#10m + * @param string $title + * @return bool + */ + protected function celestial(string $title = '天选时刻'): bool + { + $response = ApiAnchor::awardRecord(); + // + if ($response['code']) { + Log::warning("获奖记录: 获取{$title}失败 {$response['code']} -> {$response['message']}"); + $this->locks['celestial'] = time() + 30 * 60; + return false; + } + // + foreach ($response['data']['list'] as $data) { + $info = $data['end_time'] . '-' . $data['id'] . '-' . $data['anchor_name'] . '-' . $data['award_name']; + // + if (!in_array($info, $this->records['celestial'])) { + $this->records['celestial'][] = $info; + } + // + $end_time = strtotime($data['end_time']); //礼物时间 + $day = ceil((time() - $end_time) / 86400); //60s*60min*24h + // 范围 + if ($day <= 2) { + Log::notice($info); + Notice::push($title, $info); + } + } + $this->locks['celestial'] = time() + 10 * 60; + return true; + } + + /** + * 航海回馈|false#6|true#24 + * @param string $title + * @return bool + */ + protected function bonus(string $title = '航海回馈'): bool + { + $response = ApiAnchor::awardRecord(); + // + if ($response['code']) { + Log::warning("获奖记录: 获取{$title}失败 {$response['code']} -> {$response['message']}"); + $this->locks['bonus'] = time() + 6 * 30 * 60; + return false; + } + // + foreach ($response['data']['list'] as $data) { + $info = $data['settlement_time'] . '-' . $data['win_id'] . '-' . $data['anchor_name'] . '-' . $data['award_name']; + // + if (!in_array($info, $this->records['bonus'])) { + $this->records['bonus'][] = $info; + } + // + $settlement_time = strtotime($data['settlement_time']); //礼物时间 + // 范围 + if (time() < $settlement_time) { + Log::notice($info); + Notice::push($title, $info); + } + } + $this->locks['bonus'] = time() + 24 * 60 * 60; + return true; + } + + /** + * 初始化 + * @return array[] + */ + protected function initRecords(): array + { + return [ + 'operation' => [], + 'award' => [], + 'celestial' => [], + 'bonus' => [], + ]; + } +} diff --git a/plugin/PluginTemplate/PluginTemplate.php b/plugin/PluginTemplate/PluginTemplate.php index 76ebbdc..f998737 100644 --- a/plugin/PluginTemplate/PluginTemplate.php +++ b/plugin/PluginTemplate/PluginTemplate.php @@ -63,4 +63,3 @@ class PluginTemplate extends BasePlugin } - \ No newline at end of file diff --git a/profile/example/config/user.ini b/profile/example/config/user.ini index 0141b5d..c1e8461 100644 --- a/profile/example/config/user.ini +++ b/profile/example/config/user.ini @@ -95,6 +95,10 @@ vmids = 9617619 [live_gold_box] enable = true +; 获取记录 +[award_records] +enable = true + ####################### # 通知设置 # ####################### diff --git a/src/Api/Lottery/V1/ApiAward.ctp b/src/Api/Lottery/V1/ApiAward.ctp new file mode 100644 index 0000000..5e0062c --- /dev/null +++ b/src/Api/Lottery/V1/ApiAward.ctp @@ -0,0 +1,41 @@ + 1, + 'month' => '' + ]; + $headers = [ + 'origin' => 'https://link.bilibili.com', + 'referer' => 'https://link.bilibili.com/p/center/index' + ]; + return Request::getJson(true, 'pc', $url, $payload, $headers); + } +} diff --git a/src/Api/XLive/GeneralInterface/V1/ApiGuardBenefit.ctp b/src/Api/XLive/GeneralInterface/V1/ApiGuardBenefit.ctp new file mode 100644 index 0000000..e2a67a7 --- /dev/null +++ b/src/Api/XLive/GeneralInterface/V1/ApiGuardBenefit.ctp @@ -0,0 +1,41 @@ + 1, + ]; + $headers = [ + 'origin' => 'https://link.bilibili.com', + 'referer' => 'https://link.bilibili.com/p/center/index' + ]; + // {"code":0,"message":"0","ttl":1,"data":{"count":1,"page_count":1,"list":[{"win_id":16211,"recipient_name":"","phone":"","address":"","info_type":1,"award_name":"【韩小沐】月度舰长福利","ruid":642922,"anchor_name":"韩小沐","settlement_time":"2022-08-07 20:57:29"}]}} + return Request::getJson(true, 'pc', $url, $payload, $headers); + } +} diff --git a/src/Api/XLive/LotteryInterface/V1/ApiAnchor.ctp b/src/Api/XLive/LotteryInterface/V1/ApiAnchor.ctp new file mode 100644 index 0000000..cf479dd --- /dev/null +++ b/src/Api/XLive/LotteryInterface/V1/ApiAnchor.ctp @@ -0,0 +1,40 @@ + 1, + ]; + $headers = [ + 'origin' => 'https://link.bilibili.com', + 'referer' => 'https://link.bilibili.com/p/center/index' + ]; + return Request::getJson(true, 'pc', $url, $payload, $headers); + } +} diff --git a/src/Api/XLive/Revenue/V1/ApiWallet.ctp b/src/Api/XLive/Revenue/V1/ApiWallet.ctp new file mode 100644 index 0000000..8d7dd22 --- /dev/null +++ b/src/Api/XLive/Revenue/V1/ApiWallet.ctp @@ -0,0 +1,40 @@ + 1, + ]; + $headers = [ + 'origin' => 'https://link.bilibili.com', + 'referer' => 'https://link.bilibili.com/p/center/index' + ]; + return Request::getJson(true, 'pc', $url, $payload, $headers); + } +} diff --git a/src/Notice/Notice.php b/src/Notice/Notice.php index 140ba0a..d22c5a3 100644 --- a/src/Notice/Notice.php +++ b/src/Notice/Notice.php @@ -187,8 +187,8 @@ class Notice extends SingleTon 'content' => "[$now_time] 用户: $uname 详情: $msg ,请及时关注風機委員连任状态哦~" ], default => [ - 'title' => '推送消息异常记录', - 'content' => "[$now_time] 用户: $uname 推送消息key错误: $type->$msg" + 'title' => $type, + 'content' => "[$now_time] 用户: $uname 详情: $msg" ], }; // 添加前缀 @@ -404,7 +404,7 @@ class Notice extends SingleTon { Log::info('使用weComApp推送消息'); $corp_id = getConf('notify_we_com_app.corp_id'); - $corp_secret = getConf('notify_we_com_app.corp_secret' ); + $corp_secret = getConf('notify_we_com_app.corp_secret'); $agent_id = getConf('notify_we_com_app.agent_id'); $to_user = getConf('notify_we_com_app.to_user') ?? '@all'; @@ -474,4 +474,3 @@ class Notice extends SingleTon } - \ No newline at end of file