12306/config/pushbearConf.py

41 lines
1.1 KiB
Python
Raw Normal View History

# -*- coding: utf8 -*-
2019-01-16 03:19:32 +00:00
import time
import requests
from config.ticketConf import _get_yaml
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:
"""
conf = _get_yaml()
if conf["pushbear_conf"]["is_pushbear"] and conf["pushbear_conf"]["send_key"].strip() != "":
try:
2019-01-16 03:19:32 +00:00
sendPushBearUrls = urls.get("Pushbear")
data = {
"sendkey": conf["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)