[add] new Plugin@DailyGold@beta

This commit is contained in:
Lkeme 2022-10-31 20:41:46 +08:00
parent e32e36d8bc
commit 5b4de4369e
15 changed files with 335 additions and 34 deletions

View File

@ -16,7 +16,7 @@
<p align="center">
<img src="https://img.shields.io/badge/Version-2.0.2.221025-orange.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/Version-2.0.3.221031-orange.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/PHP-8.1+-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge">
@ -76,23 +76,25 @@ Group: [602815575](https://jq.qq.com/?_wv=1027&k=UaalVexM) | **请不要来问
<details open>
<summary>点击展开</summary>
| 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(小时) | √ |
</details>

View File

@ -8,13 +8,29 @@
[comment]: <> (</details>)
## 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

View File

@ -0,0 +1,151 @@
<?php declare(strict_types=1);
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2022 ~ 2023
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \ & l、
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| | (゚、
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /   \、゙ ~ *
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \  じしf_, )
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
use Bhp\Api\XLive\AppRoom\V1\ApiDM;
use Bhp\Api\XLive\AppUcenter\V1\ApiUserTask;
use Bhp\Log\Log;
use Bhp\Plugin\BasePlugin;
use Bhp\Plugin\Plugin;
use Bhp\TimeLock\TimeLock;
use Bhp\Util\Fake\Fake;
class DailyGold extends BasePlugin
{
/**
* 插件信息
* @var array|string[]
*/
protected ?array $info = [
'hook' => __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;
}
}

View File

@ -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);

View File

@ -111,6 +111,12 @@ lottery_mode = 0
; 直播预约抽奖
live_enable = true
; 每日电池 对应直播间ID和直播间UID
[daily_gold]
enable = false
target_up_id = 11153765
target_room_id = 23058
#######################
# 通知设置 #
#######################

View File

@ -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="

View File

@ -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",

View File

@ -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":""}',
];
/**

View File

@ -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":""}',
];
/**

View File

@ -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"}}

View File

@ -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":""}',
];
/**

View File

@ -0,0 +1,56 @@
<?php declare(strict_types=1);
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2022 ~ 2023
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \ & l、
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| | (゚、
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /   \、゙ ~ *
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \  じしf_, )
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
namespace Bhp\Api\XLive\AppRoom\V1;
use Bhp\Request\Request;
use Bhp\Sign\Sign;
class ApiDM
{
/**
* 发送弹幕(APP)
* @param int $room_id
* @param string $msg
* @return array
*/
public static function sendMsg(int $room_id, string $msg): array
{
$params = [
'aid' => '',
'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);
}
}

View File

@ -0,0 +1,62 @@
<?php declare(strict_types=1);
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2022 ~ 2023
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \ & l、
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| | (゚、
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /   \、゙ ~ *
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \  じしf_, )
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
namespace Bhp\Api\XLive\AppUcenter\V1;
use Bhp\Request\Request;
use Bhp\Sign\Sign;
class ApiUserTask
{
/**
* 获取任务进度
* @return array
*/
public static function getUserTaskProgress(): array
{
$url = 'https://api.live.bilibili.com/xlive/app-ucenter/v1/userTask/GetUserTaskProgress';
$payload = [
'statistics' => 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));
}
}

View File

@ -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;
}
}
}

View File

@ -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)];
}
}
}