From 00818ecfea22fb09d4d30010c81d98c3a0fead09 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 30 Apr 2020 11:57:24 +0800 Subject: [PATCH] 1 --- tools/kefu_robot.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/kefu_robot.py b/tools/kefu_robot.py index f8db9d3..c30b02a 100644 --- a/tools/kefu_robot.py +++ b/tools/kefu_robot.py @@ -48,6 +48,25 @@ def sendNotify(conf, sendtime): tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + sendtime, lambda : sendNotify(conf, sendtime)) +def sendOrderNotify(conf, sendtime): + try: + print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%s"), flush=True) + print('sendOrderNotify start', flush=True) + params = {'key' : 'kingsome'} + secret = 'fc38349c5d084e920925e614c420be9f' + timestamp = time.time() + md5signstr = md5Sign(params, secret, timestamp) + url = conf['subscribe_notify_url'] + '×tamp=' + str(timestamp) + '&sign=' + md5signstr + req = urllib.request.Request(url) + data = urllib.request.urlopen(req).read() + print('sendOrderNotify end', flush=True) + except Exception as e: + print('sendOrderNotify error: ' + str(e), flush=True) + + #进入下一次循环 + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + sendtime, + lambda : sendOrderNotify(conf, sendtime)) + class SelfCheckingHandler(tornado.web.RequestHandler): def get(self): @@ -76,4 +95,17 @@ if __name__ == "__main__": lambda : sendNotify(conf, conf['sendtime2'])) tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['sendtime3'], lambda : sendNotify(conf, conf['sendtime3'])) + + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['signtime'], + lambda : sendOrderNotify(conf, conf['signtime'])) + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['boxtime'], + lambda : sendOrderNotify(conf, conf['boxtime'])) + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['diamondtime1'], + lambda : sendOrderNotify(conf, conf['diamondtime1'])) + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['diamondtime2'], + lambda : sendOrderNotify(conf, conf['diamondtime2'])) + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['diamondtime3'], + lambda : sendOrderNotify(conf, conf['diamondtime3'])) + tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['seasontime'], + lambda : sendOrderNotify(conf, conf['seasontime'])) tornado.ioloop.IOLoop.current().start()