12306/config/pushbearConf.py

37 lines
1.1 KiB
Python
Raw Normal View History

# -*- coding: utf8 -*-
2019-09-01 04:41:25 +00:00
import TickerConfig
2019-01-16 03:19:32 +00:00
from config.urlConf import urls
from myUrllib.httpUtils import HTTPClient
2019-01-10 17:11:18 +00:00
PUSH_BEAR_API_PATH = "https://pushbear.ftqq.com/sub"
2019-01-16 03:19:32 +00:00
def sendPushBear(msg):
"""
pushBear微信通知
:param str: 通知内容 content
:return:
"""
2019-09-02 07:21:06 +00:00
if TickerConfig.PUSHBEAR_CONF["is_pushbear"] and TickerConfig.PUSHBEAR_CONF["send_key"].strip() != "":
try:
2019-01-16 03:19:32 +00:00
sendPushBearUrls = urls.get("Pushbear")
data = {
2019-09-02 07:21:06 +00:00
"sendkey": TickerConfig.PUSHBEAR_CONF["send_key"].strip(),
2019-01-17 09:37:36 +00:00
"text": "易行购票成功通知",
2019-01-16 03:19:32 +00:00
"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__':
2019-01-16 03:19:32 +00:00
sendPushBear(1)