diff --git a/README.md b/README.md index fbcde74..ac3ed27 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@

- + @@ -76,23 +76,25 @@ 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(分钟) | √ | -| AwardRecords | 0.0.1 | 获奖记录 | Lkeme | 1111 | 5(分钟) | √ | -| VipPoint | 0.0.1 | 大会员积分 | Lkeme | 1112 | 5(分钟) | √ | +| 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(分钟) | √ | +| VipPoint | 0.0.1 | 大会员积分 | Lkeme | 1112 | 5(分钟) | √ | +| Lotty | 0.0.1 | 抽奖 | MoeHero | 1113 | 5(分钟) | √ | +| DailyGold | 0.0.1 | 每日电池(APP) | Lkeme | 1114 | 24(小时) | √ |
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 64d1525..acccc9e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,13 +8,29 @@ [comment]: <> () +## v2.0.3.221031 alpha (2022-10-31) +### Added + +- 添加每日电池 + +### Changed + +- + +### Fixed + +- + +### Remarks + +- ## v2.0.2.221025 alpha (2022-10-25) ### Added -- +- ### Changed @@ -23,7 +39,6 @@ ### Fixed - 尝试修复主站部分功能`账号异常,操作失败` -- ### Remarks @@ -43,7 +58,6 @@ - 命令行解析錯誤 - 掃碼登錄異常 -- ### Remarks diff --git a/plugin/DailyGold/DailyGold.php b/plugin/DailyGold/DailyGold.php new file mode 100644 index 0000000..4d4af01 --- /dev/null +++ b/plugin/DailyGold/DailyGold.php @@ -0,0 +1,151 @@ + __CLASS__, // hook + 'name' => 'DailyGold', // 插件名称 + 'version' => '0.0.1', // 插件版本 + 'desc' => '每日电池(APP)', // 插件描述 + 'author' => 'Lkeme',// 作者 + 'priority' => 1114, // 插件优先级 + 'cycle' => '24(小时)', // 运行周期 + ]; + + /** + * @param Plugin $plugin + */ + public function __construct(Plugin &$plugin) + { + // 时间锁 + TimeLock::initTimeLock(); + // $this::class + $plugin->register($this, 'execute'); + } + + /** + * 执行 + * @return void + */ + public function execute(): void + { + if (TimeLock::getTimes() > time() || !getEnable('daily_gold')) return; + // + $up_uid = (int)getConf('daily_gold.target_up_id', ''); + $up_room_id = (int)getConf('daily_gold.target_room_id', ''); + if (!$up_room_id || !$up_uid) return; + // + $process = $this->getUserTaskProgress(); + switch ($process) { + case -3: + // 领取完成 + TimeLock::setTimes(TimeLock::timing(7, 0, 0, true)); + break; + case -1: + // 获取失败 + TimeLock::setTimes(10 * 60); + break; + case 0: + // 领取ing + $this->userTaskReceiveRewards($up_uid); + break; + default: + // 默认一次弹幕进度 + $this->sendDM($up_room_id, Fake::emoji(true)); + TimeLock::setTimes(mt_rand(30, 60) * 60); + break; + } + } + + /** + * 获取任务进度 + * @return int + */ + protected function getUserTaskProgress(): int + { + $response = ApiUserTask::getUserTaskProgress(); + if ($response['code']) { + Log::warning("每日电池: 获取任务进度失败 {$response['code']} -> {$response['message']}"); + return -1; + } + // + $target = (int)$response['data']['target']; + $progress = (int)$response['data']['progress']; + Log::info("每日电池: 当前任务进度 $progress/$target"); + // 领取完成 + if ($response['data']['status'] == 3) { + return -3; + } + // 可以领取 +// if ($response['data']['status'] == 2) { +// return 0; +// } + return (int)($response['data']['target'] - $response['data']['progress']); + } + + /** + * 发送弹幕(外部调用APP) + * @param int $room_id + * @param string $msg + * @return bool + */ + protected function sendDM(int $room_id, string $msg): bool + { + $response = ApiDM::sendMsg($room_id, $msg); + if ($response['code']) { + Log::warning("每日电池: 发送弹幕失败 {$response['code']} -> {$response['message']}"); + return false; + } + // + Log::info('每日电池: 发送弹幕成功'); + return true; + } + + /** + * 领取任务奖励 + * @param int $up_id + * @return bool + */ + protected function userTaskReceiveRewards(int $up_id): bool + { + $response = ApiUserTask::userTaskReceiveRewards($up_id); + if ($response['code']) { + Log::warning("每日电池: 领取任务奖励失败 {$response['code']} -> {$response['message']}"); + return false; + } + // + Log::notice("每日电池: 领取任务奖励成功 获得电池*{$response['data']['num']}"); + return true; + + } + +} + + diff --git a/plugin/Login/Login.php b/plugin/Login/Login.php index cc7b5a1..60d54b5 100644 --- a/plugin/Login/Login.php +++ b/plugin/Login/Login.php @@ -569,7 +569,7 @@ class Login extends BasePlugin $payload = [ 'cid' => $cid, 'tel' => $phone, - 'statistics' => '{"appId":1,"platform":3,"version":"6.86.0","abtest":""}', + 'statistics' => getDevice('app.bili_a.statistics'), ]; $raw = ApiLogin::sendSms($payload); diff --git a/profile/example/config/user.ini b/profile/example/config/user.ini index c8c3b3c..4a75df2 100644 --- a/profile/example/config/user.ini +++ b/profile/example/config/user.ini @@ -111,6 +111,12 @@ lottery_mode = 0 ; 直播预约抽奖 live_enable = true +; 每日电池 对应直播间ID和直播间UID +[daily_gold] +enable = false +target_up_id = 11153765 +target_room_id = 23058 + ####################### # 通知设置 # ####################### diff --git a/profile/example/device/device.yaml b/profile/example/device/device.yaml index 9d5651f..4227f1e 100644 --- a/profile/example/device/device.yaml +++ b/profile/example/device/device.yaml @@ -3,8 +3,8 @@ device_version: 0.0.1 app: bili_a: # Android package: "tv.danmaku.bili" - version: "6.86.0" - build: "6860300" + version: "7.3.0" + build: "7030300" channel: "bili" device: "phone" mobi_app: "android" @@ -15,6 +15,7 @@ app: secret_key: "NTYwYzUyY2NkMjg4ZmVkMDQ1ODU5ZWQxOGJmZmQ5NzM" app_key_n: "NzgzYmJiNzI2NDQ1MWQ4Mg==" secret_key_n: "MjY1MzU4M2M4ODczZGVhMjY4YWI5Mzg2OTE4YjFkNjU=" + statistics: '{"appId":1,"platform":3,"version":"7.3.0","abtest":""}' bili_i: # IOS app_key: "MjdlYjUzZmM5MDU4ZjhjMw==" secret_key: "YzJlZDUzYTc0ZWVlZmUzY2Y5OWZiZDAxZDhjOWMzNzU=" diff --git a/resources/version.json b/resources/version.json index 6133c6e..519633d 100644 --- a/resources/version.json +++ b/resources/version.json @@ -7,7 +7,7 @@ "dev_raw_url": "https://gh.notifyplus.cf/https://github.com/lkeme/BiliHelper-personal/blob/dev/resources/version.json", "master_purge_url": "https://cdn.staticaly.com/gh/lkeme/BiliHelper-personal/master/resources/version.json", "dev_purge_url": "https://cdn.staticaly.com/gh/lkeme/BiliHelper-personal/dev/resources/version.json", - "version": "2.0.2.221025", + "version": "2.0.3.221031", "des": "程序有更新,请及时线上查看更新哦~", "time": "2022年10月25日", "ini_version": "0.0.1", diff --git a/src/Api/Api/Pgc/Activity/Deliver/ApiTask.php b/src/Api/Api/Pgc/Activity/Deliver/ApiTask.php index 56724bf..d956633 100644 --- a/src/Api/Api/Pgc/Activity/Deliver/ApiTask.php +++ b/src/Api/Api/Pgc/Activity/Deliver/ApiTask.php @@ -34,7 +34,7 @@ class ApiTask * @var array|string[] */ protected static array $payload = [ - 'statistics' => '{"appId":1,"platform":3,"version":"6.86.0","abtest":""}', + 'statistics' => '{"appId":1,"platform":3,"version":"7.3.0","abtest":""}', ]; /** diff --git a/src/Api/Api/Pgc/Activity/Score/ApiTask.php b/src/Api/Api/Pgc/Activity/Score/ApiTask.php index 0d62714..8050922 100644 --- a/src/Api/Api/Pgc/Activity/Score/ApiTask.php +++ b/src/Api/Api/Pgc/Activity/Score/ApiTask.php @@ -34,7 +34,7 @@ class ApiTask * @var array|string[] */ protected static array $payload = [ - 'statistics' => '{"appId":1,"platform":3,"version":"6.86.0","abtest":""}', + 'statistics' => '{"appId":1,"platform":3,"version":"7.3.0","abtest":""}', ]; /** diff --git a/src/Api/Passport/ApiLogin.php b/src/Api/Passport/ApiLogin.php index 29d17b7..ddd7a24 100644 --- a/src/Api/Passport/ApiLogin.php +++ b/src/Api/Passport/ApiLogin.php @@ -60,7 +60,7 @@ class ApiLogin // $payload = [ // 'cid' => $cid, // 'tel' => $phone, -// 'statistics' => '{"appId":1,"platform":3,"version":"6.86.0","abtest":""}', +// 'statistics' => '{"appId":1,"platform":3,"version":"7.3.0","abtest":""}', // ]; // {"code":0,"message":"0","ttl":1,"data":{"is_new":false,"captcha_key":"4e292933816755442c1568e2043b8e41","recaptcha_url":""}} // {"code":0,"message":"0","ttl":1,"data":{"is_new":false,"captcha_key":"","recaptcha_url":"https://www.bilibili.com/h5/project-msg-auth/verify?ct=geetest\u0026recaptcha_token=ad520c3a4a3c46e29b1974d85efd2c4b\u0026gee_gt=1c0ea7c7d47d8126dda19ee3431a5f38\u0026gee_challenge=c772673050dce482b9f63ff45b681ceb\u0026hash=ea2850a43cc6b4f1f7b925d601098e5e"}} diff --git a/src/Api/Show/Api/Activity/Fire/Common/ApiEvent.php b/src/Api/Show/Api/Activity/Fire/Common/ApiEvent.php index 222c9a3..0641ce3 100644 --- a/src/Api/Show/Api/Activity/Fire/Common/ApiEvent.php +++ b/src/Api/Show/Api/Activity/Fire/Common/ApiEvent.php @@ -35,7 +35,7 @@ class ApiEvent * @var array|string[] */ protected static array $payload = [ - 'statistics' => '{"appId":1,"platform":3,"version":"6.86.0","abtest":""}', + 'statistics' => '{"appId":1,"platform":3,"version":"7.3.0","abtest":""}', ]; /** diff --git a/src/Api/XLive/AppRoom/V1/ApiDM.php b/src/Api/XLive/AppRoom/V1/ApiDM.php new file mode 100644 index 0000000..bc70e02 --- /dev/null +++ b/src/Api/XLive/AppRoom/V1/ApiDM.php @@ -0,0 +1,56 @@ + '', + 'page' => '1', + //'statistics' => getDevice('app.bili_a.statistics'), + ]; + $url = 'https://api.live.bilibili.com/xlive/app-room/v1/dM/sendmsg?' . http_build_query(Sign::common($params)); + $payload = [ + "cid" => $room_id, + "msg" => $msg, + "rnd" => time(), + "color" => "16777215", + "fontsize" => "25", + ]; + $headers = [ + 'content-type' => 'application/x-www-form-urlencoded', + ]; + + // {"code":0,"data":{"mode_info":{"extra":"{\"send_from_me\":true,\"mode\":0,\"color\":16777215,\"dm_type\":0,\"font_size\":25,\"player_mode\":1,\"show_player_type\":0,\"content\":\"1\",\"user_hash\":\"111111\",\"emoticon_unique\":\"\",\"bulge_display\":0,\"recommend_score\":8,\"main_state_dm_color\":\"\",\"objective_state_dm_color\":\"\",\"direction\":0,\"pk_direction\":0,\"quartet_direction\":0,\"anniversary_crowd\":0,\"yeah_space_type\":\"\",\"yeah_space_url\":\"\",\"jump_to_url\":\"\",\"space_type\":\"\",\"space_url\":\"\"}","mode":0,"show_player_type":0}},"message":"","msg":""} + return Request::postJson(true, 'app', $url, $payload, $headers); + } +} + + diff --git a/src/Api/XLive/AppUcenter/V1/ApiUserTask.php b/src/Api/XLive/AppUcenter/V1/ApiUserTask.php new file mode 100644 index 0000000..20e5d00 --- /dev/null +++ b/src/Api/XLive/AppUcenter/V1/ApiUserTask.php @@ -0,0 +1,62 @@ + getDevice('app.bili_a.statistics'), + ]; + + // 已领取 {"code":0,"message":"0","ttl":1,"data":{"is_surplus":1,"status":3,"progress":5,"target":5,"wallet":{"gold":100,"silver":130},"linked_actions_progress":null}} + // 可领取 {"code":0,"message":"0","ttl":1,"data":{"is_surplus":1,"status":2,"progress":5,"target":5,"wallet":{"gold":0,"silver":130},"linked_actions_progress":null}} + // 进行中 {"code":0,"message":"0","ttl":1,"data":{"is_surplus":1,"status":1,"progress":4,"target":5,"wallet":{"gold":0,"silver":130},"linked_actions_progress":null}} + // 未开始 {"code":0,"message":"0","ttl":1,"data":{"is_surplus":1,"status":0,"progress":0,"target":5,"wallet":{"gold":0,"silver":130},"linked_actions_progress":null}} + return Request::getJson(true, 'app', $url, Sign::common($payload)); + } + + + /** + * 获取任务奖品 + * @param int $up_id + * @return array + */ + public static function userTaskReceiveRewards(int $up_id): array + { + $url = 'https://api.live.bilibili.com/xlive/app-ucenter/v1/userTask/UserTaskReceiveRewards'; + $payload = [ + 'target_id' => $up_id, + 'statistics' => getDevice('app.bili_a.statistics'), + ]; + + // {"code":0,"message":"0","ttl":1,"data":{"num":1}} + return Request::postJson(true, 'app', $url, Sign::common($payload)); + } + +} + diff --git a/src/Sign/Sign.php b/src/Sign/Sign.php index 7a90422..cd14e6e 100644 --- a/src/Sign/Sign.php +++ b/src/Sign/Sign.php @@ -49,6 +49,9 @@ class Sign extends SingleTon 'device' => getDevice('app.bili_a.device'), 'mobi_app' => getDevice('app.bili_a.mobi_app'), 'platform' => getDevice('app.bili_a.platform'), + 'c_locale' => 'zh_CN', // zh-Hans_CH + 's_locale' => 'zh_CN', // zh-Hans_CH + 'disable_rcmd' => '0', // 'ts' => time(), ]; // @@ -112,6 +115,9 @@ class Sign extends SingleTon 'device' => getDevice('app.bili_a.device'), 'mobi_app' => getDevice('app.bili_a.mobi_app'), 'platform' => getDevice('app.bili_a.platform'), + 'c_locale' => 'zh_CN', // zh-Hans_CH + 's_locale' => 'zh_CN', // zh-Hans_CH + 'disable_rcmd' => '0', // 'ts' => time(), ]; $payload = array_merge($payload, $default); @@ -135,4 +141,4 @@ class Sign extends SingleTon return $payload; } -} \ No newline at end of file +} diff --git a/src/Util/Fake/Fake.php b/src/Util/Fake/Fake.php index 587fd56..d91a811 100644 --- a/src/Util/Fake/Fake.php +++ b/src/Util/Fake/Fake.php @@ -94,9 +94,10 @@ class Fake /** * 获取颜文字信息 + * @param bool $full * @return string */ - public static function emoji(): string + public static function emoji(bool $full = false): string { $emoji_list_all = [ "(⌒▽⌒)", "( ̄▽ ̄)", "(=・ω・=)", "(`・ω・´)", "(〜 ̄△ ̄)〜", "(・∀・)", @@ -105,15 +106,17 @@ class Fake "(´;ω;`)", "(/TДT)/", "(^・ω・^ )", "(。・ω・。)", "(● ̄(エ) ̄●)", "ε=ε=(ノ≧∇≦)ノ", "(´・_・`)", "(-_-#)", "( ̄へ ̄)", "( ̄ε(# ̄) Σ", "ヽ(`Д´)ノ", "(#-_-)┯━┯", "(╯°口°)╯(┴—┴", "←◡←", "( ♥д♥)", "Σ>―(〃°ω°〃)♡→", "⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄", - "(╬゚д゚)▄︻┻┳═一", "・*・:≡( ε:)", "(打卡)", "(签到)" + "(╬゚д゚)▄︻┻┳═一", "・*・:≡( ε:)", "(打卡)", "(签到)", "(⌒▽⌒)", "( ̄▽ ̄)", "(=・ω・=)", "(`・ω・´)", "(〜 ̄△ ̄)〜", "(・∀・)", "(°∀°)ノ", "( ̄3 ̄)", "╮( ̄▽ ̄)╭", "_(:3」∠)_", "( ´_ゝ`)", "←_←", "→_→", "(<_<)", "(>_>)", "(;¬_¬)", '("▔□▔)/', "(゚Д゚≡゚д゚)!?", "Σ(゚д゚;)", "Σ(  ̄□ ̄||)", "(´;ω;`)", "(/TДT)/", "(^・ω・^ )", "(。・ω・。)", "(● ̄(エ) ̄●)", "ε=ε=(ノ≧∇≦)ノ", "(´・_・`)", "(-_-#)", "( ̄へ ̄)", "( ̄ε(# ̄) Σ", "ヽ(`Д´)ノ", "(#-_-)┯━┯", "(╯°口°)╯(┴—┴", "←◡←", "( ♥д♥)", "Σ>―(〃°ω°〃)♡→", "⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄", "(╬゚д゚)▄︻┻┳═一", "・*・:≡( ε:)", "(汗)", "(苦笑)" ]; - $emoji_list = [ + $emoji_list_part = [ "(⌒▽⌒)", "( ̄▽ ̄)", "(=・ω・=)", "(`・ω・´)", "(〜 ̄△ ̄)〜", "╮( ̄▽ ̄)╭", "_(:3」∠)_", "( ´_ゝ`)", "(● ̄(エ) ̄●)", "(・∀・)", "(´・_・`)", "( ̄へ ̄)", "(打卡)", "(签到)" ]; + $emoji_list = $full ? $emoji_list_all : $emoji_list_part; + shuffle($emoji_list); return $emoji_list[array_rand($emoji_list)]; } -} \ No newline at end of file +}