Skip to content

Commit

Permalink
feat: bark 推送增加铃声、分组和图标设置 (chen310#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
chen310 authored Mar 28, 2022
1 parent a6af279 commit 2fa4735
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,18 @@ cookie 获取方式:首先在网页登录[网易云音乐](https://music.163.c
"Bark_url": "",
/* Bark的API key */
"Bark_key": "",
/* 铃声 */
"sound": "",
/* 消息分组 */
"group": "",
/* 图标链接 */
"icon": "",
/* 是否将多个账号的信息合并推送, 建议为false,iOS推送消息过长可能会失败 */
"merge": false
}
```

要使用 Bark 的话需要填写 `Bark_url``Bark_key`。可以使用 Bark 官方 API 或者自行搭建。
要使用 Bark 的话需要填写 `Bark_url``Bark_key``sound``group``icon` 根据需要选填,如果不清楚如何填写就放空。可以使用 Bark 官方 API 或者自行搭建。

##### pushdeer

Expand Down
6 changes: 6 additions & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
"Bark_url": "",
/* Bark的API key */
"Bark_key": "",
/* 铃声 */
"sound": "",
/* 消息分组 */
"group": "",
/* 图标链接 */
"icon": "",
/* 是否将多个账号的信息合并推送, 建议为false,iOS推送消息过长可能会失败 */
"merge": false
},
Expand Down
13 changes: 10 additions & 3 deletions push/Bark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

def getKey(data):
config = data['config']
if len(config['Bark_key']) == 0:
if len(config['Bark_key']) == 0 or len(config['Bark_url']) == 0:
return None
return (config['module'], config['Bark_key'])
return (config['module'], config['Bark_key'], config['Bark_url'], config['sound'], config['group'], config['icon'])


def push(title, mdmsg, mdmsg_compat, textmsg, config):
Expand All @@ -16,5 +16,12 @@ def push(title, mdmsg, mdmsg_compat, textmsg, config):
if len(Bark_key) == 0 and len(Bark_url) == 0:
return
url = parse.urljoin(Bark_url, Bark_key)
data = {"title": title, "body": msg}
if config['sound']:
data['sound'] = config['sound']
if config['group']:
data['group'] = config['group']
if config['icon']:
data['icon'] = config['icon']

requests.post(url, data={"title": title, "body": msg})
requests.post(url, data=data)

0 comments on commit 2fa4735

Please sign in to comment.