diff --git a/profile/example/config/user.ini b/profile/example/config/user.ini index 73e7ea7..b18ec3c 100644 --- a/profile/example/config/user.ini +++ b/profile/example/config/user.ini @@ -184,6 +184,11 @@ to_user = [notify_bark] token = +; PushDeer/服务器地址/token +[notify_push_deer] +url = +token = + ####################### # 网络设置 # ####################### diff --git a/src/Notice/Notice.php b/src/Notice/Notice.php index a13a1d7..773c475 100644 --- a/src/Notice/Notice.php +++ b/src/Notice/Notice.php @@ -100,6 +100,9 @@ class Notice extends SingleTon if (getConf('notify_bark.token')) { $this->bark($info); } + if (getConf('notify_push_deer.token')) { + $this->pushDeer($info); + } } /** @@ -499,5 +502,31 @@ class Notice extends SingleTon } } + protected function pushDeer(array $info) + { + Log::info('使用 PushDeer 推送消息'); + $token = getConf('notify_push_deer.token'); + $url = getConf('notify_push_deer.url'); + if (!str_contains($url, "http")){ + $url = "https://api2.pushdeer.com/message/push"; + } + + $payload = [ + "text" => $info['title'], + "desp" => $info['content'], + "pushkey" => $token + ]; + + $raw = Request::post('other', $url, $payload, [ + 'Content-Type' => 'application/x-www-form-urlencoded' + ]); + $de_raw = json_decode($raw, true); + if ($de_raw['code'] == 0){ + Log::notice("推送消息成功: {$de_raw['content']['result'][0]}"); + } else { + Log::warning("推送消息失败: $raw"); + } + } + }