-
Notifications
You must be signed in to change notification settings - Fork 666
/
Copy pathsend_message.py
43 lines (38 loc) · 1.24 KB
/
send_message.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import logging
import requests
def send_server_chan(sckey, title, desp):
"""
server酱推送
:param sckey: server酱推送的key
:param title: 标题
:param desp: 内容
:return:
"""
if sckey:
url = f"https://sctapi.ftqq.com/{sckey}.send"
data = {"title": title, "desp": desp}
response = requests.post(url, data=data)
if response.json()['data']['error'] == 'SUCCESS':
logging.info('Server酱 Turbo版推送成功')
else:
logging.info('Server酱 Turbo版推送失败')
else:
logging.warning("server酱 KEY 没有配置,不推送消息")
def send_pushplus(pushplus_key, title, message):
"""
pushplus 推送
:param pushplus_key: pushplus的token
:param title: 标题
:param message: 内容
:return:
"""
if pushplus_key:
url = "http://www.pushplus.plus/send"
data = {"token": pushplus_key, "title": title, "content": message}
response = requests.post(url, data=data)
if response.json()['code'] == 200:
logging.info('PushPlus推送成功')
else:
logging.info('PushPlus推送失败')
else:
logging.warning("PUSHPLUS_KEY 没有配置,不推送消息")