Skip to content

Commit

Permalink
[update] Version 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lkeme committed Jul 30, 2020
1 parent 8a38ad8 commit 962b7d4
Show file tree
Hide file tree
Showing 14 changed files with 538 additions and 63 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Release Notes
# 本项目Log

## v0.6.0.200730 alpha (2020-07-30)

### Added
- 添加小心心支持
-

### Changed
- 更新天选过滤关键词
-

### Fixed
- 修复节奏风暴逻辑错误
-

## v0.5.0.200625 alpha (2020-06-25)

### Added
Expand Down
55 changes: 28 additions & 27 deletions DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p align="center"><img width="300px" src="https://i.loli.net/2018/04/20/5ad97bd395912.jpeg"></p>

<p align="center">
<img src="https://img.shields.io/badge/version-0.5.0.200625 alpha-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/version-0.6.0.200730 alpha-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/license-mit-blue.svg?longCache=true&style=for-the-badge">
</p>

Expand All @@ -15,32 +15,33 @@ B 站直播实用脚本

|plugin |version |description |
|--------------------|--------------------|--------------------|
|Login |20.06.24 |账号登录 |
|Schedule |20.06.24 |休眠控制 |
|MasterSite |20.06.24 |主站助手 |
|Daily |20.06.24 |每日礼包 |
|Heart |20.06.24 |双端心跳 |
|Task |20.06.24 |每日任务 |
|Silver |20.06.24 |银瓜子宝箱 |
|Barrage |20.06.24 |活跃弹幕 |
|Silver2Coin |20.06.24 |银瓜子换硬币 |
|GiftSend |20.06.24 |礼物赠送 |
|Judge |20.06.24 |风纪 |
|GroupSignIn |20.06.24 |友爱社签到 |
|ManGa |20.06.24 |漫画签到分享 |
|Match |20.06.24 |赛事签到分享 |
|GiftHeart |20.06.24 |心跳礼物 |
|MaterialObject |20.06.24 |实物抽奖 |
|AloneTcpClient |20.06.24 |独立监控 |
|ZoneTcpClient |20.06.24 |分区监控 |
|StormRaffle |20.06.24 |节奏风暴 |
|GiftRaffle |20.06.24 |活动礼物 |
|PkRaffle |20.06.24 |大乱斗 |
|GuardRaffle |20.06.24 |舰长总督 |
|AnchorRaffle |20.06.24 |天选时刻 |
|AwardRecord |20.06.24 |获奖通知 |
|Statistics |20.06.24 |数据统计 |
|Competition |20.06.24 |赛事竞猜 |
|Login |20.07.30 |账号登录 |
|Schedule |20.07.30 |休眠控制 |
|MasterSite |20.07.30 |主站助手 |
|Daily |20.07.30 |每日礼包 |
|Heart |20.07.30 |双端心跳 |
|Task |20.07.30 |每日任务 |
|Silver |20.07.30 |银瓜子宝箱 |
|Barrage |20.07.30 |活跃弹幕 |
|Silver2Coin |20.07.30 |银瓜子换硬币 |
|GiftSend |20.07.30 |礼物赠送 |
|Judge |20.07.30 |风纪 |
|GroupSignIn |20.07.30 |友爱社签到 |
|ManGa |20.07.30 |漫画签到分享 |
|Match |20.07.30 |赛事签到分享 |
|GiftHeart |20.07.30 |心跳礼物 |
|MaterialObject |20.07.30 |实物抽奖 |
|AloneTcpClient |20.07.30 |独立监控 |
|ZoneTcpClient |20.07.30 |分区监控 |
|StormRaffle |20.07.30 |节奏风暴 |
|GiftRaffle |20.07.30 |活动礼物 |
|PkRaffle |20.07.30 |大乱斗 |
|GuardRaffle |20.07.30 |舰长总督 |
|AnchorRaffle |20.07.30 |天选时刻 |
|AwardRecord |20.07.30 |获奖通知 |
|Statistics |20.07.30 |数据统计 |
|Competition |20.07.30 |赛事竞猜 |
|SmallHeart |20.07.30 |小心心 |

