-
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.
- Loading branch information
Showing
16 changed files
with
137 additions
and
20 deletions.
There are no files selected for viewing
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
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,10 @@ | ||
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 |
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,48 @@ | ||
import json | ||
|
||
from ..utils.fetch import Fetch | ||
from .notify import Notify | ||
|
||
|
||
class Telegram(Notify): | ||
""" | ||
Telegram通知 | ||
""" | ||
|
||
def __init__(self, token='', chatid=''): | ||
self.token = token | ||
self.chatid = chatid | ||
self.url = 'https://api.telegram.org' | ||
|
||
def _signature(self): | ||
pass | ||
|
||
def seturl(self, url): | ||
self.url = url | ||
|
||
def _geturl(self, uri='sendMessage'): | ||
""" | ||
生成请求的 URL | ||
""" | ||
return f'{self.url}/bot{self.token}/{uri}' | ||
|
||
def send(self, message): | ||
""" | ||
发送通知 | ||
:param message: 消息内容 | ||
""" | ||
req_url = self._geturl() | ||
|
||
headers = { | ||
'content-type': 'application/json', | ||
} | ||
req = Fetch() | ||
req.update_headers(headers) | ||
|
||
data = { | ||
'chat_id': self.chatid, | ||
'text': message, | ||
} | ||
data = json.dumps(data, indent=4) | ||
req.post(req_url, data=data.encode('utf-8')) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.bark import Bark | ||
from ipush import Bark | ||
|
||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.chanify import Chanify | ||
from ipush import Chanify | ||
|
||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.dingtalk import Dingtalk | ||
from ipush import Dingtalk | ||
|
||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.feishu import Feishu | ||
from ipush import Feishu | ||
|
||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.lark import Lark | ||
from ipush import Lark | ||
|
||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.pushdeer import PushDeer | ||
from ipush import PushDeer | ||
|
||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.pushplus import PushPlus | ||
from ipush import PushPlus | ||
|
||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.showdoc import Showdoc | ||
from ipush import Showdoc | ||
|
||
|
||
@pytest.fixture | ||
|
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,42 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from ipush import Telegram | ||
|
||
|
||
@pytest.fixture | ||
def access_token(): | ||
token = os.environ.get('TelegramToken') | ||
chat_id = os.environ.get('TelegramChatId') | ||
custom_url = os.environ.get('TelegramCustomURL') | ||
return token, chat_id, custom_url | ||
|
||
|
||
@pytest.mark.skipif( | ||
not os.environ.get('TelegramToken') or not os.environ.get('TelegramChatId'), | ||
reason='Telegram Token not provided', | ||
) | ||
def test_telegram(access_token): | ||
token, chat_id, _ = access_token | ||
notify = Telegram(token, chat_id) | ||
res = notify.send('pypush test') | ||
assert res.status_code == 200 | ||
json = res.json() | ||
assert json['ok'] | ||
|
||
|
||
@pytest.mark.skipif( | ||
not os.environ.get('TelegramToken') | ||
or not os.environ.get('TelegramChatId') | ||
or not os.environ.get('TelegramCustomURL'), | ||
reason='Telegram Token not provided', | ||
) | ||
def test_telegram_custom_url(access_token): | ||
token, chat_id, custom_url = access_token | ||
notify = Telegram(token, chat_id) | ||
notify.seturl(custom_url) | ||
res = notify.send('pypush test custom url') | ||
assert res.status_code == 200 | ||
json = res.json() | ||
assert json['ok'] |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ipush.notify.xizhi import Xizhi | ||
from ipush import Xizhi | ||
|
||
|
||
@pytest.fixture | ||
|