[fix] Live fixes #19

This commit is contained in:
Lkeme 2020-03-16 00:59:07 +08:00
parent fe8477a05a
commit 2496655b89
10 changed files with 85 additions and 1099 deletions

View File

@ -1,6 +1,21 @@
# Release Notes
# 本项目Log
## v0.3.0.200316 alpha (2020-03-169)
### Added
- 添加异常处理(通知)
-
### Changed
-
### Fixed
- 修复活跃弹幕
- 修复风纪测试
- 修复部分已知
-
## v0.3.0.200312 alpha (2020-03-12)
### Added

49
DOC.md
View File

@ -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.3.0.200312 alpha-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/version-0.3.0.200316 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>
@ -15,29 +15,30 @@ B 站直播实用脚本
|plugin |version |description |
|--------------------|--------------------|--------------------|
|Login |20.03.12 |账号登录 |
|Sleep |20.03.12 |休眠控制 |
|MasterSite |20.03.12 |主站助手 |
|Daily |20.03.12 |每日礼包 |
|Heart |20.03.12 |双端心跳 |
|Task |20.03.12 |每日任务 |
|Silver |20.03.12 |银瓜子宝箱 |
|Barrage |20.03.12 |活跃弹幕 |
|Silver2Coin |20.03.12 |银瓜子换硬币 |
|GiftSend |20.03.12 |礼物赠送 |
|GroupSignIn |20.03.12 |友爱社签到 |
|ManGa |20.03.12 |漫画签到分享 |
|GiftHeart |20.03.12 |心跳礼物 |
|MaterialObject |20.03.12 |实物抽奖 |
|AloneTcpClient |20.03.12 |独立监控 |
|ZoneTcpClient |20.03.12 |分区监控 |
|StormRaffle |20.03.12 |节奏风暴 |
|GiftRaffle |20.03.12 |活动礼物 |
|PkRaffle |20.03.12 |大乱斗 |
|GuardRaffle |20.03.12 |舰长总督 |
|AnchorRaffle |20.03.12 |天选时刻 |
|AwardRecord |20.03.12 |获奖通知 |
|Statistics |20.03.12 |数据统计 |
|Login |20.03.16 |账号登录 |
|Sleep |20.03.16 |休眠控制 |
|MasterSite |20.03.16 |主站助手 |
|Daily |20.03.16 |每日礼包 |
|Heart |20.03.16 |双端心跳 |
|Task |20.03.16 |每日任务 |
|Silver |20.03.16 |银瓜子宝箱 |
|Barrage |20.03.16 |活跃弹幕 |
|Silver2Coin |20.03.16 |银瓜子换硬币 |
|GiftSend |20.03.16 |礼物赠送 |
|Judge |20.03.16 |风纪 |
|GroupSignIn |20.03.16 |友爱社签到 |
|ManGa |20.03.16 |漫画签到分享 |
|GiftHeart |20.03.16 |心跳礼物 |
|MaterialObject |20.03.16 |实物抽奖 |
|AloneTcpClient |20.03.16 |独立监控 |
|ZoneTcpClient |20.03.16 |分区监控 |
|StormRaffle |20.03.16 |节奏风暴 |
|GiftRaffle |20.03.16 |活动礼物 |
|PkRaffle |20.03.16 |大乱斗 |
|GuardRaffle |20.03.16 |舰长总督 |
|AnchorRaffle |20.03.16 |天选时刻 |
|AwardRecord |20.03.16 |获奖通知 |
|Statistics |20.03.16 |数据统计 |
## 打赏赞助

View File

@ -7,7 +7,7 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg)
## 公告
Currently for Personal Edition **0.3.0.200312 alpha**
Currently for Personal Edition **0.3.0.200316 alpha**
## 文档

