[add] pk lottery

This commit is contained in:
Lkeme 2019-07-23 14:45:44 +08:00
parent f505b40d9e
commit 0336f85170
14 changed files with 324 additions and 176 deletions

View File

@ -1,6 +1,19 @@
# Release Notes # Release Notes
# 本项目Log # 本项目Log
## v0.0.1.190723 alpha (2019-07-23)
### Added
- pk lottery
### Changed
-
### Fixed
-
## v0.0.1.190713 alpha (2019-07-13) ## v0.0.1.190713 alpha (2019-07-13)
### Added ### Added

5
DOC.md
View File

@ -29,9 +29,10 @@ B 站直播实用脚本
|GroupSignIn |19.07.13 |应援团签到 | |GroupSignIn |19.07.13 |应援团签到 |
|Storm |19.07.13 |节奏风暴 | |Storm |19.07.13 |节奏风暴 |
|Notice |19.07.13 |Server酱 | |Notice |19.07.13 |Server酱 |
|RaffleHandler |19.07.13 |统一活动抽奖 | |UnifyRaffle |19.07.23 |统一活动抽奖 |
|MasterSite |19.07.13 |主站(观看、分享、投币)| |MasterSite |19.07.13 |主站(观看、分享、投币)|
|Guard |19.07.13 |舰长上船亲密度 | |Guard |19.07.23 |舰长上船亲密度 |
|PkRaffle |19.07.23 |大乱斗 |
## 打赏赞助 ## 打赏赞助

View File

