forked from testerSunshine/12306
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpushbearConf.py
36 lines (31 loc) · 1.07 KB
/
pushbearConf.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
# -*- coding: utf8 -*-
import TickerConfig
from config.urlConf import urls
from myUrllib.httpUtils import HTTPClient
PUSH_BEAR_API_PATH = "https://pushbear.ftqq.com/sub"
def sendPushBear(msg):
"""
pushBear微信通知
:param str: 通知内容 content
:return:
"""
if TickerConfig.PUSHBEAR_CONF["is_pushbear"] and TickerConfig.PUSHBEAR_CONF["send_key"].strip() != "":
try:
sendPushBearUrls = urls.get("Pushbear")
data = {
"sendkey": TickerConfig.PUSHBEAR_CONF["send_key"].strip(),
"text": "易行购票成功通知",
"desp": msg
}
httpClint = HTTPClient(0)
sendPushBeaRsp = httpClint.send(sendPushBearUrls, data=data)
if sendPushBeaRsp.get("code") is 0:
print(u"已下发 pushbear 微信通知, 请查收")
else:
print(sendPushBeaRsp)
except Exception as e:
print(u"pushbear 配置有误 {}".format(e))
else:
pass
if __name__ == '__main__':
sendPushBear(1)