1056
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,8 @@ namespace BiliHelper\Core;
use Amp\Delayed;
use Amp\Loop;
use function Amp\asyncCall;
use BiliHelper\Plugin\Notice;
class App
{
@ -22,6 +24,8 @@ class App
public function __construct()
{
set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', 'on');
header("Content-Type:text/html; charset=utf-8");
date_default_timezone_set('Asia/Shanghai');
if (PHP_SAPI != 'cli') {
@ -37,7 +41,6 @@ class App
*/
public function load($app_path, $load_file = 'user.conf')
{
// define('APP_PATH', dirname(__DIR__));
define('APP_PATH', $app_path);
Config::load($load_file);
return $this;
@ -51,11 +54,16 @@ class App
{
asyncCall(function () use ($taskName) {
while (true) {
call_user_func(array('BiliHelper\Plugin\\' . $taskName, 'run'), []);
try {
call_user_func(array('BiliHelper\Plugin\\' . $taskName, 'run'), []);
} catch (\Throwable $e) {
$error_msg = "MSG: {$e->getMessage()} CODE: {$e->getCode()} FILE: {$e->getFile()} LINE: {$e->getLine()}";
Log::error($error_msg);
Notice::push('error', $error_msg);
}
yield new Delayed(1000);
}
});
}
/**

View File

@ -91,9 +91,9 @@ class Barrage
/**
* @use 弹幕通用模块
* @param $info
* @return bool|string
* @return array
*/
private static function sendMsg($info)
private static function sendMsg($info): array
{
$user_info = User::parseCookies();
$url = 'https://api.live.bilibili.com/msg/send';
@ -108,7 +108,8 @@ class Barrage
'csrf' => $user_info['token'],
'csrf_token' => $user_info['token'],
];
return Curl::post('app', $url, Sign::common($payload));
$raw = Curl::post('app', $url, Sign::common($payload));
return json_decode($raw, true) ?? ['code' => 404, 'msg' => '上层数据为空!'];
}
/**
@ -116,21 +117,16 @@ class Barrage
* @param $info
* @return bool
*/
private static function privateSendMsg($info)
private static function privateSendMsg($info): bool
{
//TODO 暂时性功能 有需求就修改
$raw = self::sendMsg($info);
$de_raw = json_decode($raw, true);
if ($de_raw['code'] == 1001) {
Log::warning($de_raw['msg']);
return false;
}
if (!$de_raw['code']) {
$response = self::sendMsg($info);
if (isset($response['code']) && $response['code'] == 0) {
Log::info('活跃弹幕发送成功!');
return true;
} else {
Log::warning("活跃代码发送失败, CODE -> {$response['code']} MSG -> {$response['msg']} ");
return false;
}
Log::error("活跃弹幕发送失败!, {$de_raw['msg']}");
return false;
}
}

View File

@ -36,11 +36,11 @@ class Judge
return;
}
// self::judgementIndex();
self::setLock(mt_rand(6, 10) * 60);
self::setLock(mt_rand(15, 30) * 60);
}
/**
* @use 判案
* @use 判案 TODO: 处理案例已满(MAX20例) / 尝试已实名续期风纪
* @param $case_id
* @return bool
*/
@ -173,8 +173,10 @@ class Judge
];
$raw = Curl::post('pc', $url, $payload);
$de_raw = json_decode($raw, true);
// {"code":25008,"message":"真给力 , 移交众裁的举报案件已经被处理完了","ttl":1}
// {"code":25014,"message":"25014","ttl":1}
// {"code":25005,"message":"请成为风纪委员后再试","ttl":1}
if (isset($de_raw['code']) && $de_raw['code'] == 25005) {
// {"code":25005,"message":"请成为风纪委员后再试","ttl":1}
Log::warning($de_raw['message']);
self::setLock(24 * 60 * 60);
return null;

View File

@ -112,6 +112,9 @@ class Live
public static function getRealRoomID($room_id)
{
$data = self::getRoomInfo($room_id);
if (!isset($data['code']) || !isset($data['data'])) {
return false;
}
if ($data['code']) {
Log::warning($room_id . ' : ' . $data['msg']);
return false;
@ -140,7 +143,7 @@ class Live
'id' => $room_id
];
$raw = Curl::get('other', $url, $payload);
return json_decode($raw, true);;
return json_decode($raw, true);
}

View File

@ -75,7 +75,7 @@ class MasterSite
$raw = Curl::get('pc', $url, $payload);
$de_raw = json_decode($raw, true);
$logs = $de_raw['data']['list'];
$logs = isset($de_raw['data']['list']) ? $de_raw['data']['list'] : [];
$coins = 0;
foreach ($logs as $log) {
$log_ux = strtotime($log['time']);
@ -100,9 +100,8 @@ class MasterSite
return $coins;
}
/**
* @use 投币视频
* @use 视频投币 TODO : 处理视频投币硬币少于需要投币数
* @return bool
* @throws \Exception
*/

View File

@ -110,6 +110,12 @@ class Notice
'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 账号被封禁: 程序开始睡眠,凌晨自动唤醒,距离唤醒还有' . self::$result . '小时',
];
break;
case 'error':
$info = [
'title' => '程序错误',
'content' => '[' . $now_time . ']' . ' 用户: ' . self::$uname . ' 程序运行错误: ' . self::$result,
];
break;
default:
$info = [
'title' => '推送消息异常记录',