From 7cca86c86a398c6c668901605a9d253befcb425c Mon Sep 17 00:00:00 2001 From: murmur Date: Thu, 23 Mar 2023 15:56:02 +0800 Subject: [PATCH] =?UTF-8?q?s2wx=E5=8A=A0=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- s2f.py | 3 +++ server.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 s2f.py diff --git a/s2f.py b/s2f.py new file mode 100644 index 0000000..1c3c898 --- /dev/null +++ b/s2f.py @@ -0,0 +1,3 @@ + +def save2file(data): + pass \ No newline at end of file diff --git a/server.py b/server.py index 4c99263..378613d 100755 --- a/server.py +++ b/server.py @@ -10,6 +10,7 @@ import requests import socket # import json from threading import Timer +import s2f SERVER = "http://www.pushplus.plus/send" TOKEN = "ff328cba923a4225bc4acd0086a9014c" @@ -32,7 +33,7 @@ def pp2wx(title,content,description): requests.post(SERVER, json=ppmsg) msgcache=[] - +pushisbusy=0 def s2wx(title="",description="", content=""): """通过自建msgpusher发送至微信 当前title值无效 @@ -40,6 +41,9 @@ def s2wx(title="",description="", content=""): # return # 受API限制,频繁发送会失败 # 拟合并发送,满3条已发送,超时时间10s + if pushisbusy: + return + pushisbusy=1 if len(content): t=f""" *时戳:* @@ -67,7 +71,7 @@ _{datetime.datetime.now()}_ send() msgcache.clear() t= Timer(10,s2wx).start() - + pushisbusy=0 # GET 方式 # res = requests.get(f"{SERVER}/push/{USERNAME}?title={title}" # f"&description={description}&content={content}&token={TOKEN}") @@ -92,7 +96,7 @@ _{datetime.datetime.now()}_ # return None # else: # return res["message"] -t=Timer(10,s2wx).start() +# t=Timer(10,s2wx).start() cache = defaultdict(list) offs = 0 # 偏移量 @@ -392,6 +396,7 @@ class MyServer(socketserver.BaseRequestHandler): if not data: break add_timestamp() + s2f.save2file(data) t = f"接收到新数据,长度{len(data)}字节。" print(t) s2wx("","",t)