diff --git a/server.py b/server.py index aed5cb0..fccb3fe 100755 --- a/server.py +++ b/server.py @@ -35,7 +35,7 @@ def s2wx(title,description, content): """通过自建msgpusher发送至微信 当前title值无效 """ - # return + return # GET 方式 # res = requests.get(f"{SERVER}/push/{USERNAME}?title={title}" # f"&description={description}&content={content}&token={TOKEN}") @@ -116,14 +116,18 @@ CCID:{ccid.decode()} del p[ccid] del pp[addr] - print("在线终端已更新。") # 打印在线终端 # for i in p: # print(i, "<--->", p[i]) + od= [] for i in pp: p[pp[i]] = i - print(pp[i],"<--->",i) - + # print(pp[i],"<--->",i) + od.append(f"{pp[i].decode()}<--->{i.getpeername()}") + # print('\r\n'.join(zd)) + clents = ' \n'+'\r\n'.join(od) if len(od) else "" + print("在线终端已更新,数量",len(od),clents) + s2wx("","",f"在线终端已更新,数量{len(od)}。{clents}") def get_addr(ccid): @@ -239,9 +243,6 @@ def tt_trans(addr, data): # 更新缓存 # {tccid1=[msg1,msg2,...],...} - if cache is None: - cache=[] - print(cache,tccid) cache[tccid].append(msg) save_cache(cache) @@ -365,7 +366,8 @@ CCID:{pp[self.request].decode()} if __name__ == "__main__": # load_cache - cache = load_cache() + if load_cache(): + cache = load_cache() socketserver.TCPServer.allow_reuse_address = True server = socketserver.ThreadingTCPServer(("", 7222), MyServer) add_timestamp()