[fix] Heart

This commit is contained in:
Lkeme 2020-02-26 15:14:05 +08:00
parent 5fdd14a9b3
commit 97028b09d2
6 changed files with 60 additions and 12 deletions

View File

@ -1,6 +1,19 @@
# Release Notes # Release Notes
# 本项目Log # 本项目Log
## v0.2.0.200226 alpha (2020-02-26)
### Added
-
### Changed
-
### Fixed
- 修复节奏风暴
- 修复双端心跳
-
## v0.2.0.200224 alpha (2020-02-24) ## v0.2.0.200224 alpha (2020-02-24)
### Added ### Added

2
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 width="300px" src="https://i.loli.net/2018/04/20/5ad97bd395912.jpeg"></p>
<p align="center"> <p align="center">
<img src="https://img.shields.io/badge/version-0.2.0.200224 alpha-green.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/version-0.2.0.200226 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"> <img src="https://img.shields.io/badge/license-mit-blue.svg?longCache=true&style=for-the-badge">
</p> </p>

View File

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

View File

@ -23,18 +23,17 @@ class Heart
if (self::getLock() > time()) { if (self::getLock() > time()) {
return; return;
} }
self::webHeart();
self::pc(); self::appHeart();
self::mobile();
self::setLock(5 * 60); self::setLock(5 * 60);
} }
/** /**
* @use pc端心跳 * @use Web 心跳
*/ */
protected static function pc() protected static function webHeart()
{ {
User::webGetUserInfo();
$payload = [ $payload = [
'room_id' => getenv('ROOM_ID'), 'room_id' => getenv('ROOM_ID'),
]; ];
@ -51,8 +50,9 @@ class Heart
/** /**
* @use 手机端心跳 * @use 手机端心跳
*/ */
protected static function mobile() protected static function appHeart()
{ {
User::appGetUserInfo();
$payload = [ $payload = [
'room_id' => getenv('ROOM_ID'), 'room_id' => getenv('ROOM_ID'),
]; ];

View File

@ -123,8 +123,8 @@ class StormRaffle extends BaseRaffle
Log::notice(self::formatInfo($raffle['raffle_id'], $num, $de_raw['data']['mobile_content'])); Log::notice(self::formatInfo($raffle['raffle_id'], $num, $de_raw['data']['mobile_content']));
break; break;
} }
if ($de_raw['msg'] == '节奏风暴不存在') { if ($de_raw['msg'] == '节奏风暴不存在' || $de_raw['msg'] == '节奏风暴抽奖过期') {
Log::notice(self::formatInfo($raffle['raffle_id'], $num, '节奏风暴已结束')); Log::notice(self::formatInfo($raffle['raffle_id'], $num, '节奏风暴已结束'));
break; break;
} }
if ($de_raw['msg'] == '已经领取奖励') { if ($de_raw['msg'] == '已经领取奖励') {

View File

@ -23,6 +23,7 @@ class User
/** /**
* @use 实名检测 * @use 实名检测
* @return bool * @return bool
* @throws \Exception
*/ */
public static function realNameCheck(): bool public static function realNameCheck(): bool
{ {
@ -38,8 +39,9 @@ class User
/** /**
* @use 是否是老爷 * @use 老爷检测
* @return bool * @return bool
* @throws \Exception
*/ */
public static function isMaster(): bool public static function isMaster(): bool
{ {
@ -60,6 +62,7 @@ class User
/** /**
* @use 用户名写入 * @use 用户名写入
* @return bool * @return bool
* @throws \Exception
*/ */
public static function userInfo(): bool public static function userInfo(): bool
{ {
@ -99,4 +102,36 @@ class User
'sid' => $sid, 'sid' => $sid,
]; ];
} }
/**
* @use Web User
* @param null $room_id
* @return mixed
* @throws \Exception
*/
public static function webGetUserInfo($room_id = null)
{
$url = 'https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByUser';
$payload = [
'room_id' => $room_id ?? getenv('ROOM_ID')
];
$raw = Curl::get($url, Sign::api($payload));
return json_decode($raw, true);;
}
/**
* @use App User
* @return mixed
* @throws \Exception
*/
public static function appGetUserInfo()
{
$url = 'https://api.live.bilibili.com/xlive/app-room/v1/index/getInfoByUser';
$payload = [
'room_id' => $room_id ?? getenv('ROOM_ID')
];
$raw = Curl::get($url, Sign::api($payload));
return json_decode($raw, true);;
}
} }