Skip to content

Commit

Permalink
[update] jury leave office
Browse files Browse the repository at this point in the history
  • Loading branch information
lkeme committed Feb 15, 2022
1 parent 2b115f9 commit fee3019
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 31 deletions.
4 changes: 2 additions & 2 deletions conf/bili.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ bili_version: 0.0.1
# Android
bili_a:
package: "tv.danmaku.bili"
version: "6.58.0"
build: "6580300"
version: "6.59.0"
build: "6590300"
channel: "bili"
device: "phone"
mobi_app: "android"
Expand Down
75 changes: 46 additions & 29 deletions src/plugin/Judge.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use BiliHelper\Core\Log;
use BiliHelper\Core\Curl;
use BiliHelper\Util\TimeLock;
use JetBrains\PhpStorm\ArrayShape;

class Judge
{
Expand All @@ -34,6 +33,11 @@ class Judge

use TimeLock;

private static array $default_headers = [
'origin' => 'https://www.bilibili.com',
'referer' => 'https://www.bilibili.com/',
];

private static array $wait_case = [];

/**
Expand Down Expand Up @@ -89,11 +93,11 @@ private static function caseCheck($case_id)
$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]);
self::$wait_case[] = ["id" => $case_id, 'vote' => $vote];
// 尝试修复25018 未测试
self::vote($case_id, 0);

self::setLock(1 * 60 + 5);
self::setLock(60 + 5);
}

/**
Expand All @@ -111,11 +115,7 @@ private static function vote(string $case_id, int $vote)
"anonymous" => 0,
"csrf" => getCsrf(),
];
$headers = [
'origin' => 'https://www.bilibili.com',
'referer' => 'https://www.bilibili.com/',
];
$raw = Curl::post('pc', $url, $payload, $headers);
$raw = Curl::post('pc', $url, $payload, self::$default_headers);
$de_raw = json_decode($raw, true);
// {"code":0,"message":"0","ttl":1}
// {"code":25018,"message":"不能进行此操作","ttl":1}
Expand All @@ -126,6 +126,25 @@ private static function vote(string $case_id, int $vote)
}
}

/**
* @use 申请连任
*/
private static function juryApply()
{
$url = 'https://api.bilibili.com/x/credit/v2/jury/apply';
$payload = [
"csrf" => getCsrf(),
];
$raw = Curl::post('pc', $url, $payload, self::$default_headers);
$de_raw = json_decode($raw, true);
// {"code":0,"message":"0","ttl":1}
if (isset($de_raw['code']) && $de_raw['code']) {
Log::warning("申请连任失败 $raw");
} else {
Log::notice("申请连任成功 $raw");
}
}


/**
* @use 获取众议观点
Expand All @@ -138,11 +157,8 @@ private static function caseOpinion(string $case_id, int $pn = 1, int $ps = 5)
'pn' => $pn,
'ps' => $ps
];
$headers = [
'origin' => 'https://www.bilibili.com',
'referer' => 'https://www.bilibili.com/',
];
$raw = Curl::get('pc', $url, $payload, $headers);

$raw = Curl::get('pc', $url, $payload, self::$default_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']) {
Expand All @@ -164,11 +180,7 @@ private static function caseInfo(string $case_id): mixed
$payload = [
'case_id' => $case_id,
];
$headers = [
'origin' => 'https://www.bilibili.com',
'referer' => 'https://www.bilibili.com/',
];
$raw = Curl::get('pc', $url, $payload, $headers);
$raw = Curl::get('pc', $url, $payload, self::$default_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']) {
Expand All @@ -186,22 +198,24 @@ 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);
$raw = Curl::get('pc', $url, $payload, self::$default_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}
// {"code":25006,"message":"风纪委员资格已过期","ttl":1}
if (isset($de_raw['code']) && $de_raw['code']) {
switch ($de_raw['code']) {
case 25005:
Log::warning($de_raw['message']);
self::setLock(self::timing(10));
break;
case 25006:
Log::warning($de_raw['message']);
Notice::push('jury_leave_office', $de_raw['message']);
self::setLock(self::timing(10));
break;
case 25008:
Log::info("暂时没有新的案件需要审理~ $raw");
break;
Expand Down Expand Up @@ -229,17 +243,20 @@ private static function jury(): bool
{
$url = 'https://api.bilibili.com/x/credit/v2/jury/jury';
$payload = [];
$headers = [
'origin' => 'https://www.bilibili.com',
'referer' => 'https://www.bilibili.com/',
];
$raw = Curl::get('pc', $url, $payload, $headers);
$raw = Curl::get('pc', $url, $payload, self::$default_headers);
$de_raw = json_decode($raw, true);
// {"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;
}
// "status": 1 理论正常
// "status": 2, 没有资格
// "apply_status": -1 已经卸任但未连任
// "apply_status": 0 申请连任后
// "apply_status": 5 审核连任中
// "apply_status": 3 连任成功后

// 理论上正常
if ($de_raw['data']['status'] == 1) {
Log::info('你可以参与社区众裁,共创良好环境哦~');
Expand Down Expand Up @@ -304,7 +321,7 @@ private static function randInt(int $max = 17): string
{
$temp = [];
foreach (range(1, $max) as $ignored) {
array_push($temp, mt_rand(0, 9));
$temp[] = mt_rand(0, 9);
}
return implode("", $temp);
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugin/Notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ private static function sendInfoHandle(string $type, string $uname, string $resu
'title' => '主站九宫格抽奖活动',
'content' => "[$now_time] 用户: $uname 详情: $result"
],
'jury_leave_office' => [
'title' => '已卸任风纪委员',
'content' => "[$now_time] 用户: $uname 详情: $result ,请及时关注风纪委员连任状态哦~"
],
default => [
'title' => '推送消息异常记录',
'content' => "[$now_time] 用户: $uname 推送消息key错误: $type->$result"
Expand Down

0 comments on commit fee3019

Please sign in to comment.