增加 server酱通知

pull/328/head
jasonqiao36 5 years ago
parent eb42e0d95f
commit 7a4b56ba91

@ -92,6 +92,13 @@ PUSHBEAR_CONF = {
"send_key": "" "send_key": ""
} }
# 是否开启 server酱 微信提醒, 使用前需要前往 http://sc.ftqq.com/3.version 扫码绑定获取 SECRET 并关注获得抢票结果通知的公众号
SERVER_CHAN_CONF = {
"is_server_chan": False,
"secret": ""
}
# 是否开启cdn查询可以更快的检测票票 1为开启2为关闭 # 是否开启cdn查询可以更快的检测票票 1为开启2为关闭
IS_CDN = 1 IS_CDN = 1

@ -53,5 +53,15 @@ class testAll(unittest.TestCase):
# :return: # :return:
# """ # """
def testServerChan(self):
"""
实测server酱是否可用
:return:
"""
from config.serverchanConf import sendServerChan
sendServerChan(u"server酱 微信通知测试一下")
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

@ -0,0 +1,36 @@
# -*- coding: utf8 -*-
import TickerConfig
from config.urlConf import urls
from myUrllib.httpUtils import HTTPClient
PUSH_SERVER_CHAN_PATH = "https://sc.ftqq.com"
def sendServerChan(msg):
"""
pushBear微信通知
:param str: 通知内容 content
:return:
"""
if (
TickerConfig.SERVER_CHAN_CONF["is_server_chan"]
and TickerConfig.SERVER_CHAN_CONF["secret"].strip() != ""
):
try:
secret = TickerConfig.SERVER_CHAN_CONF["secret"].strip()
sendServerChanUrls = urls.get("ServerChan")
sendServerChanUrls["req_url"] += f'{secret}.send'
params = {"text": "易行购票成功通知", "desp": msg}
httpClint = HTTPClient(0)
sendServerChanRsp = httpClint.send(sendServerChanUrls, params=params)
if sendServerChanRsp.get("errno") == 0:
print(u"已下发 Server酱 微信通知, 请查收")
else:
print(sendServerChanRsp)
except Exception as e:
print(u"Server酱 配置有误 {}".format(e))
if __name__ == "__main__":
sendServerChan(1)

@ -408,6 +408,19 @@ urls = {
"is_logger": False, "is_logger": False,
"is_json": True, "is_json": True,
}, },
"ServerChan": { # Server酱 push通知
"req_url": "/",
"req_type": "get",
"Referer": "",
"Content-Type": 1,
"Host": "sc.ftqq.com",
"re_try": 10,
"re_time": 0.01,
"s_time": 0.1,
"is_logger": True,
"is_json": True,
},
"cdn_host": { "cdn_host": {
"req_url": "http://ping.chinaz.com/kyfw.12306.cn", "req_url": "http://ping.chinaz.com/kyfw.12306.cn",
"req_type": "post" "req_type": "post"

@ -1,6 +1,7 @@
# -*- coding=utf-8 -*- # -*- coding=utf-8 -*-
from config.emailConf import sendEmail from config.emailConf import sendEmail
from config.pushbearConf import sendPushBear from config.pushbearConf import sendPushBear
from config.serverchanConf import sendServerChan
from init import select_ticket_info from init import select_ticket_info
@ -16,7 +17,11 @@ def PushbearConf():
sendPushBear("订票小助手测试一下") sendPushBear("订票小助手测试一下")
def PushServerChan():
sendServerChan("订票小助手测试一下")
if __name__ == '__main__': if __name__ == '__main__':
run() run()
# Email() # Email()
# PushbearConf() # PushbearConf()

Loading…
Cancel
Save