Merge pull request #152 from stormeyes/master

添加 pushbear 微信通知的能力
pull/187/head
wenxianping 6 years ago committed by GitHub
commit 3fd25c3925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,6 +6,7 @@ import requests
from agency.agency_tools import proxy
from config.emailConf import sendEmail
from config.pushbearConf import sendPushBear
def _set_header_default():
@ -38,6 +39,13 @@ class testAll(unittest.TestCase):
:return:
"""
sendEmail("订票小助手测试一下")
def testPushbear(self):
"""
实测pushbear是否可用
:return:
"""
sendPushBear("pushbear 微信通知测试一下")
# def testConfig(self):
# """

@ -0,0 +1,26 @@
# -*- coding: utf8 -*-
__author__ = 'kongkongyzt'
import requests
from config.ticketConf import _get_yaml
PUSH_BEAR_API_PATH = "https://pushbear.ftqq.com/sub"
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:
requests.get("{}?sendkey={}&text=来自12306抢票助手的通知&desp={}".format(PUSH_BEAR_API_PATH, conf["pushbear_conf"]["send_key"].strip(), msg))
print(u"已下发 pushbear 微信通知, 请查收")
except Exception as e:
print(u"pushbear 配置有误 {}".format(e))
else:
pass
if __name__ == '__main__':
sendPushBear(1)

@ -103,6 +103,11 @@ email_conf:
password: ""
host: "smtp.qq.com"
# 是否开启 pushbear 微信提醒, 使用前需要前往 http://pushbear.ftqq.com 扫码绑定获取 send_key 并关注获得抢票结果通知的公众号
pushbear_conf:
is_pushbear: False
send_key: ""
# 是否开启cdn查询可以更快的检测票票 1为开启2为关闭
is_cdn: 1

@ -4,6 +4,7 @@ import time
from config.TicketEnmu import ticket
from config.emailConf import sendEmail
from config.pushbearConf import sendPushBear
from myException.ticketIsExitsException import ticketIsExitsException
from myException.ticketNumOutException import ticketNumOutException
@ -42,6 +43,8 @@ class queryOrderWaitTime:
if data and data.get("orderId", ""):
sendEmail(ticket.WAIT_ORDER_SUCCESS.format(
data.get("orderId", "")))
sendPushBear(ticket.WAIT_ORDER_SUCCESS.format(
data.get("orderId", "")))
raise ticketIsExitsException(ticket.WAIT_ORDER_SUCCESS.format(
data.get("orderId")))
elif data.get("msg", False):

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Loading…
Cancel
Save