Skip to content

Commit

Permalink
🍒 0.8.0 新增小电视抽奖功能
Browse files Browse the repository at this point in the history
  • Loading branch information
metowolf committed May 4, 2018
1 parent 5e9e89d commit cffd847
Show file tree
Hide file tree
Showing 19 changed files with 519 additions and 83 deletions.
7 changes: 0 additions & 7 deletions .env

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Release Notes

## v0.8.0 (2018-05-04)

**该版本为非兼容更新,从 0.7.x 升级需要重新覆盖配置文件**

### Added
- 新增小电视抽奖功能 ([#18](https://github.com/metowolf/BilibiliHelper/issues/18))
- 新增配置项检测

### Changed
- 修改部分时间锁逻辑
- 修改部分日志提示

## v0.7.3 (2018-04-28)

### Added
Expand Down
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ SOFTWARE.

------------------------------------------------------------------------------------

https://github.com/copyliu/bililive_dm

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

------------------------------------------------------------------------------------

And wait, the most important, you shall star/+1/like the project(s) in project url
section above first, and then thank the author(s) in Copyright section.

Expand Down
39 changes: 32 additions & 7 deletions README.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.7.3-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/version-0.8.0-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 @@ -14,27 +14,30 @@ B 站直播实用脚本

|plugin |version |description |
|---------|---------|--------------|
|Daily |18.04.21 |每日背包奖励 |
|GiftSend |18.04.21 |自动清空过期礼物 |
|Heart |18.04.21 |双端直播间心跳 |
|Login |18.04.25 |帐号登录组件 |
|Silver |18.04.21 |自动领宝箱 |
|Daily |18.05.04 |每日背包奖励 |
|GiftSend |18.05.04 |自动清空过期礼物 |
|Heart |18.05.04 |双端直播间心跳 |
|Login |18.05.04 |帐号登录组件 |
|Silver |18.05.04 |自动领宝箱 |
|SmallTV |18.05.04 |小电视抽奖 |
|Task |18.04.21 |每日任务 |


## 未完成功能
|待续|
|-------|
|总督检测|
|节奏风暴|
|抽小电视|
|应援团签到|


## 环境依赖
|Requirement|
|-------|
|PHP (>=5.6 or >=7.0)|
|php-openssl|
|php-curl|
|php-sockets|

通常使用 `composer` 工具会自动检测上述依赖问题。

Expand All @@ -61,13 +64,19 @@ $ php index.php
<p align="center"><img width="680px" src="https://i.loli.net/2018/04/21/5adb497dc3ece.png"></p>

## 升级指南

1. 进入项目目录
```
$ cd BilibiliHelper
```
2. 拉取最新代码
```
$ git pull
```
**大版本更新需要重新覆盖配置文件,并重新填写设置**
```
$ mv config config.old
$ cp config.example config
```
3. 更新依赖库
```
Expand Down Expand Up @@ -148,6 +157,22 @@ http://live.bilibili.com/3746256
所有直播间号码小于 1000 的直播间为短号,该脚本在每次启动会自动修正,无需关心,


## 小电视抽奖
config 文件中开放了三个相关设置,这里作下说明

|key|description|
|---|---|
|SOCKET_ROOM_ID|弹幕监控直播间,这里通常选择音乐台等 24 小时直播,并且弹幕较少的房间,例如 23058|
|SMALLTV_RATE|小电视抽奖的比率,可以设置 0-100 的整数,作用是随机加入抽奖的概率|
|SMALLTV_HOURS|小电视抽奖的时段,采用 24 小时制,通常设置为正常人看直播的时段,数字间用英文逗号隔开|



## 分支
- 多帐号 https://github.com/NeverBehave/BilibiliHelper
- lkeme https://github.com/lkeme/BiliHelper


## License 许可证

本项目基于 MIT 协议发布,并增加了 SATA 协议。
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"php": ">=5.4.0",
"ext-curl": "*",
"ext-openssl": "*",
"ext-sockets": "*",
"vlucas/phpdotenv": "^2.4",
"monolog/monolog": "^1.23",
"bramus/monolog-colored-line-formatter": "^2.0"
Expand Down
5 changes: 3 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 36 additions & 14 deletions config.example
Original file line number Diff line number Diff line change
@@ -1,30 +1,52 @@
#######################
# 账户设置 #
#######################

# 帐号
APP_USER=

# 多账号区别输出
APP_MULTIPLE=false
# 账号别名,如果为空则默认使用登陆账号作为标示
APP_USER_IDENTITY=

# 密码
APP_PASS=

# 自动生成
# 令牌(自动生成
ACCESS_TOKEN=
REFRESH_TOKEN=

#######################
# 功能设置 #
#######################

# 礼物赠送直播间
ROOM_ID=3746256

# 弹幕监控直播间
SOCKET_ROOM_ID=23058

# 小电视百分比
SMALLTV_RATE=0

# 小电视时间段
SMALLTV_HOURS=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23

#######################
# 日志设置 #
#######################

# 调试模式
APP_DEBUG=true

# 直播间ID,用于礼物赠送
ROOM_ID=3746256
# 多账号区别输出
APP_MULTIPLE=false

# 账号别名,如果为空则默认使用登陆账号作为标示
APP_USER_IDENTITY=

# 日志回调地址
# 渲染参数
# {level} 日志等级
# {account} 账号标识符
# {message} 日志信息
APP_CALLBACK="http://www.example.com/api.send?text=[{level}]: {message}"
#
# {level} 日志等级
# {message} 日志信息
#
CALLBACK_URL="http://www.example.com/api.send?text=[{level}]: {message}"

# 错误回调级别
#
Expand All @@ -34,4 +56,4 @@ APP_CALLBACK="http://www.example.com/api.send?text=[{level}]: {message}"
# WARNING 300
# ERROR 400
#
APP_CALLBACK_LEVEL=400
CALLBACK_LEVEL=400
26 changes: 9 additions & 17 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,37 @@
/*!
* metowolf BilibiliHelper
* https://i-meto.com/
* Version 18.04.25 (0.7.3)
* Version 18.05.04 (0.8.0)
*
* Copyright 2018, metowolf
* Released under the MIT license
*/

require 'vendor/autoload.php';

use Dotenv\Dotenv;
use metowolf\Bilibili\Loader;
use metowolf\Bilibili\Curl;
use metowolf\Bilibili\Daily;
use metowolf\Bilibili\GiftSend;
use metowolf\Bilibili\Heart;
use metowolf\Bilibili\Login;
use metowolf\Bilibili\Silver;
use metowolf\Bilibili\SmallTV;
use metowolf\Bilibili\Task;

// timezone
date_default_timezone_set('Asia/Shanghai');
Loader::config();

// load config
$dotenv = new Dotenv(__DIR__, '.env');
$dotenv->load();
$dotenv = new Dotenv(__DIR__, 'config');
$dotenv->load();

// load ACCESS_KEY
Login::run();
$dotenv->overload();
if (Login::run() === false) {
Loader::overload();
}

// run
while (true) {
if (!Login::check()) {
$dotenv->overload();
}
Login::check();
Daily::run();
GiftSend::run();
Heart::run();
Silver::run();
SmallTV::run();
Task::run();
sleep(10);
}
5 changes: 4 additions & 1 deletion src/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*!
* metowolf BilibiliHelper
* https://i-meto.com/
* Version 18.04.19
* Version 18.05.04
*
* Copyright 2018, metowolf
* Released under the MIT license
Expand Down Expand Up @@ -33,6 +33,9 @@ public static function post($url, $payload = null)
if (!is_null($payload)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, is_array($payload) ? http_build_query($payload) : $payload);
Log::debug('POST: ' . $url);
} else {
Log::debug('GET: ' . $url);
}
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
Expand Down
8 changes: 4 additions & 4 deletions src/Daily.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*!
* metowolf BilibiliHelper
* https://i-meto.com/
* Version 18.04.21
* Version 18.05.04
*
* Copyright 2018, metowolf
* Released under the MIT license
Expand All @@ -26,8 +26,6 @@ public static function run()
}

self::dailyBag();

self::$lock = time() + 3600;
}

protected static function dailyBag()
Expand All @@ -38,8 +36,10 @@ protected static function dailyBag()

if (isset($data['code']) && $data['code']) {
Log::warning('每日礼包领取失败!', ['msg' => $data['message']]);
self::$lock = time() + 600;
} else {
Log::info('每日礼包领取成功');
Log::notice('每日礼包领取成功');
self::$lock = strtotime(date('Y-m-d 23:59:59')) + 600;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/GiftSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*!
* metowolf BilibiliHelper
* https://i-meto.com/
* Version 18.04.21
* Version 18.05.04
*
* Copyright 2018, metowolf
* Released under the MIT license
Expand Down Expand Up @@ -33,7 +33,7 @@ protected static function getRoomInfo()
if (isset($data['code']) && $data['code']) {
Log::warning('获取帐号信息失败!', ['msg' => $data['message']]);
Log::warning('清空礼物功能禁用!');
self::$lock = time() + 100000000;
self::$lock = strtotime('2099-12-31 00:00:00');
return;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ protected static function send($value)
if (isset($data['code']) && $data['code']) {
Log::warning('送礼失败!', ['msg' => $data['message']]);
} else {
Log::info("成功向 {$payload['biz_id']} 投喂了 {$value['gift_num']}{$value['gift_name']}");
Log::notice("成功向 {$payload['biz_id']} 投喂了 {$value['gift_num']}{$value['gift_name']}");
}
}
}
Loading

0 comments on commit cffd847

Please sign in to comment.