[add] Support bark notice push

This commit is contained in:
Lkeme 2023-01-10 16:30:16 +08:00
parent de45364e5a
commit ee9afc6635
3 changed files with 54 additions and 1 deletions

View File

@ -125,8 +125,30 @@ agent_id = ****
to_user = UserId1|UserId2|UserId3
```
**飞书**
> 文档: https://developers.dingtalk.com/document/robots/custom-robot-access
> 说明: 推送的AccessToken
```ini
; 飞书机器人/依赖USE_NOTIFY
[notify_feishu]
token =
```
**飞书**
> 文档: https://github.com/Finb/Bark
> 说明: 推送的AccessToken
```ini
; Bark/Token
[notify_bark]
token =
```
### 调试
https://github.com/lkeme/BiliHelper-personal/blob/eb06f55fa0fa6cb07bbeffc7e85c6ac0bfaa67b3/data/latest_version.json#L8
改成与线上不同的版本即可,检查新版本就会推送一次。
改成与线上不同的版本即可,检查新版本就会推送一次。

View File

@ -180,6 +180,10 @@ corp_secret =
agent_id =
to_user =
; Bark/Token
[notify_bark]
token =
#######################
# 网络设置 #
#######################

View File

@ -97,6 +97,9 @@ class Notice extends SingleTon
if (getConf('notify_feishu.token')) {
$this->feiShuSend($info);
}
if (getConf('notify_bark.token')) {
$this->bark($info);
}
}
/**
@ -471,6 +474,30 @@ class Notice extends SingleTon
}
}
/**
* Bark Public 推送
* @doc https://github.com/Finb/Bark
* @param array $info
*/
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']}");
} else {
Log::warning("推送消息失败: $raw");
}
}
}