From 5ed2d9ff121349610aead55580531fa166b57bb5 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Tue, 9 May 2023 15:00:50 +0800 Subject: [PATCH] [fix] some bug --- composer.json | 2 +- plugin/Lottery/Lottery.php | 2 +- src/Notice/Notice.php | 22 +++++++++------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index b6ffb0c..3bbde41 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "amphp/amp": "3.x-dev", "fire015/flintstone": "dev-master", "overtrue/pinyin": "dev-master", - "guzzlehttp/guzzle": "dev-master", + "guzzlehttp/guzzle": "^7.0", "toolkit/pflag": "dev-main", "symfony/console": "^6.0", "malios/php-to-ascii-table": "dev-master" diff --git a/plugin/Lottery/Lottery.php b/plugin/Lottery/Lottery.php index 671f0a8..4e53ae9 100644 --- a/plugin/Lottery/Lottery.php +++ b/plugin/Lottery/Lottery.php @@ -183,7 +183,7 @@ class Lottery extends BasePlugin $response = Request::getJson(true, 'pc', $url, $payload); // 抽奖不存在 - if ($response['code'] === -9999) { + if ($response['code'] === -9999 || $response['code'] === 4000014) { return [ 'status' => -9999, ]; diff --git a/src/Notice/Notice.php b/src/Notice/Notice.php index 14b6d14..78130e7 100644 --- a/src/Notice/Notice.php +++ b/src/Notice/Notice.php @@ -485,20 +485,16 @@ class Notice extends SingleTon protected function bark(array $info): void { Log::info('使用bark推送消息'); - $url = 'https://api.day.app/' . getConf('notify_bark.token'); - - $payload = [ - 'msgtype' => 'markdown', - 'markdown' => [ - 'content' => "{$info['title']} \n\n{$info['content']}" - ] - ]; - $raw = Request::put('other', $url, $payload, $this->headers); - $de_raw = json_decode($raw, true); - if ($de_raw['message'] == 'success') { - Log::notice("推送消息成功: {$de_raw['errmsg']}"); + // 转url编码 + $info['title'] = urlencode($info['title']); + $info['content'] = urlencode($info['content']); + // + $url = 'https://api.day.app/' . getConf('notify_bark.token') . "/{$info['title']}/{$info['content']}"; + $de_raw = Request::getJson(true, 'other', $url, [], []); + if ($de_raw['code'] === 200) { + Log::notice("推送消息成功: {$de_raw['message']}"); } else { - Log::warning("推送消息失败: $raw"); + Log::warning('推送消息失败: ' . json_encode($de_raw)); } }