diff --git a/server.py b/server.py index a03bb13..ee3c999 100755 --- a/server.py +++ b/server.py @@ -6,6 +6,29 @@ import pickle from collections import defaultdict import datetime import time +import requests +# import json + + +SERVER = "http://www.pushplus.plus/send" +TOKEN = "ff328cba923a4225bc4acd0086a9014c" +# SERVER = "https://msgpusher.com/push/test111" +# TOKEN = "tt" + +def s2wx(title,content): + """发送至微信. + title:标题 + content:内容""" + + ppmsg = {"token":TOKEN, + "template":"json", + "channel":"wechat", + "description": content, + } + ppmsg["title"] = title + ppmsg["content"] = content + # ppmsg["description"]= content + requests.post(SERVER, json=ppmsg) cache = defaultdict(list) offs = 0 # 偏移量 @@ -51,6 +74,9 @@ def update_pairs(addr, ccid, clear=0): if ccid and not clear: # 添加或更新客户端 + if ccid not in p: + t = "终端信息:\nCCID:" + ccid.decode() + "\n地址:" + str(addr.getpeername()) + s2wx("天通终端上线",t) p[ccid] = addr pp[addr] = ccid else: