From c6606470a33e21ca5cb7602e096252db7c06e71f Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Tue, 28 Jan 2020 18:06:21 +0800 Subject: [PATCH] [fix] Notice --- CHANGELOG.md | 14 ++++++++++++++ DOC.md | 4 ++-- README.md | 2 +- conf/user.conf.example | 8 +++++--- src/plugin/AnchorRaffle.php | 2 +- src/plugin/GiftRaffle.php | 2 +- src/plugin/Notice.php | 26 ++++++++++++++++++++++---- 7 files changed, 46 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93fa775..95acc94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - diff --git a/DOC.md b/DOC.md index 6b642d8..d086a83 100644 --- a/DOC.md +++ b/DOC.md @@ -2,7 +2,7 @@

- +

@@ -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 |天选时刻 | diff --git a/README.md b/README.md index 0a1c3bc..186c0f6 100644 --- a/README.md +++ b/README.md @@ -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** ## 文档 diff --git a/conf/user.conf.example b/conf/user.conf.example index 7311894..0e60d85 100644 --- a/conf/user.conf.example +++ b/conf/user.conf.example @@ -70,7 +70,7 @@ 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 # 是否使用代理(前提保证有效代理) @@ -78,8 +78,10 @@ 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= ####################### # 房间设置 # diff --git a/src/plugin/AnchorRaffle.php b/src/plugin/AnchorRaffle.php index 8d26d93..cba2d52 100644 --- a/src/plugin/AnchorRaffle.php +++ b/src/plugin/AnchorRaffle.php @@ -44,7 +44,7 @@ class AnchorRaffle extends BaseRaffle "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) { diff --git a/src/plugin/GiftRaffle.php b/src/plugin/GiftRaffle.php index 55ece16..d82477a 100644 --- a/src/plugin/GiftRaffle.php +++ b/src/plugin/GiftRaffle.php @@ -114,7 +114,7 @@ class GiftRaffle extends BaseRaffle 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']}"); diff --git a/src/plugin/Notice.php b/src/plugin/Notice.php index 9a6be44..fd6826b 100644 --- a/src/plugin/Notice.php +++ b/src/plugin/Notice.php @@ -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 处理信息