mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 01:20:08 +08:00
feat: add push deer
This commit is contained in:
parent
d0277f9ddb
commit
4602e28320
@ -184,6 +184,11 @@ to_user =
|
||||
[notify_bark]
|
||||
token =
|
||||
|
||||
; PushDeer/服务器地址/token
|
||||
[notify_push_deer]
|
||||
url =
|
||||
token =
|
||||
|
||||
#######################
|
||||
# 网络设置 #
|
||||
#######################
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user