-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add some providers, rename notify to provider
- Loading branch information
Showing
31 changed files
with
272 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[project] | ||
name = "ipush" | ||
version = "0.3.0" | ||
description = "APP 推送通知。支持往 钉钉群、飞书群、Lark 群、Bark、Chanify、PushDeer、PushPlus、Showdoc、息知 推送消息。" | ||
version = "0.4.0" | ||
description = "向 APP、微信平台推送通知。支持 Telegram、钉钉群、飞书群、Lark 群、Bark 等平台。" | ||
authors = [ | ||
{ name = "Jetsung Chan", email = "[email protected]" } | ||
] | ||
|
@@ -10,7 +10,7 @@ dependencies = [ | |
"lxml>=4.9.4", | ||
] | ||
readme = "README.md" | ||
keywords = ["push", "notify", "dingtalk", "feishu", "lark", "bark", "chanify", "pushdeer", "pushplus", "showdoc", "xizhi"] | ||
keywords = ["push", "notify", "telegram", "dingtalk", "feishu", "lark", "bark", "chanify", "pushdeer", "pushplus", "showdoc", "xizhi"] | ||
requires-python = ">= 3.8" | ||
classifiers = [ | ||
'Development Status :: 4 - Beta', | ||
|
@@ -37,6 +37,7 @@ classifiers = [ | |
Homepage = "https://git.jetsung.com/idev/pypush" | ||
Documentation = "https://pypush.skiy.net/" | ||
Repository = "https://github.com/idevsig/pypush" | ||
Download = "https://github.com/idevsig/pypush/releases" | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
from .notify.bark import Bark | ||
from .notify.chanify import Chanify | ||
from .notify.dingtalk import Dingtalk | ||
from .notify.feishu import Feishu | ||
from .notify.lark import Lark | ||
from .notify.pushdeer import PushDeer | ||
from .notify.pushplus import PushPlus | ||
from .notify.showdoc import Showdoc | ||
from .notify.telegram import Telegram | ||
from .notify.xizhi import Xizhi | ||
from .provider.alertzy import Alertzy | ||
from .provider.bark import Bark | ||
from .provider.chanify import Chanify | ||
from .provider.dingtalk import Dingtalk | ||
from .provider.feishu import Feishu | ||
from .provider.lark import Lark | ||
from .provider.notify import Notify | ||
from .provider.pushdeer import PushDeer | ||
from .provider.pushplus import PushPlus | ||
from .provider.showdoc import Showdoc | ||
from .provider.telegram import Telegram | ||
from .provider.xizhi import Xizhi |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import json | ||
|
||
from ..utils.fetch import Fetch | ||
from ._provider import Provider | ||
|
||
|
||
class Alertzy(Provider): | ||
""" | ||
Alertzy通知 | ||
""" | ||
|
||
def __init__(self, token=''): | ||
self.token = token | ||
|
||
def _signature(self): | ||
pass | ||
|
||
def _geturl(self): | ||
""" | ||
生成请求的 URL | ||
""" | ||
return 'https://alertzy.app/send' | ||
|
||
def send(self, message, title=''): | ||
""" | ||
发送通知 | ||
:param message: 消息内容 | ||
""" | ||
req_url = self._geturl() | ||
|
||
req = Fetch() | ||
|
||
data = { | ||
'accountKey': self.token, | ||
'title': '新消息' if title == '' else title, | ||
'message': message, | ||
} | ||
req.post(req_url, data) | ||
return req.response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import json | ||
|
||
from ..utils.fetch import Fetch | ||
from ._provider import Provider | ||
|
||
|
||
class Notify(Provider): | ||
""" | ||
Notify通知 | ||
""" | ||
|
||
def __init__(self, token='', user_id=''): | ||
self.token = token | ||
self.user_id = user_id | ||
|
||
def _signature(self): | ||
pass | ||
|
||
def _geturl(self): | ||
""" | ||
生成请求的 URL | ||
""" | ||
return 'https://notify.dev/api/v1/notify' | ||
|
||
def send(self, message, title=''): | ||
""" | ||
发送通知 | ||
:param message: 消息内容 | ||
""" | ||
req_url = self._geturl() | ||
|
||
headers = { | ||
'Content-Type': 'application/json', | ||
'Authorization': self.token, | ||
} | ||
req = Fetch() | ||
req.update_headers(headers) | ||
|
||
data = { | ||
'user_id': self.user_id, | ||
'title': '新消息' if title == '' else title, | ||
'body': message, | ||
} | ||
data = json.dumps(data, indent=4) | ||
req.post(req_url, data=data.encode('utf-8')) | ||
return req.response |
4 changes: 2 additions & 2 deletions
4
src/ipush/notify/pushdeer.py → src/ipush/provider/pushdeer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/ipush/notify/pushplus.py → src/ipush/provider/pushplus.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/ipush/notify/telegram.py → src/ipush/provider/telegram.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def title(): | ||
return 'iPush' | ||
|
||
|
||
@pytest.fixture | ||
def message(): | ||
return 'PyPush test' | ||
|
||
|
||
@pytest.fixture | ||
def custom_message(): | ||
return 'PyPush test custom url' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from ipush import Alertzy | ||
|
||
|
||
@pytest.fixture | ||
def access_token(): | ||
token = os.environ.get('AlertzyToken') | ||
return token | ||
|
||
|
||
@pytest.mark.skipif( | ||
not os.environ.get('AlertzyToken'), reason='Alertzy Token not provided' | ||
) | ||
def test_alertzy(access_token, message): | ||
token = access_token | ||
notify = Alertzy(token) | ||
res = notify.send(message) | ||
assert res.status_code == 200 | ||
json = res.json() | ||
assert json['response'] == 'success' | ||
|
||
|
||
@pytest.mark.skipif( | ||
not os.environ.get('AlertzyToken'), reason='Alertzy Token not provided' | ||
) | ||
def test_alertzy_title(access_token, title, message): | ||
token = access_token | ||
notify = Alertzy(token) | ||
res = notify.send(message, title) | ||
assert res.status_code == 200 | ||
json = res.json() | ||
assert json['response'] == 'success' |
Oops, something went wrong.