Skip to content

Commit 3a29fcb

Browse files
committed
feat: add pages
1 parent df71e34 commit 3a29fcb

File tree

8 files changed

+163
-13
lines changed

8 files changed

+163
-13
lines changed

.github/workflows/build-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
shell: bash
1818
env:
1919
RYE_INSTALL_OPTION: "--yes"
20-
RYE_VERSION: 0.16.0
20+
RYE_VERSION: 0.17.0
2121
run: |
2222
curl -fSL https://rye-up.com/get | bash
2323
echo "$HOME/.rye/shims" >> $GITHUB_PATH
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
2+
name: GitHub Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Build job
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
- name: Setup Pages
32+
uses: actions/configure-pages@v4
33+
- name: Build with Jekyll
34+
uses: actions/jekyll-build-pages@v1
35+
with:
36+
source: ./docs
37+
destination: ./_site
38+
- name: Upload artifact
39+
uses: actions/upload-pages-artifact@v3
40+
41+
# Deployment job
42+
deploy:
43+
environment:
44+
name: github-pages
45+
url: ${{ steps.deployment.outputs.page_url }}
46+
runs-on: ubuntu-latest
47+
needs: build
48+
steps:
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ notify.send("iPush test")
3232

3333
## 支持平台
3434

35-
| 状态 | **国内**平台 | 官网 | 文档 | 备注 |
36-
| :------- | :---------------- | :-------------------------------------------------------------------------------------------------------- | :--- | :----------- |
37-
|**** | **钉钉群机器人** | [https://open.dingtalk.com/](https://open.dingtalk.com/document/robots/customize-robot-security-settings) | - | |
38-
|**** | **飞书群机器人** | [https://open.feishu.cn/](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot) | - | |
39-
|**** | **Lark 群机器人** | [https://open.larksuite.com/](https://open.larksuite.com/document/client-docs/bot-v3/add-custom-bot) | - | |
40-
|**** | **Bark** | [https://day.app/2021/06/barkfaq/](https://day.app/2021/06/barkfaq/) | - | 仅支持 `iOS` |
41-
|| **Chanify** | [https://www.chanify.net/](https://www.chanify.net/) | - | 仅支持 `iOS` |
42-
|| **PushDeer** | https://www.pushdeer.com/ | - | |
43-
| // | // | **基于微信公众号** | \\\\ | \\\\ |
44-
|| **PushPlus** | [https://www.pushplus.plus/](https://www.pushplus.plus/doc) | - | |
45-
|| **Showdoc** | [https://push.showdoc.com.cn/](https://www.showdoc.com.cn/push) | - | |
46-
|| **息知** | [https://xz.qqoq.net/](https://xz.qqoq.net/) | - | |
35+
| 状态 | **国内**平台 | 官网 | 文档 | 备注 |
36+
| :------- | :---------------- | :-------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------- | :----------- |
37+
|**** | **钉钉群机器人** | [https://open.dingtalk.com/](https://open.dingtalk.com/document/robots/customize-robot-security-settings) | - | |
38+
|**** | **飞书群机器人** | [https://open.feishu.cn/](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot) | - | |
39+
|**** | **Lark 群机器人** | [https://open.larksuite.com/](https://open.larksuite.com/document/client-docs/bot-v3/add-custom-bot) | - | |
40+
|**** | **Bark** | [https://day.app/2021/06/barkfaq/](https://day.app/2021/06/barkfaq/) | - | 仅支持 `iOS` |
41+
|| **Chanify** | [https://www.chanify.net/](https://www.chanify.net/) | - | 仅支持 `iOS` |
42+
|| **PushDeer** | https://www.pushdeer.com/ | - | |
43+
| // | // | **基于微信公众号** | \\\\ | \\\\ |
44+
|| **PushPlus** | [https://www.pushplus.plus/](https://www.pushplus.plus/doc) | - | |
45+
|| **Showdoc** | [https://push.showdoc.com.cn/](https://www.showdoc.com.cn/push) | - | |
46+
|| **息知** | [https://xz.qqoq.net/](https://xz.qqoq.net/) | - | |
47+
|| **聚合云推** | [https://tui.juhe.cn/](https://tui.juhe.cn/docs) | 聚合推送。支持 `邮箱``微信公众号``钉钉机器人``WebHook``企业微信``Bark` |
4748

4849
| 状态 | **国外**平台 | 官网 | 文档 | 备注 |
4950
| :------- | :----------- | :-------------------------------------------------------------------------------- | :--- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |

docs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,12 @@ from ipush import Notify
125125
notify = Notify("token", "user_id")
126126
notify.send("ipush test", "title")
127127
```
128+
129+
- **Juhe**
130+
131+
```python
132+
from ipush import Juhe
133+
134+
notify = Juhe("token", "service_id")
135+
notify.send("ipush test", "title")
136+
```

docs/_config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
theme: jekyll-theme-cayman
2+
title: ipush
3+
description: 向 APP、微信平台推送通知。支持往 Telegram、钉钉群、飞书群、Lark 群、Bark、Chanify、PushDeer、PushPlus、Showdoc、息知、Alertzy、Notify 推送消息。
4+
encoding: UTF-8
5+
highlighter: rouge
6+
7+
copyright:
8+
year: 2024
9+
name: Jetsung Chan
10+
11+
timezone: Asia/Shanghai

src/ipush/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .provider.chanify import Chanify
44
from .provider.dingtalk import Dingtalk
55
from .provider.feishu import Feishu
6+
from .provider.juhe import Juhe
67
from .provider.lark import Lark
78
from .provider.notify import Notify
89
from .provider.pushdeer import PushDeer

src/ipush/provider/juhe.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from ..utils.fetch import Fetch
2+
from ._provider import Provider
3+
4+
5+
class Juhe(Provider):
6+
"""
7+
Juhe通知
8+
"""
9+
10+
def __init__(self, token='', service_id=''):
11+
self.token = token
12+
self.service_id = service_id
13+
14+
def _signature(self):
15+
pass
16+
17+
def _geturl(self):
18+
"""
19+
生成请求的 URL
20+
"""
21+
return 'https://tui.juhe.cn/api/plus/pushApi'
22+
23+
def send(self, message, title=''):
24+
"""
25+
发送通知
26+
:param message: 消息内容
27+
"""
28+
req_url = self._geturl()
29+
30+
req = Fetch()
31+
32+
data = {
33+
'token': self.token,
34+
'service_id': self.service_id,
35+
'title': '新消息' if title == '' else title,
36+
'content': message,
37+
}
38+
req.post(req_url, data)
39+
return req.response

tests/test_juhe.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
3+
import pytest
4+
5+
from ipush import Juhe
6+
7+
8+
@pytest.fixture
9+
def access_token():
10+
token = os.environ.get('JuheToken')
11+
service_id = os.environ.get('JuheServiceID')
12+
return token, service_id
13+
14+
15+
@pytest.mark.skipif(
16+
not os.environ.get('JuheToken') or not os.environ.get('JuheServiceID'),
17+
reason='Juhe Token not provided',
18+
)
19+
def test_juhe(access_token, message):
20+
token, service_id = access_token
21+
notify = Juhe(token, service_id)
22+
res = notify.send(message)
23+
assert res.status_code == 200
24+
json = res.json()
25+
assert json['code'] == 200
26+
27+
28+
@pytest.mark.skipif(
29+
not os.environ.get('JuheToken') or not os.environ.get('JuheServiceID'),
30+
reason='Juhe Token not provided',
31+
)
32+
def test_juhe_title(access_token, title, message):
33+
token, service_id = access_token
34+
notify = Juhe(token, service_id)
35+
res = notify.send(message, title)
36+
assert res.status_code == 200
37+
json = res.json()
38+
assert json['code'] == 200

0 commit comments

Comments
 (0)