Skip to content

Commit df71e34

Browse files
committed
feat: add some providers, rename notify to provider
1 parent fa30263 commit df71e34

31 files changed

+272
-74
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ipush
22

3-
APP 推送通知。支持往 **钉钉群、飞书群、Lark 群、Bark、Chanify、PushDeer、PushPlus、Showdoc、息知** 推送消息。
3+
向 APP、微信平台推送通知。
4+
支持往 **Telegram、钉钉群、飞书群、Lark 群、Bark、Chanify、PushDeer、PushPlus、Showdoc、息知、Alertzy、Notify** 推送消息。
45

56
---
67

@@ -26,7 +27,7 @@ pip install -U ipush
2627
from ipush import Dingtalk
2728

2829
notify = Dingtalk("token", "secret")
29-
notify.send("ipush test")
30+
notify.send("iPush test")
3031
```
3132

3233
## 支持平台
@@ -47,6 +48,8 @@ notify.send("ipush test")
4748
| 状态 | **国外**平台 | 官网 | 文档 | 备注 |
4849
| :------- | :----------- | :-------------------------------------------------------------------------------- | :--- | :--------------------------------------------------------------------------------------------------------------------------------------------------- |
4950
|**** | **Telegram** | [https://core.telegram.org/bots/](https://core.telegram.org/bots/api#sendmessage) | - | 创建[Bot](https://t.me/BotFather)后,将 Bot 添加至群组或频道,再添加[获取 ChatId 的机器人进群组](https://t.me/getmyid_bot)(可移除),即可获得`ChatId` |
51+
|| **Alertzy** | [https://alertzy.app/](https://alertzy.app/) | - | |
52+
|| **Notify** | [https://notify.dev/](https://notify.dev/docs/quickstart) | - | 安装手机 APP,复制设备 ID(`Settings -> Device ID`),输入到 [`Playground`](https://notify.dev/playground),获取二维码,再使用手机 APP 扫描 |
5053

5154
## 开发
5255

docs/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,21 @@ notify.send("ipush test", "chat_id")
107107
notify.seturl("https://self-hosted")
108108
notify.send("ipush test custom url")
109109
```
110+
111+
- **Alertzy**
112+
113+
```python
114+
from ipush import Alertzy
115+
116+
notify = Alertzy("token")
117+
notify.send("ipush test", "title")
118+
```
119+
120+
- **Notify**
121+
122+
```python
123+
from ipush import Notify
124+
125+
notify = Notify("token", "user_id")
126+
notify.send("ipush test", "title")
127+
```

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "ipush"
3-
version = "0.3.0"
4-
description = "APP 推送通知。支持往 钉钉群、飞书群、Lark 群、Bark、Chanify、PushDeer、PushPlus、Showdoc、息知 推送消息"
3+
version = "0.4.0"
4+
description = "向 APP、微信平台推送通知。支持 Telegram、钉钉群、飞书群、Lark 群、Bark 等平台"
55
authors = [
66
{ name = "Jetsung Chan", email = "[email protected]" }
77
]
@@ -10,7 +10,7 @@ dependencies = [
1010
"lxml>=4.9.4",
1111
]
1212
readme = "README.md"
13-
keywords = ["push", "notify", "dingtalk", "feishu", "lark", "bark", "chanify", "pushdeer", "pushplus", "showdoc", "xizhi"]
13+
keywords = ["push", "notify", "telegram", "dingtalk", "feishu", "lark", "bark", "chanify", "pushdeer", "pushplus", "showdoc", "xizhi"]
1414
requires-python = ">= 3.8"
1515
classifiers = [
1616
'Development Status :: 4 - Beta',
@@ -37,6 +37,7 @@ classifiers = [
3737
Homepage = "https://git.jetsung.com/idev/pypush"
3838
Documentation = "https://pypush.skiy.net/"
3939
Repository = "https://github.com/idevsig/pypush"
40+
Download = "https://github.com/idevsig/pypush/releases"
4041

4142
[build-system]
4243
requires = ["hatchling"]

src/ipush/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
from .notify.bark import Bark
2-
from .notify.chanify import Chanify
3-
from .notify.dingtalk import Dingtalk
4-
from .notify.feishu import Feishu
5-
from .notify.lark import Lark
6-
from .notify.pushdeer import PushDeer
7-
from .notify.pushplus import PushPlus
8-
from .notify.showdoc import Showdoc
9-
from .notify.telegram import Telegram
10-
from .notify.xizhi import Xizhi
1+
from .provider.alertzy import Alertzy
2+
from .provider.bark import Bark
3+
from .provider.chanify import Chanify
4+
from .provider.dingtalk import Dingtalk
5+
from .provider.feishu import Feishu
6+
from .provider.lark import Lark
7+
from .provider.notify import Notify
8+
from .provider.pushdeer import PushDeer
9+
from .provider.pushplus import PushPlus
10+
from .provider.showdoc import Showdoc
11+
from .provider.telegram import Telegram
12+
from .provider.xizhi import Xizhi
File renamed without changes.

src/ipush/notify/notify.py renamed to src/ipush/provider/_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from abc import abstractmethod
33

44
"""
5-
Notify 推送通知
5+
Provider 提供者
66
"""
77

88

9-
class Notify(ABC):
9+
class Provider(ABC):
1010
@abstractmethod
1111
def _signature(self):
1212
"""

src/ipush/provider/alertzy.py

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

src/ipush/notify/bark.py renamed to src/ipush/provider/bark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import json
22

33
from ..utils.fetch import Fetch
4-
from .notify import Notify
4+
from ._provider import Provider
55

66

7-
class Bark(Notify):
7+
class Bark(Provider):
88
"""
99
Bark通知
1010
"""
@@ -39,7 +39,7 @@ def send(self, message, title=''):
3939
req.update_headers(headers)
4040

4141
data = {
42-
'title': '' if title == '' else title,
42+
'title': '新消息' if title == '' else title,
4343
'body': message,
4444
'device_key': self.token,
4545
}

src/ipush/notify/chanify.py renamed to src/ipush/provider/chanify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import json
22

33
from ..utils.fetch import Fetch
4-
from .notify import Notify
4+
from ._provider import Provider
55

66

7-
class Chanify(Notify):
7+
class Chanify(Provider):
88
"""
99
Chanify通知
1010
"""

src/ipush/notify/dingtalk.py renamed to src/ipush/provider/dingtalk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
from ..utils.fetch import Fetch
55
from ..utils.helper import signature
6-
from .notify import Notify
6+
from ._provider import Provider
77

88

9-
class Dingtalk(Notify):
9+
class Dingtalk(Provider):
1010
"""
1111
钉钉通知
1212
"""

0 commit comments

Comments
 (0)