mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 09:30:10 +08:00
[update] MaterialObject
This commit is contained in:
parent
1f6f0bff6b
commit
90c5479a15
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,6 +1,20 @@
|
|||||||
# Release Notes
|
# Release Notes
|
||||||
# 本项目Log
|
# 本项目Log
|
||||||
|
|
||||||
|
## v0.2.0.200214 alpha (2020-02-14)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
-
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- 优化实物抽奖流程
|
||||||
|
- 优化延迟礼物抽奖
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- 修正部分函数名称
|
||||||
|
- 尝试减少静态占用
|
||||||
|
-
|
||||||
|
|
||||||
## v0.2.0.200208 alpha (2020-02-08)
|
## v0.2.0.200208 alpha (2020-02-08)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
48
DOC.md
48
DOC.md
@ -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.200208 alpha-green.svg?longCache=true&style=for-the-badge">
|
<img src="https://img.shields.io/badge/version-0.2.0.200214 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>
|
||||||
|
|
||||||
@ -15,29 +15,29 @@ B 站直播实用脚本
|
|||||||
|
|
||||||
|plugin |version |description |
|
|plugin |version |description |
|
||||||
|--------------------|--------------------|--------------------|
|
|--------------------|--------------------|--------------------|
|
||||||
|Login |20.02.08 |账号登录 |
|
|Login |20.02.14 |账号登录 |
|
||||||
|Sleep |20.02.08 |休眠控制 |
|
|Sleep |20.02.14 |休眠控制 |
|
||||||
|MasterSite |20.02.08 |主站助手 |
|
|MasterSite |20.02.14 |主站助手 |
|
||||||
|Daily |20.02.08 |每日礼包 |
|
|Daily |20.02.14 |每日礼包 |
|
||||||
|Heart |20.02.08 |双端心跳 |
|
|Heart |20.02.14 |双端心跳 |
|
||||||
|Task |20.02.08 |每日任务 |
|
|Task |20.02.14 |每日任务 |
|
||||||
|Silver |20.02.08 |银瓜子宝箱 |
|
|Silver |20.02.14 |银瓜子宝箱 |
|
||||||
|Barrage |20.02.08 |活跃弹幕 |
|
|Barrage |20.02.14 |活跃弹幕 |
|
||||||
|Silver2Coin |20.02.08 |银瓜子换硬币 |
|
|Silver2Coin |20.02.14 |银瓜子换硬币 |
|
||||||
|GiftSend |20.02.08 |礼物赠送 |
|
|GiftSend |20.02.14 |礼物赠送 |
|
||||||
|GroupSignIn |20.02.08 |友爱社签到 |
|
|GroupSignIn |20.02.14 |友爱社签到 |
|
||||||
|ManGa |20.02.08 |漫画签到分享 |
|
|ManGa |20.02.14 |漫画签到分享 |
|
||||||
|GiftHeart |20.02.08 |心跳礼物 |
|
|GiftHeart |20.02.14 |心跳礼物 |
|
||||||
|MaterialObject |20.02.08 |实物抽奖 |
|
|MaterialObject |20.02.14 |实物抽奖 |
|
||||||
|AloneTcpClient |20.02.08 |独立监控 |
|
|AloneTcpClient |20.02.14 |独立监控 |
|
||||||
|ZoneTcpClient |20.02.08 |分区监控 |
|
|ZoneTcpClient |20.02.14 |分区监控 |
|
||||||
|StormRaffle |20.02.08 |节奏风暴 |
|
|StormRaffle |20.02.14 |节奏风暴 |
|
||||||
|GiftRaffle |20.02.08 |活动礼物 |
|
|GiftRaffle |20.02.14 |活动礼物 |
|
||||||
|PkRaffle |20.02.08 |大乱斗 |
|
|PkRaffle |20.02.14 |大乱斗 |
|
||||||
|GuardRaffle |20.02.08 |舰长总督 |
|
|GuardRaffle |20.02.14 |舰长总督 |
|
||||||
|AnchorRaffle |20.02.08 |天选时刻 |
|
|AnchorRaffle |20.02.14 |天选时刻 |
|
||||||
|AwardRecord |20.02.08 |获奖通知 |
|
|AwardRecord |20.02.14 |获奖通知 |
|
||||||
|Statistics |20.02.08 |数据统计 |
|
|Statistics |20.02.14 |数据统计 |
|
||||||
|
|
||||||
## 打赏赞助
|
## 打赏赞助
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg)
|
|||||||
|
|
||||||
## 公告
|
## 公告
|
||||||
|
|
||||||
Currently for Personal Edition **0.2.0.200208 alpha**
|
Currently for Personal Edition **0.2.0.200214 alpha**
|
||||||
|
|
||||||
## 文档
|
## 文档
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@ class Curl
|
|||||||
// 网络断开判断 延时方便连接网络
|
// 网络断开判断 延时方便连接网络
|
||||||
if ($ret_count < $waring) {
|
if ($ret_count < $waring) {
|
||||||
Log::warning("正常等待网络连接状态恢复正常...");
|
Log::warning("正常等待网络连接状态恢复正常...");
|
||||||
sleep(mt_rand(5, 10));
|
sleep(random_int(5, 10));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
|||||||
@ -93,7 +93,7 @@ class AnchorRaffle extends BaseRaffle
|
|||||||
'room_id' => $room_id,
|
'room_id' => $room_id,
|
||||||
'raffle_id' => $de_raw['id'],
|
'raffle_id' => $de_raw['id'],
|
||||||
'raffle_name' => $de_raw['award_name'],
|
'raffle_name' => $de_raw['award_name'],
|
||||||
'wait' => time()
|
'wait' => time() + random_int(5, 25)
|
||||||
];
|
];
|
||||||
Statistics::addPushList(self::ACTIVE_TITLE);
|
Statistics::addPushList(self::ACTIVE_TITLE);
|
||||||
array_push(self::$wait_list, $data);
|
array_push(self::$wait_list, $data);
|
||||||
|
|||||||
@ -154,7 +154,7 @@ abstract class BaseRaffle
|
|||||||
if (in_array($lid, static::$all_list)) {
|
if (in_array($lid, static::$all_list)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (count(static::$all_list) > 2000) {
|
if (count(static::$all_list) > 1000) {
|
||||||
static::$all_list = [];
|
static::$all_list = [];
|
||||||
}
|
}
|
||||||
if ($filter) {
|
if ($filter) {
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class GuardRaffle extends BaseRaffle
|
|||||||
* @param int $room_id
|
* @param int $room_id
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
protected static function parseLotteryInfo(int $room_id, array $data): bool
|
protected static function parseLotteryInfo(int $room_id, array $data): bool
|
||||||
{
|
{
|
||||||
@ -72,7 +73,7 @@ class GuardRaffle extends BaseRaffle
|
|||||||
'room_id' => $room_id,
|
'room_id' => $room_id,
|
||||||
'raffle_id' => $guard['id'],
|
'raffle_id' => $guard['id'],
|
||||||
'raffle_name' => $raffle_name,
|
'raffle_name' => $raffle_name,
|
||||||
'wait' => time()
|
'wait' => time() + random_int(5, 25)
|
||||||
];
|
];
|
||||||
Statistics::addPushList(self::ACTIVE_TITLE);
|
Statistics::addPushList(self::ACTIVE_TITLE);
|
||||||
array_push(self::$wait_list, $data);
|
array_push(self::$wait_list, $data);
|
||||||
|
|||||||
@ -139,7 +139,7 @@ class Live
|
|||||||
*/
|
*/
|
||||||
public static function randDelay($min = 0, $max = 3): bool
|
public static function randDelay($min = 0, $max = 3): bool
|
||||||
{
|
{
|
||||||
$rand = $min + mt_rand() / mt_getrandmax() * ($max - $min);
|
$rand = $min + random_int() / mt_getrandmax() * ($max - $min);
|
||||||
sleep($rand);
|
sleep($rand);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,7 +149,7 @@ class MasterSite
|
|||||||
private static function getRandomAid(): string
|
private static function getRandomAid(): string
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
$page = mt_rand(1, 1000);
|
$page = random_int(1, 1000);
|
||||||
$payload = [];
|
$payload = [];
|
||||||
$url = "https://api.bilibili.com/x/web-interface/newlist?&pn={$page}&ps=1";
|
$url = "https://api.bilibili.com/x/web-interface/newlist?&pn={$page}&ps=1";
|
||||||
$raw = Curl::get($url, Sign::api($payload));
|
$raw = Curl::get($url, Sign::api($payload));
|
||||||
|
|||||||
@ -18,7 +18,7 @@ class MaterialObject
|
|||||||
{
|
{
|
||||||
use TimeLock;
|
use TimeLock;
|
||||||
|
|
||||||
private static $discard_aid_list = [];
|
private static $invalid_aids = [];
|
||||||
private static $start_aid = 0;
|
private static $start_aid = 0;
|
||||||
private static $end_aid = 0;
|
private static $end_aid = 0;
|
||||||
|
|
||||||
@ -30,100 +30,158 @@ class MaterialObject
|
|||||||
if (self::getLock() > time()) {
|
if (self::getLock() > time()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 计算AID TODO 待优化
|
// TODO 优化计算AID算法
|
||||||
self::calculateAid(150, 550);
|
self::calcAid(470, 770);
|
||||||
self::drawLottery();
|
$lottery_list = self::fetchLottery();
|
||||||
|
self::drawLottery($lottery_list);
|
||||||
self::setLock(random_int(5, 10) * 60);
|
self::setLock(random_int(5, 10) * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 实物抽奖
|
* @use 过滤抽奖Title
|
||||||
|
* @param string $title
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected static function drawLottery(): bool
|
private static function filterTitleWords(string $title): bool
|
||||||
{
|
{
|
||||||
$block_key_list = [
|
$sensitive_words = [
|
||||||
'测试', '加密', 'test', 'TEST', '钓鱼', '炸鱼', '调试', "123", "1111", "测试", "測試","Test",
|
'测试', '加密', 'test', 'TEST', '钓鱼', '炸鱼', '调试', "123", "1111", "测试", "測試", "Test",
|
||||||
"测一测", "ce-shi", "test", "T-E-S-T", "lala", "我是抽奖标题", "压测", "測一測", "t-e-s-t"
|
"测一测", "ce-shi", "test", "T-E-S-T", "lala", "我是抽奖标题", "压测", "測一測", "t-e-s-t"
|
||||||
];
|
];
|
||||||
$flag = 5;
|
foreach ($sensitive_words as $word) {
|
||||||
|
if (strpos($title, $word) !== false) {
|
||||||
for ($i = self::$start_aid; $i < self::$end_aid; $i++) {
|
return true;
|
||||||
if (!$flag) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
// 在丢弃列表里 跳过
|
}
|
||||||
if (in_array($i, self::$discard_aid_list)) {
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 抽奖盒子状态
|
||||||
|
* @param int $aid
|
||||||
|
* @param string $reply
|
||||||
|
* @return array|bool|mixed
|
||||||
|
*/
|
||||||
|
private static function boxStatus(int $aid, $reply = 'bool')
|
||||||
|
{
|
||||||
|
$payload = [
|
||||||
|
'aid' => $aid,
|
||||||
|
];
|
||||||
|
$raw = Curl::get('https://api.live.bilibili.com/lottery/v1/box/getStatus', Sign::api($payload));
|
||||||
|
$de_raw = json_decode($raw, true);
|
||||||
|
switch ($reply) {
|
||||||
|
// 等于0是有抽奖返回false
|
||||||
|
case 'bool':
|
||||||
|
if ($de_raw['code'] == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case 'array':
|
||||||
|
if ($de_raw['code'] == 0) {
|
||||||
|
return $de_raw;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
default:
|
||||||
|
return $de_raw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 获取抽奖
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function fetchLottery(): array
|
||||||
|
{
|
||||||
|
$lottery_list = [];
|
||||||
|
$max_probe = 5;
|
||||||
|
$probes = range(self::$start_aid, self::$end_aid);
|
||||||
|
foreach ($probes as $probe_aid) {
|
||||||
|
// 最大试探
|
||||||
|
if ($max_probe == 0) break;
|
||||||
|
// 无效列表
|
||||||
|
if (in_array($probe_aid, self::$invalid_aids)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// 试探
|
||||||
|
$response = self::boxStatus($probe_aid, 'array');
|
||||||
|
if (empty($response)) {
|
||||||
|
$max_probe--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$rounds = $response['data']['typeB'];
|
||||||
|
$last_round = end($rounds);
|
||||||
|
// 最后抽奖轮次无效
|
||||||
|
if ($last_round['join_end_time'] < time()) {
|
||||||
|
array_push(self::$invalid_aids, $probe_aid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 过滤敏感词
|
||||||
|
$title = $response['data']['title'];
|
||||||
|
if (self::filterTitleWords($title)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 过滤抽奖轮次
|
||||||
|
$round_num = self::filterRound($rounds);
|
||||||
|
if ($round_num == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
array_push($lottery_list, [
|
||||||
|
'aid' => $probe_aid,
|
||||||
|
'num' => $round_num,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $lottery_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 过滤轮次
|
||||||
|
* @param array $rounds
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private static function filterRound(array $rounds): int
|
||||||
|
{
|
||||||
|
foreach ($rounds as $round) {
|
||||||
|
$join_start_time = $round['join_start_time'];
|
||||||
|
$join_end_time = $round['join_end_time'];
|
||||||
|
if ($join_end_time > time() && time() > $join_start_time) {
|
||||||
|
$status = $round['status'];
|
||||||
|
/*
|
||||||
|
* 3 结束 1 抽过 -1 未开启 0 可参与
|
||||||
|
*/
|
||||||
|
if ($status == 0) {
|
||||||
|
return $round['round_num'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 抽奖
|
||||||
|
* @param array $lottery_list
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function drawLottery(array $lottery_list): bool
|
||||||
|
{
|
||||||
|
foreach ($lottery_list as $lottery) {
|
||||||
|
$aid = $lottery['aid'];
|
||||||
|
$num = $lottery['num'];
|
||||||
|
Log::notice("实物抽奖 {$aid} 轮次 {$num} 可参与抽奖~");
|
||||||
$payload = [
|
$payload = [
|
||||||
'aid' => $i,
|
'aid' => $aid,
|
||||||
|
'number' => $num,
|
||||||
];
|
];
|
||||||
$url = 'https://api.live.bilibili.com/lottery/v1/box/getStatus';
|
$raw = Curl::get('https://api.live.bilibili.com/lottery/v1/Box/draw', Sign::api($payload));
|
||||||
// 请求 && 解码
|
|
||||||
$raw = Curl::get($url, Sign::api($payload));
|
|
||||||
$de_raw = json_decode($raw, true);
|
$de_raw = json_decode($raw, true);
|
||||||
// -403 没有抽奖
|
if ($de_raw['code'] == 0) {
|
||||||
if ($de_raw['code'] != '0') {
|
Log::notice("实物抽奖 {$aid} 轮次 {$num} 参与抽奖成功~");
|
||||||
$flag--;
|
} else {
|
||||||
continue;
|
Log::notice("实物抽奖 {$aid} 轮次 {$num} {$de_raw['msg']}~");
|
||||||
}
|
|
||||||
// 如果最后一个结束时间已过 加入丢弃
|
|
||||||
$lotterys = $de_raw['data']['typeB'];
|
|
||||||
$total = count($lotterys);
|
|
||||||
if ($lotterys[$total - 1]['join_end_time'] < time()) {
|
|
||||||
array_push(self::$discard_aid_list, $i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果存在敏感词 加入丢弃
|
|
||||||
$title = $de_raw['data']['title'];
|
|
||||||
foreach ($block_key_list as $block_key) {
|
|
||||||
if (strpos($title, $block_key) !== false) {
|
|
||||||
array_push(self::$discard_aid_list, $i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = 1;
|
|
||||||
foreach ($lotterys as $lottery) {
|
|
||||||
$join_end_time = $lottery['join_end_time'];
|
|
||||||
$join_start_time = $lottery['join_start_time'];
|
|
||||||
|
|
||||||
if ($join_end_time > time() && time() > $join_start_time) {
|
|
||||||
switch ($lottery['status']) {
|
|
||||||
case 3:
|
|
||||||
Log::info("实物[{$i}]抽奖: 当前轮次已经结束!");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
Log::info("实物[{$i}]抽奖: 当前轮次已经抽过了!");
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
Log::info("实物[{$i}]抽奖: 当前轮次暂未开启!");
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
Log::info("实物[{$i}]抽奖: 当前轮次正在抽奖中!");
|
|
||||||
|
|
||||||
$payload = [
|
|
||||||
'aid' => $i,
|
|
||||||
'number' => $num,
|
|
||||||
];
|
|
||||||
$raw = Curl::get('https://api.live.bilibili.com/lottery/v1/box/draw', Sign::api($payload));
|
|
||||||
$de_raw = json_decode($raw, true);
|
|
||||||
|
|
||||||
if ($de_raw['code'] == 0) {
|
|
||||||
Log::notice("实物[{$i}]抽奖: 成功!");
|
|
||||||
}
|
|
||||||
$num++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Log::info("实物[{$i}]抽奖: 当前轮次状态码[{$lottery['status'] }]未知!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -131,22 +189,21 @@ class MaterialObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 计算开始结束的AID
|
* @use 计算Aid
|
||||||
* @param $min
|
* @param $min
|
||||||
* @param $max
|
* @param $max
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private static function calculateAid($min, $max): bool
|
private static function calcAid($min, $max): bool
|
||||||
{
|
{
|
||||||
if (self::$end_aid != 0 && self::$start_aid != 0) {
|
if (self::$end_aid != 0 && self::$start_aid != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
while (true) {
|
||||||
while (1) {
|
|
||||||
$middle = round(($min + $max) / 2);
|
$middle = round(($min + $max) / 2);
|
||||||
if (self::aidPost($middle)) {
|
if (self::boxStatus($middle)) {
|
||||||
if (self::aidPost($middle + random_int(0, 3))) {
|
if (self::boxStatus($middle + random_int(0, 3))) {
|
||||||
$max = $middle;
|
$max = $middle;
|
||||||
} else {
|
} else {
|
||||||
$min = $middle;
|
$min = $middle;
|
||||||
@ -158,31 +215,9 @@ class MaterialObject
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self::$start_aid = $min - random_int(15, 30);
|
||||||
self::$start_aid = $min - random_int(30, 40);
|
self::$end_aid = $min + random_int(15, 30);
|
||||||
self::$end_aid = $min + random_int(30, 40);
|
|
||||||
Log::info("实物抽奖起始值[" . self::$start_aid . "],结束值[" . self::$end_aid . "]");
|
Log::info("实物抽奖起始值[" . self::$start_aid . "],结束值[" . self::$end_aid . "]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @use Aid 请求
|
|
||||||
* @param $aid
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private static function aidPost($aid): bool
|
|
||||||
{
|
|
||||||
$payload = [
|
|
||||||
'aid' => $aid,
|
|
||||||
];
|
|
||||||
$raw = Curl::get('https://api.live.bilibili.com/lottery/v1/box/getStatus', Sign::api($payload));
|
|
||||||
$de_raw = json_decode($raw, true);
|
|
||||||
|
|
||||||
// 等于0是有抽奖返回false
|
|
||||||
if ($de_raw['code'] == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 没有抽奖
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ class PkRaffle extends BaseRaffle
|
|||||||
'room_id' => $room_id,
|
'room_id' => $room_id,
|
||||||
'raffle_id' => $pk['id'],
|
'raffle_id' => $pk['id'],
|
||||||
'raffle_name' => '大乱斗',
|
'raffle_name' => '大乱斗',
|
||||||
'wait' => time()
|
'wait' => time() + random_int(5, 25)
|
||||||
];
|
];
|
||||||
Statistics::addPushList(self::ACTIVE_TITLE);
|
Statistics::addPushList(self::ACTIVE_TITLE);
|
||||||
array_push(self::$wait_list, $data);
|
array_push(self::$wait_list, $data);
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class StormRaffle extends BaseRaffle
|
|||||||
}
|
}
|
||||||
// 过滤抽奖范围
|
// 过滤抽奖范围
|
||||||
self::$drop_rate = getenv('STORM_DROPRATE') !== "" ? (int)getenv('STORM_DROPRATE') : 0;
|
self::$drop_rate = getenv('STORM_DROPRATE') !== "" ? (int)getenv('STORM_DROPRATE') : 0;
|
||||||
if (mt_rand(1, 100) <= (int)self::$drop_rate) {
|
if (random_int(1, 100) <= (int)self::$drop_rate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 去重
|
// 去重
|
||||||
|
|||||||
@ -309,7 +309,7 @@ class ZoneTcpClient
|
|||||||
private static function genHandshakePkg($room_id): string
|
private static function genHandshakePkg($room_id): string
|
||||||
{
|
{
|
||||||
return self::packMsg(json_encode([
|
return self::packMsg(json_encode([
|
||||||
'uid' => mt_rand(1000000, 2999999),
|
'uid' => random_int(1000000, 2999999),
|
||||||
'roomid' => intval($room_id),
|
'roomid' => intval($room_id),
|
||||||
]), 0x0007);
|
]), 0x0007);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user