Skip to content

Commit

Permalink
[fix] Notice
Browse files Browse the repository at this point in the history
  • Loading branch information
lkeme committed Jan 28, 2020
1 parent 2ca80eb commit f3ecfe5
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# Release Notes
# 本项目Log

## v0.1.0.200128 alpha (2020-01-28)

### Added
- 增加推送消息过滤
-

### Changed
-

### Fixed
- 修复抽奖推送错误
-

## v0.1.0.200111 alpha (2020-01-11)

### Added
- 天选时刻奖品过滤
-

### Changed
-
Expand Down
4 changes: 2 additions & 2 deletions DOC.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.1.0.200111 alpha-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/version-0.1.0.200128 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>

Expand Down Expand Up @@ -33,7 +33,7 @@ B 站直播实用脚本
|AloneTcpClient |19.12.27 |独立监控 |
|ZoneTcpClient |19.12.27 |分区监控 |
|StormRaffle |20.01.03 |节奏风暴 |
|GiftRaffle |20.01.03 |活动礼物 |
|GiftRaffle |20.01.28 |活动礼物 |
|PkRaffle |20.01.03 |大乱斗 |
|GuardRaffle |20.01.03 |舰长总督 |
|AnchorRaffle |20.01.11 |天选时刻 |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Group: [55308141](https://jq.qq.com/?_wv=1027&k=5AIDaJg)

## 公告

Currently for Personal Edition **0.1.0.200111 alpha**
Currently for Personal Edition **0.1.0.200128 alpha**

## 文档

Expand Down
8 changes: 5 additions & 3 deletions conf/user.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@ ALONE_SERVER_KEY=,*(?PVl]nIbo35sB
USE_ZONE_SERVER=false
ZONE_SERVER_ADDR=tcp://broadcastlv.chat.bilibili.com:2243/sub

# 切换HTTPS,为真则使用https协议
# 切换HTTPS|为真则使用https协议
USE_HTTPS=true

# 是否使用代理(前提保证有效代理)
USE_PROXY=false
PROXY_IP=127.0.0.1
PROXY_PORT=8888

# SERVER酱, 用于推送消息
USE_SCKEY=
# SERVER酱|令牌KEY|过滤关键词|逗号分隔
USE_SC=false
SC_KEY=
SC_FILTER_WORDS=

#######################
# 房间设置 #
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/AnchorRaffle.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected static function filterPrizeWords(string $prize_name): bool
"0.1", "五毛二", "一分", "一毛", "0.52", "0.66", "0.01", "0.77", "0.16", "照片", "", "0.5",
"0.88", "双排"
];
$custom_words = empty(getenv('ANCHOR_TYPE')) ? [] : explode(',', getenv('ANCHOR_TYPE'));
$custom_words = empty(getenv('ANCHOR_FILTER_WORDS')) ? [] : explode(',', getenv('ANCHOR_FILTER_WORDS'));
$total_words = array_merge($default_words, $custom_words);
foreach ($total_words as $word) {
if (strpos($prize_name, $word) !== false) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/GiftRaffle.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected static function parseLottery(array $results)
if (isset($de_raw['code']) && !$de_raw['code']) {
// 推送中奖信息
if ($de_raw['data']['award_name'] != '辣条' && $de_raw['data']['award_name'] != '') {
$info = $de_raw['data']['gift_name'] . 'x' . $de_raw['data']['gift_num'];
$info = $de_raw['data']['award_name'] . 'x' . $de_raw['data']['award_name'];
Notice::push('gift', $info);
}
Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . self::ACTIVE_TITLE . ": {$de_raw['data']['award_name']}x{$de_raw['data']['award_num']}");
Expand Down
26 changes: 22 additions & 4 deletions src/plugin/Notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,36 @@ class Notice
*/
public static function push(string $type, string $result = '')
{
if (getenv('USE_SCKEY') == "") {
if (getenv('USE_SC') == 'false' || getenv('SC_KEY') == "") {
return;
}

self::$type = $type;
self::$result = $result;
self::$sckey = getenv('USE_SCKEY');
self::$sckey = getenv('SC_KEY');
self::$uname = User::userInfo() ? getenv('APP_UNAME') : getenv('APP_USER');

if (self::filterResultWords($result)) {
return;
}
self::sendInfoHandle();
}

/**
* @use 过滤信息
* @param string $result
* @return bool
*/
private static function filterResultWords(string $result): bool
{
$default_words = [];
$custom_words = empty(getenv('SC_FILTER_WORDS')) ? [] : explode(',', getenv('SC_FILTER_WORDS'));
$total_words = array_merge($default_words, $custom_words);
foreach ($total_words as $word) {
if (strpos($result, $word) !== false) {
return true;
}
}
return false;
}

/**
* @use 处理信息
Expand Down

0 comments on commit f3ecfe5

Please sign in to comment.