Merge pull request #203 from StringKe/master

feat: add PushDeer
This commit is contained in:
lkeme 2023-01-26 23:13:24 +08:00 committed by GitHub
commit a76cdd1c85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -184,6 +184,11 @@ to_user =
[notify_bark]
token =
; PushDeer/服务器地址/token
[notify_push_deer]
url =
token =
#######################
# 网络设置 #
#######################

View File

@ -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");
}
}
}