## 打赏赞助

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **仅用于BUG提交

## 公告

> Currently for Personal Edition **0.5.0.200625 alpha**
> Currently for Personal Edition **0.6.0.200730 alpha**
```notice
---- 免费的东西总是得不到人的珍惜。
Expand All @@ -28,4 +28,3 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) | **仅用于BUG提交
## 效果

![](https://i.loli.net/2019/07/13/5d296961a4bae41364.png)

6 changes: 5 additions & 1 deletion conf/user.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ USE_SC=false
SC_KEY=
SC_FILTER_WORDS=

# 小心心|加密服务器(开源)|
USE_HEARTBEAT=true
ENC_SERVER=http://116.85.43.27:3000/enc

#######################
# 房间设置 #
#######################
Expand Down Expand Up @@ -154,4 +158,4 @@ APP_CALLBACK="http://www.example.com/api.send?text={account}[{level}]: {message}
# WARNING 300
# ERROR 400
#
APP_CALLBACK_LEVEL=400
APP_CALLBACK_LEVEL=400
1 change: 1 addition & 0 deletions src/core/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function start()
'GiftSend',
'GroupSignIn',
'GiftHeart',
'SmallHeart',
'MaterialObject',
'AloneTcpClient',
'ZoneTcpClient',
Expand Down
2 changes: 1 addition & 1 deletion src/core/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class Env
{
private $app_name = 'BiliHelper Personal';
private $app_version = '0.5.0.*';
private $app_version = '0.6.0.*';

/**
* Env constructor.
Expand Down
9 changes: 8 additions & 1 deletion src/plugin/AnchorRaffle.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ protected static function filterPrizeWords(string $prize_name): bool
'房间抽奖', 'CESHI', 'ceshi', '奖品A', '奖品B', '奖品C', '硬币', '无奖品', '白名单', '我是抽奖',
'0.1', '五毛二', '一分', '一毛', '0.52', '0.66', '0.01', '0.77', '0.16', '照片', '穷', '0.5',
'0.88', '双排', '1毛', '1分', '1角', 'P口罩', '素颜', '写真', '图包', '五毛', '一角', '冥币',
'自拍', '日历', '0.22', '加速器', '越南盾'
'自拍', '日历', '0.22', '加速器', '越南盾','毛','分','限','0.','角','〇点','①元',
'一起玩','不包邮','邮费','续期卡','儿时','闪宠','大师球','一元','两元','两块','赛车',
'代币','一块','一局','好友位','通话','首胜','代金券','辣条','补贴','抵用券','主播素颜照',
'武器箱棺材板','游戏道具','优惠券','日元','发音课','壹元','零点','舰长五折券','上车',
'没有钱','女装','肥宅快乐水','哥斯拉','公主连结','pokemmo','宝可>梦','明日方舟','雪碧','公主连接',
'专属头衔','FF14','韩元','空洞骑士','老婆饼','稀世时装','洛克衣服','帮过图','证件照','自抽号',
'晶耀之星','伊洛纳','〇.','②元','③元','0·','繁华美化','喵喵喵','闪伊布','①圆','o点','金达摩','嗷呜',
'游戏位','S-追光者','OWL','勾玉','跟yo宝游戏','三元','怡宝','蛋闪迷>你冰','哥伦比亚比索','油条'
];
$custom_words = empty(getenv('ANCHOR_FILTER_WORDS')) ? [] : explode(',', getenv('ANCHOR_FILTER_WORDS'));
$total_words = array_merge($default_words, $custom_words);
Expand Down
41 changes: 14 additions & 27 deletions src/plugin/GiftSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,35 +180,22 @@ protected static function checkExpireGift(array $bag_list): array
protected static function getMedalList()
{
self::$medal_list = [];
$url = 'https://api.live.bilibili.com/i/api/medal';
$payload = [
'page' => 1,
'pageSize' => 25
];
$data = Curl::get('app', $url, Sign::common($payload));
$data = json_decode($data, true);
if (isset($data['code']) && $data['code']) {
Log::warning('获取勋章列表失败!', ['msg' => $data['message']]);
return;
$data = Live::fetchMedalList();
$fans_medals = [];
foreach ($data as $vo) {
if (!isset($vo['roomid'])) continue;
$fans_medals[(string)$vo['roomid']] = $vo;
}
Log::info('勋章列表获取成功!');
if (isset($data['data']['fansMedalList'])) {
$fans_medals = [];
foreach ($data['data']['fansMedalList'] as $vo) {
if (!isset($vo['roomid'])) continue;
$fans_medals[(string)$vo['roomid']] = $vo;
// 基于配置
foreach (self::$room_list as $room_id) {
// 配置是否存在获取
if (!array_key_exists((string)$room_id, $fans_medals)) {
continue;
}
// 基于配置
foreach (self::$room_list as $room_id) {
// 配置是否存在获取
if (!array_key_exists((string)$room_id, $fans_medals)) {
continue;
}
$vo = $fans_medals[(string)$room_id];
// 是否还需要投喂
if ($vo['day_limit'] - $vo['today_feed']) {
self::$medal_list[(string)$vo['roomid']] = ($vo['day_limit'] - $vo['today_feed']);
}
$vo = $fans_medals[(string)$room_id];
// 是否还需要投喂
if ($vo['day_limit'] - $vo['today_feed']) {
self::$medal_list[(string)$vo['roomid']] = ($vo['day_limit'] - $vo['today_feed']);
}
}
}
Expand Down
112 changes: 110 additions & 2 deletions src/plugin/Live.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public static function getDanMuInfo($room_id): array
*/
public static function webGetRoomInfo($room_id): array
{
$url = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom?=23058';
$url = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom';
$payload = [
'room_id' => $room_id
];
Expand Down Expand Up @@ -266,4 +266,112 @@ public static function sendBarrage(int $room_id, string $content): array
return json_decode($raw, true) ?? ['code' => 404, 'msg' => '上层数据为空!'];
}

}

/**
* @use 获取勋章列表
* @param int $page_size
* @return array
*/
public static function fetchMedalList(int $page_size = 100): array
{
$metal_list = [];
for ($i = 1; $i <= 10; $i++) {
$url = 'https://api.live.bilibili.com/i/api/medal';
$payload = [
'page' => $i,
'pageSize' => $page_size
];
$raw = Curl::get('app', $url, Sign::common($payload));
$de_raw = json_decode($raw, true);
if (isset($data['code']) && $data['code']) {
Log::warning('获取勋章列表失败!', ['msg' => $data['message']]);
return $metal_list;
}
if (empty($de_raw['data']['fansMedalList'])) {
return $metal_list;
}
if (isset($de_raw['data']['fansMedalList'])) {
foreach ($de_raw['data']['fansMedalList'] as $vo) {
array_push($metal_list, $vo);
}
}
if ($de_raw['data']['pageinfo']['totalpages'] == $de_raw['data']['pageinfo']['curPage']) {
return $metal_list;
}
}
Log::info('勋章列表获取成功!');
return $metal_list;
}

/**
* @use 背包获取单项礼物
* @param string $gift_name
* @param int $gift_id
* @return array
*/
public static function fetchBagListByGift(string $gift_name, int $gift_id): array
{
$new_bag_list = [];
$payload = [];
$url = 'https://api.live.bilibili.com/gift/v2/gift/bag_list';
$data = Curl::get('app', $url, Sign::common($payload));
$data = json_decode($data, true);
if (isset($data['code']) && $data['code']) {
Log::warning('背包查看失败!', ['msg' => $data['message']]);
return $new_bag_list;
}
if (isset($data['data']['list'])) {
$bag_list = $data['data']['list'];
if (count($bag_list)) {
// 按过期时间 升序
// array_multisort(array_column($bag_list, "gift_id"), SORT_DESC, $bag_list);
array_multisort(array_column($bag_list, "expire_at"), SORT_ASC, $bag_list);
}
foreach ($bag_list as $vo) {
// 去除永久礼物
if ($vo['corner_mark'] == '永久') continue;
if ($vo['gift_id'] == $gift_id && $vo['gift_name'] == $gift_name){
array_push($new_bag_list, $vo);
}
}
}
return $new_bag_list;
}

/**
* @use 赠送礼物
* @param array $guest // 用户信息
* @param array $gift // 礼物信息
* @param int $num // 数量
*/
public static function sendGift(array $guest, array $gift, int $num)
{
$url = 'https://api.live.bilibili.com/gift/v2/live/bag_send';
$user_info = User::parseCookies();
$payload = [
'uid' => $user_info['uid'], // 自己的UID
'gift_id' => $gift['gift_id'],
'ruid' => $guest['uid'], // UP的UID
'send_ruid' => 0,
'gift_num' => $num,
'bag_id' => $gift['bag_id'],
'platform' => 'pc',
'biz_code' => 'live',
'biz_id' => $guest['roomid'], // UP的直播间
'rnd' => time(), // 时间戳
'storm_beat_id' => 0,
'metadata' => '',
'price' => 0,
'csrf' => $user_info['token'],
'csrf_token' => $user_info['token']
];
// {"code":0,"msg":"success","message":"success","data":{"tid":"1595419985112400002","uid":4133274,"uname":"沙奈之朵","face":"https://i2.hdslb.com/bfs/face/eb101ef90ebc4e9bf79f65312a22ebac84946700.jpg","guard_level":0,"ruid":893213,"rcost":30834251,"gift_id":30607,"gift_type":5,"gift_name":"小心心","gift_num":1,"gift_action":"投喂","gift_price":5000,"coin_type":"silver","total_coin":5000,"pay_coin":5000,"metadata":"","fulltext":"","rnd":"1595419967","tag_image":"","effect_block":1,"extra":{"wallet":null,"gift_bag":{"bag_id":210196588,"gift_num":20},"top_list":[],"follow":null,"medal":null,"title":null,"pk":{"pk_gift_tips":"","crit_prob":0},"fulltext":"","event":{"event_score":0,"event_redbag_num":0},"capsule":null},"blow_switch":0,"send_tips":"赠送成功","gift_effect":{"super":0,"combo_timeout":0,"super_gift_num":0,"super_batch_gift_num":0,"batch_combo_id":"","broadcast_msg_list":[],"small_tv_list":[],"beat_storm":null,"smallTVCountFlag":true},"send_master":null,"crit_prob":0,"combo_stay_time":3,"combo_total_coin":0,"demarcation":2,"magnification":1,"combo_resources_id":1,"is_special_batch":0,"send_gift_countdown":6}}
$data = Curl::post('app', $url, Sign::common($payload));
$data = json_decode($data, true);
if (isset($data['code']) && $data['code']) {
Log::warning('送礼失败!', ['msg' => $data['message']]);
} else {
Log::notice("成功向 {$payload['biz_id']} 投喂了 {$num}{$gift['gift_name']}");
}
}
}
2 changes: 1 addition & 1 deletion src/plugin/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ private static function accountLogin(string $validate = '', string $challenge =
'seccode' => $validate ? "{$validate}|jordan" : '',
'validate' => $validate,
'challenge' => $challenge,
'subid' => 1,
'permission' => 'ALL',
'username' => self::$username,
'password' => self::$password,
'captcha' => '',
'subid' => 1,
'cookies' => ''
];
$raw = Curl::post('app', $url, Sign::login($payload));
Expand Down
Loading

0 comments on commit 962b7d4

Please sign in to comment.