diff --git a/CHANGELOG.md b/CHANGELOG.md index 2da9b76..a55ce4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,32 @@ [comment]: <> () +## v1.0.1.211014 alpha (2021-10-14) + +### Added + +- + +### Changed + +- 更新部分活动 +- 更新系统环境参数 +- + +### Fixed + +- 修复中文用户名运行失败 +- 修复风纪(未完善,慎用) +- + +### Remarks + +- 注意文档文件有些许改动 +- 注意需要重新进行`composer update`操作 +- 注意只支持PHP8.* 只支持PHP8.* 只支持PHP8.* +- + + ## v1.0.0.210822 alpha (2021-08-22) ### Added diff --git a/README.md b/README.md index 5814b00..5873be0 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@

- + @@ -32,10 +32,14 @@ ---- 只有花大价钱去买到的东西,才会令人信任。 ``` -## 🖥️星图 +## 打赏支持 + +如果觉得本项目好用,对你有所帮助,欢迎打赏支持本项目哦。 + +

+ +[comment]: <> (![Image](https://i.loli.net/2019/07/13/5d2963e5cc1eb22973.png)) -[![Stargazers over time](https://starchart.cc/lkeme/BiliHelper-personal.svg)](https://starchart.cc/lkeme/BiliHelper-personal) -[![Stargazers over time](https://starchart.cc/lkeme/BiliHelper.svg)](https://starchart.cc/lkeme/BiliHelper) ## 功能组件 @@ -43,47 +47,45 @@ | plugin | status | version | cycle | description | |-----------------|--------|----------|--------|---------------------------------------------| -| CheckUpdate | true | 21.08.22 | 待整理 | 程序检查更新 | -| Login | true | 21.08.22 | 待整理 | 账号登录、刷新、维持 | -| Schedule | true | 21.08.22 | 待整理 | 控制插件运行周期 | -| MainSite | true | 21.08.22 | 待整理 | 投币、观看、分享视频 (速升6级不是梦) | -| DailyBag | true | 21.08.22 | 待整理 | 双端领取日常/周常礼包 | -| ManGa | true | 21.08.22 | 待整理 | 漫画签到、分享 | -| ActivityLottery | true | 21.08.22 | 待整理 | 主站活动九宫格抽奖 | -| Competition | true | 21.08.22 | 待整理 | 游戏赛事竞猜 | -| DoubleHeart | true | 21.08.22 | 待整理 | 双端心跳 (姥爷直播经验) | -| DailyTask | true | 21.08.22 | 待整理 | 直播每日任务(签到、观看) | -| Barrage | true | 21.08.22 | 待整理 | 保持活跃弹幕 | -| Silver2Coin | true | 21.08.22 | 待整理 | 银瓜子兑换硬币 | -| Judge | true | 21.08.22 | 待整理 | 风纪委员投票 | -| GiftSend | true | 21.08.22 | 待整理 | 礼物赠送、维持每日勋章亲密度 | -| GroupSignIn | true | 21.08.22 | 待整理 | 友爱社签到 | -| GiftHeart | true | 21.08.22 | 待整理 | 日常心跳每日礼包礼物 | -| SmallHeart | true | 21.08.22 | 待整理 | 直播挂机,每日24个小心心 | -| MaterialObject | true | 21.08.22 | 待整理 | 直播金色宝箱实物抽奖 | -| AloneTcpClient | true | 21.08.22 | 待整理 | 作者的独立直播监控(可支持本项目哦) | -| ZoneTcpClient | true | 21.08.22 | 待整理 | 官方的分区直播监控 | -| StormRaffle | true | 21.08.22 | 待整理 | 直播节奏风暴抽奖、亿元 | -| GiftRaffle | true | 21.08.22 | 待整理 | 直播礼物抽奖 | -| PkRaffle | true | 21.08.22 | 待整理 | 直播大乱斗抽奖 | -| GuardRaffle | true | 21.08.22 | 待整理 | 直播大航海抽奖 | -| AnchorRaffle | true | 21.08.22 | 待整理 | 直播天选时刻抽奖 | -| GiftRaffle | true | 21.08.22 | 待整理 | 直播礼物抽奖 | -| AwardRecord | true | 21.08.22 | 待整理 | 最新的中奖纪录通知 | -| Forward | true | 21.08.22 | 待整理 | 主站动态抽奖转发 | -| CapsuleLottery | true | 21.08.22 | 待整理 | 直播扭蛋活动抽奖 | -| PolishTheMedal | true | 21.08.22 | 待整理 | 每日自动点亮灰色勋章 | -| CapsuleLottery | true | 21.08.22 | 待整理 | 直播扭蛋活动抽奖 | -| VipPrivilege | true | 21.08.22 | 待整理 | 每月领取年度大会员特权(B币券、会员购优惠券) | -| BpConsumption | true | 21.08.22 | 待整理 | 每月消费使用年度大会员特权的B币券 | -| Statistics | true | 21.08.22 | 待整理 | 全局抽奖结果统计 | +| CheckUpdate | true | 21.10.13 | 待整理 | 程序检查更新 | +| Login | true | 21.10.13 | 待整理 | 账号登录、刷新、维持 | +| Schedule | true | 21.10.13 | 待整理 | 控制插件运行周期 | +| MainSite | true | 21.10.13 | 待整理 | 投币、观看、分享视频 (速升6级不是梦) | +| DailyBag | true | 21.10.13 | 待整理 | 双端领取日常/周常礼包 | +| ManGa | true | 21.10.13 | 待整理 | 漫画签到、分享 | +| ActivityLottery | true | 21.10.13 | 待整理 | 主站活动九宫格抽奖 | +| Competition | true | 21.10.13 | 待整理 | 游戏赛事竞猜 | +| DoubleHeart | true | 21.10.13 | 待整理 | 双端心跳 (姥爷直播经验) | +| DailyTask | true | 21.10.13 | 待整理 | 直播每日任务(签到、观看) | +| Barrage | true | 21.10.13 | 待整理 | 保持活跃弹幕 | +| Silver2Coin | true | 21.10.13 | 待整理 | 银瓜子兑换硬币 | +| Judge | true | 21.10.13 | 待整理 | 风纪委员投票 | +| GiftSend | true | 21.10.13 | 待整理 | 礼物赠送、维持每日勋章亲密度 | +| GroupSignIn | true | 21.10.13 | 待整理 | 友爱社签到 | +| GiftHeart | true | 21.10.13 | 待整理 | 日常心跳每日礼包礼物 | +| SmallHeart | true | 21.10.13 | 待整理 | 直播挂机,每日24个小心心 | +| MaterialObject | true | 21.10.13 | 待整理 | 直播金色宝箱实物抽奖 | +| AloneTcpClient | true | 21.10.13 | 待整理 | 作者的独立直播监控(可支持本项目哦) | +| ZoneTcpClient | true | 21.10.13 | 待整理 | 官方的分区直播监控 | +| StormRaffle | true | 21.10.13 | 待整理 | 直播节奏风暴抽奖、亿元 | +| GiftRaffle | true | 21.10.13 | 待整理 | 直播礼物抽奖 | +| PkRaffle | true | 21.10.13 | 待整理 | 直播大乱斗抽奖 | +| GuardRaffle | true | 21.10.13 | 待整理 | 直播大航海抽奖 | +| AnchorRaffle | true | 21.10.13 | 待整理 | 直播天选时刻抽奖 | +| GiftRaffle | true | 21.10.13 | 待整理 | 直播礼物抽奖 | +| AwardRecord | true | 21.10.13 | 待整理 | 最新的中奖纪录通知 | +| Forward | true | 21.10.13 | 待整理 | 主站动态抽奖转发 | +| CapsuleLottery | true | 21.10.13 | 待整理 | 直播扭蛋活动抽奖 | +| PolishTheMedal | true | 21.10.13 | 待整理 | 每日自动点亮灰色勋章 | +| CapsuleLottery | true | 21.10.13 | 待整理 | 直播扭蛋活动抽奖 | +| VipPrivilege | true | 21.10.13 | 待整理 | 每月领取年度大会员特权(B币券、会员购优惠券) | +| BpConsumption | true | 21.10.13 | 待整理 | 每月消费使用年度大会员特权的B币券 | +| Statistics | true | 21.10.13 | 待整理 | 全局抽奖结果统计 | | Silver | false | 21.03.27 | 待整理 | 直播银瓜子自动开启宝箱 | ## 交流反馈 -`没事不要加、潜水不要加、哑巴不要加。` - -Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **请不要来问如何使用, 文档齐全, 仅用于BUG提交反馈** +Group: [163955623](https://jq.qq.com/?_wv=1027&k=1QMFTUEO) | **请不要来问如何使用, 文档齐全, 仅用于BUG提交反馈** ## 相关文档 @@ -96,13 +98,11 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **请不要来问如 * [配置文档 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3) * [常见问题 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98) -## 打赏支持 +## 🖥️星图 -如果觉得本项目好用,对你有所帮助,欢迎打赏支持本项目哦。 +[![Stargazers over time](https://starchart.cc/lkeme/BiliHelper-personal.svg)](https://starchart.cc/lkeme/BiliHelper-personal) +[![Stargazers over time](https://starchart.cc/lkeme/BiliHelper.svg)](https://starchart.cc/lkeme/BiliHelper) -

- -[comment]: <> (![Image](https://i.loli.net/2019/07/13/5d2963e5cc1eb22973.png)) ## 运行效果 diff --git a/composer.json b/composer.json index c0caaa8..32fe0a6 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "adhocore/cli": "^0.9.0", "fire015/flintstone": "^2.3", "symfony/yaml": "^5.3", - "consolidation/config": "^2.0" + "consolidation/config": "^2.0", + "overtrue/pinyin": "~4.0" }, "license": "MIT", "authors": [ diff --git a/conf/bili.yaml b/conf/bili.yaml index 3bc7986..5dc936a 100644 --- a/conf/bili.yaml +++ b/conf/bili.yaml @@ -3,8 +3,8 @@ bili_version: 0.0.1 # Android bili_a: package: "tv.danmaku.bili" - version: "6.38.0" - build: "6380500" + version: "6.43.0" + build: "6430500" channel: "bili" device: "phone" mobi_app: "android" @@ -13,8 +13,8 @@ bili_a: c_locale: "zh-Hans_CH" app_key: "MWQ4YjZlN2Q0NTIzMzQzNg==" secret_key: "NTYwYzUyY2NkMjg4ZmVkMDQ1ODU5ZWQxOGJmZmQ5NzM" - app_key_n: "YmNhN2U4NGMyZDk0N2FjNg==" - secret_key_n: "NjA2OThiYTJmNjhlMDFjZTQ0NzM4OTIwYTBmZmU3Njg=" + app_key_n: "NzgzYmJiNzI2NDQ1MWQ4Mg==" + secret_key_n: "MjY1MzU4M2M4ODczZGVhMjY4YWI5Mzg2OTE4YjFkNjU=" # IOS bili_i: diff --git a/conf/user.ini.example b/conf/user.ini.example index 300a049..a5e1b9d 100644 --- a/conf/user.ini.example +++ b/conf/user.ini.example @@ -129,7 +129,7 @@ content = [manga] enable = false -; 风纪委员投票|需要实名认证 +; 风纪委员投票|需要实名认证|慎用 [judgement] enable = false diff --git a/data/capsule_infos.json b/data/capsule_infos.json index 92822a4..bd63471 100644 --- a/data/capsule_infos.json +++ b/data/capsule_infos.json @@ -5,9 +5,9 @@ "data": [ { "_url": "注释: 活动地址", - "url": "https://www.bilibili.com/blackboard/genshin-1st-anniversary.html", + "url": "https://www.bilibili.com/blackboard/activity-aEe0qbEc8N.html", "_title": "注释: 活动标题", - "title": "原神一周年庆典UP主激励计划", + "title": "原神2.2应援激励计划", "_description": "注释: 活动描述", "description": "每日在原神分区任意直播间观看,20分钟1张、1小时2张、2小时3张,每日最高6张。", "_room_id": "注释: 活动直播间,如果为0,则取分区随机一个", @@ -17,15 +17,15 @@ "_parent_area_id": "注释: 主分区id", "parent_area_id": 3, "_coin_id": "注释: 抽奖id", - "coin_id": 249, + "coin_id": 284, "_pool_id": "注释: 抽奖id", - "pool_id": 257, + "pool_id": 290, "_watch_time": "注释: 观看时长 单位秒", "watch_time": 7320, "_draw_times": "注释: 抽奖次数", "draw_times": 6, "_expire_at": "注释: 活动有效时间", - "expire_at": "2021-10-12 23:59:59" + "expire_at": "2021-11-23 23:59:59" }, { "url": "https://live.bilibili.com/6", diff --git a/data/latest_version.json b/data/latest_version.json index 6e38456..b6d26fc 100644 --- a/data/latest_version.json +++ b/data/latest_version.json @@ -5,7 +5,7 @@ "source": "https://github.com/lkeme/BiliHelper-personal", "raw_url": "https://cdn.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json", "purge_url": "https://purge.jsdelivr.net/gh/lkeme/BiliHelper-personal@master/data/latest_version.json", - "version": "1.0.0.210822", + "version": "1.0.1.211014", "des": "程序有更新,请及时线上查看更新哦~", - "time": "2021年8月22日11:40:35" + "time": "2021年10月14日20:40:35" } \ No newline at end of file diff --git a/src/core/Cache.php b/src/core/Cache.php index 27adda0..0be153f 100644 --- a/src/core/Cache.php +++ b/src/core/Cache.php @@ -13,6 +13,7 @@ namespace BiliHelper\Core; use BiliHelper\Util\Singleton; use Flintstone\Flintstone; +use Overtrue\Pinyin\Pinyin; use Flintstone\Formatter\JsonFormatter; @@ -34,9 +35,15 @@ class Cache private function load(string $classname): static { if (!isset($this->caches[$classname])) { + $username = getConf('username', 'login.account'); + // 判断字符串中是否有中文 + if (preg_match("/[\x7f-\xff]/", $username)) { + $pinyin = new Pinyin(); // 默认 + $username = $pinyin->permalink($username); // yong-hu-ming + } // 如果不存在缓存 初始化 "BHP_username_APP.dat" $this->caches[$classname] = new Flintstone( - $this->removeSpecStr('BHP_' . getConf('username', 'login.account') . '_' . $classname), + $this->removeSpecStr('BHP_' . $username . '_' . $classname), [ 'dir' => APP_CACHE_PATH, 'gzip' => true, @@ -108,7 +115,7 @@ class Cache */ private function removeSpecStr(string $data): string { - $specs = str_split(".,:;'*?~`!@#$%^&+=)(<>{}]|\/、"); + $specs = str_split("-.,:;'*?~`!@#$%^&+=)(<>{}]|\/、"); foreach ($specs as $spec) { $data = str_replace($spec, '', $data); } diff --git a/src/plugin/Judge.php b/src/plugin/Judge.php index d2117ec..9b52137 100644 --- a/src/plugin/Judge.php +++ b/src/plugin/Judge.php @@ -17,144 +17,99 @@ use JetBrains\PhpStorm\ArrayShape; class Judge { + // https://www.bilibili.com/judgement/index + + // 评论 case_type: 1 default_vote: 4 + // 0: {vote: 1, vote_text: "合适"} + // 1: {vote: 2, vote_text: "一般"} + // 2: {vote: 3, vote_text: "不合适"} + // 3: {vote: 4, vote_text: "无法判断"} + + // 弹幕氛围 case_type: 4 default_vote: 14 + // 0: {vote: 11, vote_text: "好"} + // 1: {vote: 12, vote_text: "普通"} + // 2: {vote: 13, vote_text: "差"} + // 3: {vote: 14, vote_text: "无法判断"} + + use TimeLock; - private static int $retry_time = 0; - private static int $wait_case_id = 0; - private static int $wait_time = 0; - private static int $min_ok_pct = 1; - private static int $max_ok_pct = 0; + private static array $wait_case = []; public static function run() { - // https://www.bilibili.com/judgement/index - if (self::getLock() > time() || self::$retry_time > time() || !getEnable('judgement')) { + // 基础判断 + if (self::getLock() > time() || !getEnable('judgement')) { return; } - $case_id = self::$wait_case_id ?: self::caseObtain(); - if (!self::judgeCase($case_id)) { + // 资格判断 没有资格就60-120分钟后计息 不排除其他错误 + if (!self::jury()) { + self::setLock(mt_rand(60, 120) * 60); + } + // + if (empty(self::$wait_case)) { + // 获取任务 + $case_id = self::caseObtain(); + self::caseCheck($case_id); self::setLock(1 * 60 + 5); return; + } else { + $case = array_pop(self::$wait_case); + self::vote($case['id'], $case['vote']); } - // self::judgementIndex(); // 如果没有设置时间 就设置个默认时间 可能在一秒钟内处理完 所以 <= if (self::getLock() <= time()) { self::setLock(mt_rand(15, 30) * 60); } } + /** - * @use 判案 Todo: 处理案例已满(MAX20例) + * @use 案件核查 * @param $case_id - * @return bool + * @return bool|void */ - private static function judgeCase($case_id): bool + private static function caseCheck($case_id) { - if (is_null($case_id) || $case_id == 0) { + if ($case_id == "") { return true; } - // Log::info("尝试判定案件 {$case_id}"); - $data = self::judgementVote($case_id); - $num_judged = $data['num_voted']; - $ok_pct = $data['ok_percent']; - $advice = self::judgeAdvice($num_judged, $ok_pct); - if ($num_judged >= 50) { + $case_info = self::caseInfo($case_id); + $case_opinion = self::caseOpinion($case_id); + if (!$case_opinion && empty($case_opinion)) { + $vote_info = $case_info[array_rand($case_info)]; - self::$min_ok_pct = min(self::$min_ok_pct, $ok_pct); - self::$max_ok_pct = max(self::$max_ok_pct, $ok_pct); - // user.info('更新统计投票波动情况') + } else { + $vote_info = $case_opinion[array_rand($case_opinion)]; } - // Log::info("案件 $case_id 已经等待" . self::$wait_time . "s,统计波动区间为" . self::$min_ok_pct . "-" . self::$max_ok_pct); - if (is_null($advice)) { - if (self::$wait_time >= 1200) { - // 如果case判定中,波动很小,则表示趋势基本一致 - if ((self::$max_ok_pct - self::$min_ok_pct) >= 0 && (self::$max_ok_pct - self::$min_ok_pct) <= 0.1 && $num_judged > 200) { - $num_judged += 100; - $advice0 = self::judgeAdvice($num_judged, self::$max_ok_pct); - $advice1 = self::judgeAdvice($num_judged, self::$min_ok_pct); - $advice = ($advice0 == $advice1) ? $advice0 : null; - } - Log::info("判定结果 $advice"); - } else { - $sleep_wait_time = ($num_judged < 300) ? 200 : 60; - Log::info("案件 $case_id 暂无法判定,{$sleep_wait_time}S 后重新尝试"); - self::$wait_time += $sleep_wait_time; - self::$retry_time = $sleep_wait_time + time(); - self::$wait_case_id = $case_id; - return false; - } - } - // 如果还不行就放弃 - $decision = !is_null($advice) ? $advice : 3; - $dicision_info = ($decision == 3) ? '作废票' : '有效票'; - Log::info("案件 $case_id 的投票结果:$dicision_info($decision)"); - self::juryVote($case_id, $decision); - self::initParams(); - return true; - } - - /** - * @use 投票建议 - * @param $num_judged - * @param $pct - * @return int|null - */ - private static function judgeAdvice($num_judged, $pct): ?int - { - if ($num_judged >= 300) { - # 认为这里可能出现了较多分歧,抬一手 - if ($pct >= 0.4) { - return 2; - } elseif ($pct <= 0.25) { - return 4; - } else { - return null; - } - } elseif ($num_judged >= 150) { - if ($pct >= 0.9) { - return 2; - } elseif ($pct <= 0.1) { - return 4; - } else { - return null; - } - } elseif ($num_judged >= 50) { - if ($pct >= 0.97) { - return 2; - } elseif ($pct <= 0.03) { - return 4; - } else { - return null; - } - } - # 抬一手 - if ($num_judged >= 400) { - return 2; - } - return null; + $vote = $vote_info['vote']; + $vote_text = $vote_info['vote_text']; + Log::info("案件 $case_id 的预测投票结果:$vote($vote_text)"); + array_push(self::$wait_case, ["id" => $case_id, 'vote' => $vote]); } /** * @use 投票 - * @param $case_id - * @param $decision + * @param string $case_id + * @param int $vote */ - private static function juryVote($case_id, $decision) + private static function vote(string $case_id, int $vote) { - $url = 'https://api.bilibili.com/x/credit/jury/vote'; + $url = 'https://api.bilibili.com/x/credit/v2/jury/vote'; $payload = [ - "jsonp" => "jsonp", - "cid" => $case_id, - "vote" => $decision, + "case_id" => $case_id, + "vote" => $vote, "content" => "", - "likes" => "", - "hates" => "", - "attr" => "1", + "anonymous" => 0, "csrf" => getCsrf(), ]; - $raw = Curl::post('pc', $url, $payload); - // {"code":25012,"message":"请勿重复投票","ttl":1} + $headers = [ + 'origin' => 'https://www.bilibili.com', + 'referer' => 'https://www.bilibili.com/', + ]; + $raw = Curl::post('pc', $url, $payload, $headers); $de_raw = json_decode($raw, true); + //{"code":0,"message":"0","ttl":1} if (isset($de_raw['code']) && $de_raw['code']) { Log::warning("案件 $case_id 投票失败 $raw"); } else { @@ -162,19 +117,73 @@ class Judge } } + /** - * @use 案件获取 + * @use 获取众议观点 + */ + private static function caseOpinion(string $case_id, int $pn = 1, int $ps = 5) + { + $url = 'https://api.bilibili.com/x/credit/v2/jury/case/opinion'; + $payload = [ + 'case_id' => $case_id, + 'pn' => $pn, + 'ps' => $ps + ]; + $headers = [ + 'origin' => 'https://www.bilibili.com', + 'referer' => 'https://www.bilibili.com/', + ]; + $raw = Curl::get('pc', $url, $payload, $headers); + $de_raw = json_decode($raw, true); + // {"code":0,"message":"0","ttl":1,"data":{"total":438,"list":[]}} + if (isset($de_raw['code']) && $de_raw['code']) { + return false; + } else { + return $de_raw['data']['list']; + } + } + + + /** + * @use 获取案例详情 + * @param string $case_id * @return mixed */ - private static function caseObtain(): mixed + private static function caseInfo(string $case_id): mixed { - $url = 'https://api.bilibili.com/x/credit/jury/caseObtain'; + $url = 'https://api.bilibili.com/x/credit/v2/jury/case/info'; $payload = [ - "jsonp" => "jsonp", - "csrf" => getCsrf() + 'case_id' => $case_id, ]; - $raw = Curl::post('pc', $url, $payload); + $headers = [ + 'origin' => 'https://www.bilibili.com', + 'referer' => 'https://www.bilibili.com/', + ]; + $raw = Curl::get('pc', $url, $payload, $headers); $de_raw = json_decode($raw, true); + // {"code":0,"message":"0","ttl":1,"data":{"case_id":"","case_type":1,"vote_items":[{"vote":1,"vote_text":"合适"},{"vote":2,"vote_text":"一般"},{"vote":3,"vote_text":"不合适"},{"vote":4,"vote_text":"无法判断"}],"default_vote":4,"status":0,"origin_start":0,"avid":,"cid":,"vote_cd":5,"case_info":{"comment":{"uname":"用户1","face":"xxxx"},"danmu_img":""}}} + if (isset($de_raw['code']) && $de_raw['code']) { + return false; + } else { + return $de_raw['data']['vote_items']; + } + } + + /** + * @use 获取案件任务 + * @return string + */ + private static function caseObtain(): string + { + $url = 'https://api.bilibili.com/x/credit/v2/jury/case/next'; + $payload = []; + $headers = [ + 'origin' => 'https://www.bilibili.com', + 'referer' => 'https://www.bilibili.com/', + ]; + $raw = Curl::get('pc', $url, $payload, $headers); + $de_raw = json_decode($raw, true); + // {"code":0,"message":"0","ttl":1,"data":{"case_id":"AC1xx411c7At"}} // {"code":25008,"message":"真给力 , 移交众裁的举报案件已经被处理完了","ttl":1} // {"code":25014,"message":"25014","ttl":1} // {"code":25005,"message":"请成为风纪委员后再试","ttl":1} @@ -183,86 +192,52 @@ class Judge case 25005: Log::warning($de_raw['message']); self::setLock(self::timing(10)); - return null; + break; case 25008: Log::info("暂时没有新的案件需要审理~ $raw"); - return null; + break; case 25014: Log::info("今日案件已审满,感谢您对社区的贡献!明天再来看看吧~"); self::setLock(self::timing(7, 0, 0, true)); - return null; + break; default: Log::info("获取案件失败~ $raw"); - return null; } + return ''; } else { - $case_id = $de_raw['data']['id']; - Log::info("获取到案件 $case_id ~"); + $case_id = $de_raw['data']['case_id']; + Log::info("获取到案例ID $case_id ~"); return $case_id; } + } /** - * @use 判断投票 - * @param $case_id - * @return array + * @use 陪审团 + * @return bool */ - #[ArrayShape(['num_voted' => "mixed", 'ok_percent' => "float|int"])] - private static function judgementVote($case_id): array + private static function jury(): bool { - $url = 'https://api.bilibili.com/x/credit/jury/juryCase'; + $url = 'https://api.bilibili.com/x/credit/v2/jury/jury'; + $payload = []; $headers = [ - 'Referer' => "https://www.bilibili.com/judgement/vote/$case_id" - ]; - $payload = [ - 'callback' => "jQuery1720" . self::randInt() . "_" . time(), - 'cid' => $case_id, - '_' => time() + 'origin' => 'https://www.bilibili.com', + 'referer' => 'https://www.bilibili.com/', ]; $raw = Curl::get('pc', $url, $payload, $headers); $de_raw = json_decode($raw, true); - $data = $de_raw['data']; - # 3 放弃 - # 2 否 vote_rule - # 4 删除 vote_delete - # 1 封杀 vote_break - $vote_break = $data['voteBreak']; - $vote_delete = $data['voteDelete']; - $vote_rule = $data['voteRule']; - $num_voted = $vote_break + $vote_delete + $vote_rule; - $ok_percent = $num_voted ? ($vote_rule / $num_voted) : 0; - // 言论合理比例 {$ok_percent} - Log::info("案件 $case_id 目前已投票 $num_voted"); - return [ - 'num_voted' => $num_voted, - 'ok_percent' => $ok_percent - ]; - } - - /** - * @use 随机整数 - * @param int $max - * @return string - */ - private static function randInt(int $max = 17): string - { - $temp = []; - foreach (range(1, $max) as $ignored) { - array_push($temp, mt_rand(0, 9)); + // {"code":25005,"message":"请成为风纪委员后再试","ttl":1} + // {"code":0,"message":"0","ttl":1,"data":{"uname":"","face":"http://i2.hdslb.com/bfs/face/.jpg","case_total":,"term_end":,"status":1}} + if (isset($de_raw['code']) && $de_raw['code']) { + return false; } - return implode("", $temp); - } + // 理论上正常 + if ($de_raw['data']['status'] == 1) { + Log::info('你可以参与社区众裁,共创良好环境哦~'); + return true; + } + return false; - /** - * @use 初始化参数 - */ - private static function initParams() - { - self::$retry_time = 0; - self::$wait_case_id = 0; - self::$wait_time = 0; - self::$min_ok_pct = 1; - self::$max_ok_pct = 0; } /** @@ -310,4 +285,19 @@ class Judge Log::info("今日投票{$sum_cases}({$valid_cases}票有效(非弃权),{$judging_cases}票还在进行中)"); return true; } + + /** + * @use 随机整数 + * @param int $max + * @return string + */ + private static function randInt(int $max = 17): string + { + $temp = []; + foreach (range(1, $max) as $ignored) { + array_push($temp, mt_rand(0, 9)); + } + return implode("", $temp); + } + } \ No newline at end of file