@ -3,7 +3,7 @@ B 站直播实用脚本
## 公告 ## 公告
Currently for Personal Edition **0.0.1.190713 alpha** Currently for Personal Edition **0.0.1.190723 alpha**
## 文档 ## 文档
@ -11,8 +11,8 @@ Currently for Personal Edition **0.0.1.190713 alpha**
* [更新日志 / CHANGELOG.md](./CHANGELOG.md) * [更新日志 / CHANGELOG.md](./CHANGELOG.md)
## 交流 ## 交流
Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg) Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg)
Group: [590512629](https://jq.qq.com/?_wv=1027&k=5S5PwTE)
## 打赏 ## 打赏

View File

@ -12,30 +12,13 @@ REFRESH_TOKEN=
COOKIE= COOKIE=
####################### #######################
# 功能设置 # # 固定设置 #
####################### #######################
# 推送服务器 # 推送服务器
USE_SERVER=true USE_SERVER=true
SERVER_ADDR= SERVER_ADDR=tcp://raffle.biem.club:10010
SERVER_KEY= SERVER_KEY=,*(?PVl]nIbo35sB
# 舰长总督
USE_GUARD=true
# 主站助手
USE_MASTER_SITE=true
# 活跃弹幕|弹幕房间(为空则随机)|弹幕内容(为空随机,但是URL不能为空)
USE_DANMU=true
DANMU_ROOMID=9522051
DANMU_CONTENT=
CONTENT_FETCH="https://v1.hitokoto.cn/?encode=text"
# 视频投币|投币稿件数(每日任务最大5)|自定义稿件ID,空则随机(AV_NUM=1生效)
USE_ADD_COIN=false
ADD_COIN_AV_NUM=1
ADD_COIN_AV=33492180
# SERVER酱, 用于推送消息 # SERVER酱, 用于推送消息
USE_SCKEY= USE_SCKEY=
@ -54,19 +37,43 @@ ROOM_ID=9522051
# 弹幕监控房间(为空则随机) # 弹幕监控房间(为空则随机)
SOCKET_ROOM_ID=9522051 SOCKET_ROOM_ID=9522051
#######################
# 功能设置 #
#######################
# 主站助手
USE_MASTER_SITE=true
# 舰长总督
USE_GUARD=true
# 统一活动
USE_ACTIVE=true
# 大乱斗
USE_PK=true
# 实物抽奖
USE_MO=true
# 银瓜子兑换硬币
USE_SILVER2COIN=true
# 节奏风暴|丢弃率(0-100)|尝试数(范围值) # 节奏风暴|丢弃率(0-100)|尝试数(范围值)
USE_STORM=true USE_STORM=true
STORM_DROPRATE=0 STORM_DROPRATE=0
STORM_ATTEMPT=30,50 STORM_ATTEMPT=30,50
# 统一活动 # 活跃弹幕|弹幕房间(为空则随机)|弹幕内容(为空随机,但是URL不能为空)
USE_ACTIVE=true USE_DANMU=true
DANMU_ROOMID=9522051
DANMU_CONTENT=
CONTENT_FETCH="https://v1.hitokoto.cn/?encode=text"
# 银瓜子兑换硬币 # 视频投币|投币稿件数(每日任务最大5)|自定义稿件ID,空则随机(AV_NUM=1生效)
USE_SILVER2COIN=true USE_ADD_COIN=false
ADD_COIN_AV_NUM=1
# 实物抽奖 ADD_COIN_AV=33492180
USE_MO=true
####################### #######################
# 日志设置 # # 日志设置 #
@ -102,13 +109,3 @@ APP_CALLBACK="http://www.example.com/api.send?text={account}[{level}]: {message}
# ERROR 400 # ERROR 400
# #
APP_CALLBACK_LEVEL=400 APP_CALLBACK_LEVEL=400
#######################
# 固定设置 #
#######################
# 用于打包请求
ACTIONENTRY=7
# 用于发送心跳
ACTIONHEARTBEAT=2

View File

@ -49,9 +49,10 @@ class Index
GiftHeart::run(); GiftHeart::run();
Winning::run(); Winning::run();
MaterialObject::run(); MaterialObject::run();
TcpClinet::run(); TcpClient::run();
Storm::run(); Storm::run();
RaffleHandler::run(); PkRaffle::run();
UnifyRaffle::run();
Guard::run(); Guard::run();
Statistics::run(); Statistics::run();
usleep(0.1 * 1000000); usleep(0.1 * 1000000);

116
src/BaseRaffle.php Normal file
View File

@ -0,0 +1,116 @@
<?php
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2019
*/
namespace lkeme\BiliHelper;
abstract class BaseRaffle
{
const ACTIVE_TITLE = '';
const ACTIVE_SWITCH = '';
public static $lock;
public static $rw_lock;
protected static $wait_list;
protected static $finish_list;
protected static $all_list;
public static function run()
{
if (getenv(static::ACTIVE_SWITCH) == 'false') {
return;
}
if (static::$lock > time()) {
return;
}
static::startLottery();
}
/**
* 抽奖逻辑
* @return bool
*/
protected static function startLottery(): bool
{
$max_num = mt_rand(5, 10);
while ($max_num) {
$raffle = array_shift(static::$wait_list);
if (is_null($raffle)) {
break;
}
Live::goToRoom($raffle['room_id']);
Statistics::addJoinList(static::ACTIVE_TITLE);
static::lottery($raffle);
$max_num--;
}
return true;
}
/**
* 检查抽奖列表
* @param $rid
* @return bool
*/
abstract protected static function check($rid): bool;
/**
* @use 请求抽奖
* @param array $data
* @return bool
*/
abstract protected static function lottery(array $data): bool;
/**
* 重复检测
* @param int $lid
* @return bool
*/
protected static function toRepeatLid(int $lid): bool
{
if (in_array($lid, static::$all_list)) {
return true;
}
if (count(static::$all_list) > 2000) {
static::$all_list = [];
}
array_push(static::$all_list, $lid);
return false;
}
/**
* 数据推入队列
* @param array $data
* @return bool
*/
public static function pushToQueue(array $data): bool
{
if (getenv(static::ACTIVE_SWITCH) == 'false') {
return false;
}
if (Live::fishingDetection($data['rid'])) {
return false;
}
static::check($data['rid']);
$wait_num = count(static::$wait_list);
if ($wait_num > 2) {
Log::info("当前队列中共有 {$wait_num}" . static::ACTIVE_TITLE . "待抽奖");
}
return true;
}
}

View File

@ -32,15 +32,19 @@ class DataTreating
break; break;
case "raffle": case "raffle":
// 礼物 // 礼物
RaffleHandler::pushToQueue($info); UnifyRaffle::pushToQueue($info);
break; break;
case "guard": case "guard":
// 舰长 // 舰长
Guard::pushToQueue($info); Guard::pushToQueue($info);
break; break;
case "small_tv": case "small_tv":
// 小电视 // 电视
RaffleHandler::pushToQueue($info); UnifyRaffle::pushToQueue($info);
break;
case 'pk':
// 乱斗
PkRaffle::pushToQueue($info);
break; break;
default: default:
break; break;

View File

@ -12,19 +12,17 @@ namespace lkeme\BiliHelper;
class Guard class Guard
{ {
const KEY = '总督舰长'; const ACTIVE_TITLE = '总督舰长';
const SWITCH = 'USE_GUARD'; const ACTIVE_SWITCH = 'USE_GUARD';
public static $lock = 0; public static $lock = 0;
private static $wait_list = []; protected static $wait_list = [];
private static $finsh_list = []; protected static $all_list = [];
private static $all_list = [];
public static function run() public static function run()
{ {
if (getenv(self::SWITCH) == 'false') { if (getenv(self::ACTIVE_SWITCH) == 'false') {
return; return;
} }
if (self::$lock > time()) { if (self::$lock > time()) {
@ -48,15 +46,15 @@ class Guard
$guard_lid = $guard['lid']; $guard_lid = $guard['lid'];
$guard_rid = $guard['rid']; $guard_rid = $guard['rid'];
Live::goToRoom($guard_rid); Live::goToRoom($guard_rid);
Statistics::addJoinList(self::KEY); Statistics::addJoinList(self::ACTIVE_TITLE);
$data = self::lottery($guard_rid, $guard_lid); $data = self::lottery($guard_rid, $guard_lid);
if ($data['code'] == 0) { if ($data['code'] == 0) {
Statistics::addSuccessList(self::KEY); Statistics::addSuccessList(self::ACTIVE_TITLE);
Log::notice("房间 {$guard_rid} 编号 {$guard_lid} " . self::KEY . ": {$data['data']['message']}"); Log::notice("房间 {$guard_rid} 编号 {$guard_lid} " . self::ACTIVE_TITLE . ": {$data['data']['message']}");
} elseif ($data['code'] == 400 && $data['msg'] == '你已经领取过啦') { } elseif ($data['code'] == 400 && $data['msg'] == '你已经领取过啦') {
Log::info("房间 {$guard_rid} 编号 {$guard_lid} " . self::KEY . ": {$data['msg']}"); Log::info("房间 {$guard_rid} 编号 {$guard_lid} " . self::ACTIVE_TITLE . ": {$data['msg']}");
} else { } else {
Log::warning("房间 {$guard_rid} 编号 {$guard_lid} " . self::KEY . ": {$data['msg']}"); Log::warning("房间 {$guard_rid} 编号 {$guard_lid} " . self::ACTIVE_TITLE . ": {$data['msg']}");
} }
$max_num--; $max_num--;
} }
@ -109,17 +107,17 @@ class Guard
*/ */
public static function pushToQueue(array $data): bool public static function pushToQueue(array $data): bool
{ {
if (getenv(self::SWITCH) == 'false') { if (getenv(self::ACTIVE_SWITCH) == 'false') {
return false; return false;
} }
if (self::toRepeatLid($data['lid'])) { if (self::toRepeatLid($data['lid'])) {
return false; return false;
} }
Statistics::addPushList(self::KEY); Statistics::addPushList(self::ACTIVE_TITLE);
self::$wait_list = array_merge(self::$wait_list, [['rid' => $data['rid'], 'lid' => $data['lid']]]); self::$wait_list = array_merge(self::$wait_list, [['rid' => $data['rid'], 'lid' => $data['lid']]]);
$wait_num = count(self::$wait_list); $wait_num = count(self::$wait_list);
if ($wait_num > 2) { if ($wait_num > 2) {
Log::info("当前队列中共有 {$wait_num}" . self::KEY . "待抽奖"); Log::info("当前队列中共有 {$wait_num}" . self::ACTIVE_TITLE . "待抽奖");
} }
return true; return true;
} }

View File

@ -146,12 +146,8 @@ class Live
Silver::$lock = $second; Silver::$lock = $second;
MaterialObject::$lock = $second; MaterialObject::$lock = $second;
Websocket::$lock = $second;
GiftHeart::$lock = $second; GiftHeart::$lock = $second;
Guard::$lock = $second; TcpClient::$lock = $second;
RaffleHandler::$lock = $second;
RaffleHandler::$rw_lock = $second;
return; return;
} }

92
src/PkRaffle.php Normal file
View File

@ -0,0 +1,92 @@
<?php
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2019
*/
namespace lkeme\BiliHelper;
class PkRaffle extends BaseRaffle
{
const ACTIVE_TITLE = '大乱斗';
const ACTIVE_SWITCH = 'USE_PK';
public static $lock = 0;
public static $rw_lock = 0;
protected static $wait_list = [];
protected static $finish_list = [];
protected static $all_list = [];
/**
* 检查抽奖列表
* @param $rid
* @return bool
*/
protected static function check($rid): bool
{
$payload = [
'roomid' => $rid
];
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/pk/check';
$raw = Curl::get($url, Sign::api($payload));
$de_raw = json_decode($raw, true);
// 计数 && 跳出
$total = count($de_raw['data']);
if (!$total) {
return false;
}
for ($i = 0; $i < $total; $i++) {
$data = [
'raffle_id' => $de_raw['data'][$i]['pk_id'],
'title' => $de_raw['data'][$i]['title'],
'room_id' => $de_raw['data'][$i]['room_id']
];
if (static::toRepeatLid($data['raffle_id'])) {
continue;
}
Statistics::addPushList(static::ACTIVE_TITLE);
array_push(static::$wait_list, $data);
}
return true;
}
/**
* @use 请求抽奖
* @param array $data
* @return bool
*/
protected static function lottery(array $data): bool
{
$user_info = User::parseCookies();
$payload = [
'id' => $data['raffle_id'],
'roomid' => $data['room_id'],
'csrf_token' => $user_info['token'],
"csrf" => $user_info['token'],
];
$url = 'https://api.live.bilibili.com/xlive/lottery-interface/v1/pk/join';
$raw = Curl::post($url, Sign::api($payload));
$de_raw = json_decode($raw, true);
/*
* {'code': 0, 'message': '0', 'ttl': 1, 'data': {'id': 343560, 'gift_type': 0, 'award_id': '1', 'award_text': '辣条X1', 'award_image': 'https://i0.hdslb.com/bfs/live/da6656add2b14a93ed9eb55de55d0fd19f0fc7f6.png', 'award_num': 0, 'title': '大乱斗获胜抽奖'}}
* {'code': -1, 'message': '抽奖已结束', 'ttl': 1}
* {'code': -2, 'message': '您已参加过抽奖', 'ttl': 1}
* {"code":-403,"data":null,"message":"访问被拒绝","msg":"访问被拒绝"}
*/
if (isset($de_raw['code']) && $de_raw['code'] == 0) {
Statistics::addSuccessList(static::ACTIVE_TITLE);
Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . static::ACTIVE_TITLE . ": {$de_raw['data']['award_text']}");
} else {
Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . static::ACTIVE_TITLE . ": {$de_raw['message']}");
}
return true;
}
}

View File

@ -12,21 +12,23 @@ namespace lkeme\BiliHelper;
class Storm class Storm
{ {
const KEY = '节奏风暴'; const ACTIVE_TITLE = '节奏风暴';
const SWITCH = 'USE_STORM'; const ACTIVE_SWITCH = 'USE_STORM';
public static $lock = 0; public static $lock = 0;
protected static $wait_list = [];
protected static $all_list = [];
private static $drop_rate = null; private static $drop_rate = null;
private static $attempt = null; private static $attempt = null;
private static $wait_list = [];
private static $all_list = [];
/** /**
* @throws \Exception * @throws \Exception
*/ */
public static function run() public static function run()
{ {
if (getenv(self::SWITCH) == 'false') { if (getenv(self::ACTIVE_SWITCH) == 'false') {
return; return;
} }
if (self::$lock > time()) { if (self::$lock > time()) {
@ -65,7 +67,7 @@ class Storm
$storm_lid = $storm['lid']; $storm_lid = $storm['lid'];
$storm_rid = $storm['rid']; $storm_rid = $storm['rid'];
Live::goToRoom($storm_rid); Live::goToRoom($storm_rid);
Statistics::addJoinList(self::KEY); Statistics::addJoinList(self::ACTIVE_TITLE);
$num = random_int((int)self::$attempt[0], (int)self::$attempt[1]); $num = random_int((int)self::$attempt[0], (int)self::$attempt[1]);
for ($i = 1; $i < $num; $i++) { for ($i = 1; $i < $num; $i++) {
if (!self::lottery($storm_rid, $storm_lid, $i)) { if (!self::lottery($storm_rid, $storm_lid, $i)) {
@ -119,7 +121,7 @@ class Storm
return false; return false;
} }
if ($de_raw['code'] == 0) { if ($de_raw['code'] == 0) {
Statistics::addSuccessList(self::KEY); Statistics::addSuccessList(self::ACTIVE_TITLE);
Log::notice(self::formatInfo($lid, $num, $de_raw['data']['mobile_content'])); Log::notice(self::formatInfo($lid, $num, $de_raw['data']['mobile_content']));
return false; return false;
} }
@ -182,17 +184,17 @@ class Storm
*/ */
public static function pushToQueue(array $data): bool public static function pushToQueue(array $data): bool
{ {
if (getenv(self::SWITCH) == 'false') { if (getenv(self::ACTIVE_SWITCH) == 'false') {
return false; return false;
} }
if (self::toRepeatLid($data['lid'])) { if (self::toRepeatLid($data['lid'])) {
return false; return false;
} }
Statistics::addPushList(self::KEY); Statistics::addPushList(self::ACTIVE_TITLE);
self::$wait_list = array_merge(self::$wait_list, [['rid' => $data['rid'], 'lid' => $data['lid']]]); self::$wait_list = array_merge(self::$wait_list, [['rid' => $data['rid'], 'lid' => $data['lid']]]);
$wait_num = count(self::$wait_list); $wait_num = count(self::$wait_list);
if ($wait_num > 2) { if ($wait_num > 2) {
Log::info("当前队列中共有 {$wait_num}" . self::KEY . "待抽奖"); Log::info("当前队列中共有 {$wait_num}" . self::ACTIVE_TITLE . "待抽奖");
} }
return true; return true;
} }

View File

@ -13,7 +13,7 @@ namespace lkeme\BiliHelper;
use Exception; use Exception;
use Socket\Raw\Factory; use Socket\Raw\Factory;
class TcpClinet class TcpClient
{ {
public static $lock = 0; public static $lock = 0;
private static $heart_lock = 0; private static $heart_lock = 0;
@ -216,8 +216,8 @@ class TcpClinet
break; break;
case 'error': case 'error':
// 致命错误 // 致命错误
Log::warning($body); Log::error("推送服务器发生致命错误 {$raw_data['data']['msg']}");
exit("推送服务器发生致命错误 {$raw_data['data']['msg']}"); exit();
break; break;
case 'heartbeat': case 'heartbeat':
// 服务端心跳推送 // 服务端心跳推送

View File

@ -10,56 +10,24 @@
namespace lkeme\BiliHelper; namespace lkeme\BiliHelper;
class RaffleHandler class UnifyRaffle extends BaseRaffle
{ {
const KEY = '统一活动'; const ACTIVE_TITLE = '统一活动';
const SWITCH = 'USE_ACTIVE'; const ACTIVE_SWITCH = 'USE_ACTIVE';
public static $lock = 0; public static $lock = 0;
public static $rw_lock = 0; public static $rw_lock = 0;
private static $wait_list = []; protected static $wait_list = [];
private static $finsh_list = []; protected static $finish_list = [];
private static $all_list = []; protected static $all_list = [];
public static function run()
{
if (getenv(self::SWITCH) == 'false') {
return;
}
if (self::$lock > time()) {
return;
}
self::startLottery();
}
/**
* 抽奖逻辑
* @return bool
*/
protected static function startLottery(): bool
{
$max_num = mt_rand(5, 10);
while ($max_num) {
$raffle = array_shift(self::$wait_list);
if (is_null($raffle)) {
break;
}
Live::goToRoom($raffle['room_id']);
Statistics::addJoinList(self::KEY);
self::lottery($raffle);
$max_num--;
}
return true;
}
/** /**
* 检查抽奖列表 * 检查抽奖列表
* @param $rid * @param $rid
* @return bool * @return bool
*/ */
private static function checkWeb($rid): bool protected static function check($rid): bool
{ {
$payload = [ $payload = [
'roomid' => $rid 'roomid' => $rid
@ -86,11 +54,11 @@ class RaffleHandler
'type' => $de_raw['data']['list'][$i]['type'], 'type' => $de_raw['data']['list'][$i]['type'],
'room_id' => $rid 'room_id' => $rid
]; ];
if (self::toRepeatLid($data['raffle_id'])) { if (static::toRepeatLid($data['raffle_id'])) {
continue; continue;
} }
Statistics::addPushList(self::KEY); Statistics::addPushList(static::ACTIVE_TITLE);
array_push(self::$wait_list, $data); array_push(static::$wait_list, $data);
} }
return true; return true;
} }
@ -102,17 +70,17 @@ class RaffleHandler
public static function resultWeb() public static function resultWeb()
{ {
// 时间锁 // 时间锁
if (self::$rw_lock > time()) { if (static::$rw_lock > time()) {
return; return;
} }
// 如果待查询为空 && 去重 // 如果待查询为空 && 去重
if (!count(self::$finsh_list)) { if (!count(static::$finish_list)) {
self::$rw_lock = time() + 40; static::$rw_lock = time() + 40;
return; return;
} }
// 查询每次查询10个 // 查询每次查询10个
$flag = 0; $flag = 0;
foreach (self::$finsh_list as $winning_web) { foreach (static::$finish_list as $winning_web) {
$flag++; $flag++;
if ($flag > 40) { if ($flag > 40) {
break; break;
@ -132,7 +100,7 @@ class RaffleHandler
case 3: case 3:
break; break;
case 2: case 2:
Statistics::addSuccessList(self::KEY); Statistics::addSuccessList(static::ACTIVE_TITLE);
// 提示信息 // 提示信息
$info = "房间 {$winning_web['room_id']} 编号 {$winning_web['raffle_id']} {$winning_web['title']}: 获得"; $info = "房间 {$winning_web['room_id']} 编号 {$winning_web['raffle_id']} {$winning_web['title']}: 获得";
$info .= "{$de_raw['data']['gift_name']}X{$de_raw['data']['gift_num']}"; $info .= "{$de_raw['data']['gift_name']}X{$de_raw['data']['gift_num']}";
@ -142,14 +110,14 @@ class RaffleHandler
Notice::run('raffle', $info); Notice::run('raffle', $info);
} }
// 删除查询完成ID // 删除查询完成ID
unset(self::$finsh_list[$flag - 1]); unset(static::$finish_list[$flag - 1]);
self::$finsh_list = array_values(self::$finsh_list); static::$finish_list = array_values(static::$finish_list);
break; break;
default: default:
break; break;
} }
} }
self::$rw_lock = time() + 40; static::$rw_lock = time() + 40;
return; return;
} }
@ -157,8 +125,9 @@ class RaffleHandler
/** /**
* @use 请求抽奖 * @use 请求抽奖
* @param array $data * @param array $data
* @return bool
*/ */
private static function lottery(array $data) protected static function lottery(array $data): bool
{ {
$payload = [ $payload = [
'raffleId' => $data['raffle_id'], 'raffleId' => $data['raffle_id'],
@ -168,52 +137,11 @@ class RaffleHandler
$raw = Curl::get($url, Sign::api($payload)); $raw = Curl::get($url, Sign::api($payload));
$de_raw = json_decode($raw, true); $de_raw = json_decode($raw, true);
if (isset($de_raw['code']) && $de_raw['code']) { if (isset($de_raw['code']) && $de_raw['code']) {
Log::notice("房间 {$data['raffle_id']} 编号 {$data['room_id']} " . self::KEY . ": {$de_raw['message']}"); Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . static::ACTIVE_TITLE . ": {$de_raw['message']}");
} else { } else {
Log::notice("房间 {$data['raffle_id']} 编号 {$data['room_id']} " . self::KEY . ": {$de_raw['msg']}"); Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . static::ACTIVE_TITLE . ": {$de_raw['msg']}");
array_push(self::$finsh_list, $data); array_push(static::$finish_list, $data);
}
return;
}
/**
* 重复检测
* @param int $lid
* @return bool
*/
private static function toRepeatLid(int $lid): bool
{
if (in_array($lid, self::$all_list)) {
return true;
}
if (count(self::$all_list) > 2000) {
self::$all_list = [];
}
array_push(self::$all_list, $lid);
return false;
}
/**
* 数据推入队列
* @param array $data
* @return bool
*/
public static function pushToQueue(array $data): bool
{
if (getenv(self::SWITCH) == 'false') {
return false;
}
if (Live::fishingDetection($data['rid'])) {
return false;
}
self::checkWeb($data['rid']);
$wait_num = count(self::$wait_list);
if ($wait_num > 2) {
Log::info("当前队列中共有 {$wait_num}" . self::KEY . "待抽奖");
} }
return true; return true;
} }
} }

View File

@ -18,7 +18,7 @@ class Winning
public static function run() public static function run()
{ {
// 活动统一 // 活动统一
RaffleHandler::resultWeb(); UnifyRaffle::resultWeb();
// 实物 // 实物
self::winningRecords(); self::winningRecords();